How To View & Disable Swap Memory in CentOS

The swap feature in operating systems such as CentOS is an essential component that allows for the efficient utilization of system resources. Swap is essentially a space that can be represented by a file or partition on the hard disk, which is used to store temporary files and data when the RAM memory is fully utilized. This feature enables the system to operate smoothly and prevents it from crashing due to insufficient memory.
However, with the advent of solid-state drives and the availability of larger RAM capacities, the need for swap space has diminished. In fact, disabling the swap partition in CentOS can actually optimize the system's resources and improve its performance.
By disabling the swap partition, the system can utilize its RAM memory to its fullest potential without relying on the hard disk space. This results in faster data access and processing times, thereby improving overall system performance. Additionally, disabling swap can also reduce wear and tear on the hard disk, which can prolong its lifespan.
It is important to note that disabling swap is not recommended for systems with less than 8 GB of RAM or those that frequently use memory-intensive applications such as video editing software or virtual machines. In such cases, swap space can still be useful in preventing system crashes and improving overall stability.
See Amount of Swap Memory in CentOS
First of all we must verify what amount of swap memory is defined for the equipment, this is possible to verify using the following command:
free -h
In this example we can see that although we have 1.8 GB available for swap memory, the use is in 0 bytes, so there is an indication that physical memory is more than enough for the tasks carried out in CentOS.
Now, to identify the path where swap is located, we must execute the blkid command :
sudo blkid
We can observe the line TYPE = “swap” to define and identify the swap partition. Now, we will run the lsblk command and we will see the following:
There we can determine that the swap partition is hosted on sda2. Once we identify the partition where swap is, we proceed to execute the following command to disable swap in CentOS 7:
swapoff /dev/mapper/centos-swap
swapoff -a
We run the free -h command again to verify that swap has been disabled correctly:
Permanently Disable Swap Memory in CentOS 7
If the objective is to permanently disable the swap partition in the system, we must access the file / etc / fstab using the desired editor:
nano /etc/fstab
Once there, we should comment on the swap line by prefixing the # sign like this:
We save the changes using the following key combination Ctrl + O and exit the editor using Ctrl + X.
Then we can restart the operating system, or use the mount -a command to apply the changes.
After this we can execute the following commands to verify that swap has been permanently disabled:
free -h blkid lsblk
This way we have disabled swap in CentOS.
It might be interesting
Google earth app for Android out in the market!
There appears to be excellent news for Android users because the Google Earth app is finally here for use. In fact the image quality is as amazing which is used for the PC version.
Latest Technologies for Creating Trendy Android Apps in 2021
Android is unquestionably one of the most popular mobile operating systems, with more than 88% of the market share. There are more than 3.10 million apps in Google Play Store. The technologies & apps range from web browsers, calendars to Android App development Services & many more.
Android 13 lets you run Windows 11 directly on your smartphone
Android developer Danny Lin, known under the Twitter nickname kdrag0n, launched the Google Pixel 6 OS Windws 11, or, more precisely, its version for devices with CPUs on the Arm architecture.
Apple teams up with Google, Mozilla, and Microsoft to improve browser compatibility
Apple is working with Google, Microsoft and Mozilla in a new effort to improve the compatibility and usability of their Web browsers.