Celebrate Our 22nd Anniversary with Huge Savings! Up to 70% Off

How to Remove Swap Space from CentOS 7.x?

Please refer to the following steps to remove Swap Space from CentOS 7.x – 

1. First, use the command below to check whether your system is running with the Swap Space. 

swapon -s

It will list the Swap Space with its location

2. As per the above location, Swap Space is located at /dev/vdb since it is a virtual server.
We will disable the Swap Space by executing this command – 

swapoff -v /dev/vdb

3. After that, you can check with the free command to verify that the Swap is disabled.

free -m

4. Remove the Swap entry from /etc/fstab.
To do this, edit the fstab file and remove the Swap entry.

5. Let’s regenerate Mount units to register the new configuration – 

systemctl daemon-reload

6. Finally, remove the actual Swap file.

rm -rf /dev/vdb

This is it.

We have successfully removed the Swap Space.

 

Looking to add a new Swap Space?
Please refer to Accuweb > Add Swap Space article for more details.



Was this answer helpful?

« Back

chat