How to Permanently Disable Swap in Linux? - GeeksforGeeks (2024)

Last Updated : 08 Oct, 2021

Summarize

Comments

Improve

Swapping or swapping space is a physical memory page placed at the top of a disk partition or a special disk file that is used to expand a system’s RAM as the physical memory fills up. Inactive memory pages are often dumped into the swap area when no RAM is available, using this method of expanding RAM resources. However, swap space is much lower in transfer speeds and access time compared to RAM, due to the spinning speed of standard hard disks.

Reserving a small partition for swapping will significantly increase access time and speed transfer compared to conventional HDD on newer machines with fast SSD hard drives, but the speed is still lower than RAM memory. Some say that it is appropriate to set the swap space to twice the amount of computer RAM. However, swap space should be set to 2 or 4 GB on systems with more than 4 GB of RAM.

If your server has sufficient RAM memory or does not need the use of swap space or your device output is significantly reduced by swapping, you can consider disabling the swap field.

You first need to visualize your degree of memory load before actually disabling swap space, and then identify the partition that holds the swap area by issuing the commands below.

free -h 

Look for the Used Swap Space size. If 0B or close to 0 bytes is the size used, it can be assumed that swap space is not used intensively and can be disabled for protection.

How to Permanently Disable Swap in Linux? - GeeksforGeeks (1)

Next, check for TYPE=”swap” line after the blkid command to define the swap partition, as shown in the screenshot below.

blkid

How to Permanently Disable Swap in Linux? - GeeksforGeeks (2)

check swap partition type

Again, issue the following lsblk command to search and identify the [SWAP] partition as shown in the below screenshot.

lsblk

How to Permanently Disable Swap in Linux? - GeeksforGeeks (3)

Search Confirm Swap Partition

Run the below command to deactivate the swap area after you have identified the swap partition or file.

swapoff /dev/mapper/centos-swap 

Or disable all swaps from /proc/swaps.

swapoff -a 

To check if the swap area has been disabled, run the free command.

free -h

How to Permanently Disable Swap in Linux? - GeeksforGeeks (4)

Disable Swap Partition

To permanently disable Linux swap space, open the /etc/fstab file, search for a swap line and add a # (hashtag) sign in front of the line to comment on the entire line, as shown in the screenshot below.

vi /etc/fstab

Afterwards, reboot the system in order to apply the new swap setting or issuing mount -a command in some cases might do the trick.

mount -a

After a system reboot, the commands presented at the beginning of this tutorial should be issued to indicate that the swap area in your system has been completely and permanently disabled.

free -hblkid lsblk 

In simple ways or the other step:

If you really want to disable swapping (note: this is not suggested, even if you’re pretty sure there’s more than enough physical RAM), follow these steps:

  • Run swapoff -a: this will immediately disable the swap.
  • Remove any swap entry from /etc/fstab.
  • Get the system rebooted. Ok, if the swap is gone. If it’s still here for some reason, you have to remove the swap partition.
  • Repeat steps 1 and 2 and, after that, use fdisk or parted to delete the (now unused) swap partition. Use great caution here: removing the wrong partition would have devastating results!


Please Login to comment...

How to Permanently Disable Swap in Linux? - GeeksforGeeks (2024)
Top Articles
In Search of Free Books
Can You Escape System Requirements - Can I Run It? - PCGameBenchmark
Kmart near me - Perth, WA
Brady Hughes Justified
Craigslist Niles Ohio
Nyu Paralegal Program
Craigslist Mpls Mn Apartments
Ds Cuts Saugus
Craigslist Portales
My Boyfriend Has No Money And I Pay For Everything
Sam's Club Gas Price Hilliard
Puretalkusa.com/Amac
Acts 16 Nkjv
Draconic Treatise On Mining
What’s the Difference Between Cash Flow and Profit?
Raid Guides - Hardstuck
Thayer Rasmussen Cause Of Death
OpenXR support for IL-2 and DCS for Windows Mixed Reality VR headsets
Fredericksburg Free Lance Star Obituaries
Playgirl Magazine Cover Template Free
Fdny Business
10-Day Weather Forecast for Santa Cruz, CA - The Weather Channel | weather.com
Jalapeno Grill Ponca City Menu
Why Should We Hire You? - Professional Answers for 2024
We Discovered the Best Snow Cone Makers for Carnival-Worthy Desserts
John Chiv Words Worth
Okc Body Rub
Directions To Cvs Pharmacy
The best brunch spots in Berlin
Devotion Showtimes Near Regency Buenaventura 6
Robotization Deviantart
Tactical Masters Price Guide
Tomb Of The Mask Unblocked Games World
100 Gorgeous Princess Names: With Inspiring Meanings
Progressbook Newark
Free Tiktok Likes Compara Smm
Sf Bay Area Craigslist Com
Pitco Foods San Leandro
Tillman Funeral Home Tallahassee
Bones And All Showtimes Near Johnstown Movieplex
'Guys, you're just gonna have to deal with it': Ja Rule on women dominating modern rap, the lyrics he's 'ashamed' of, Ashanti, and his long-awaited comeback
Miami Vice turns 40: A look back at the iconic series
Luciane Buchanan Bio, Wiki, Age, Husband, Net Worth, Actress
Natasha Tosini Bikini
BCLJ July 19 2019 HTML Shawn Day Andrea Day Butler Pa Divorce
Nimbleaf Evolution
Holzer Athena Portal
How To Get To Ultra Space Pixelmon
Enter The Gungeon Gunther
Dineren en overnachten in Boutique Hotel The Church in Arnhem - Priya Loves Food & Travel
Wvu Workday
Koniec veľkorysých plánov. Prestížna LEAF Academy mení adresu, masívny kampus nepostaví
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 6077

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.