Monday, September 12, 2016

How to Disable Swap Space

These days, memory costs so cheap that unless you are running multiple instances of virtual machines and heavy-load programs, swap space is no longer necessary. In my case, I have 16GB of RAM, and the default swap space allocated by Ubuntu is 16GB, which I think is waste of disk space. So, I decided to remove swap space. Here is how.

Disable swap:
$ sudo swapoff -a

If you want to permanently disable swap space, you may want to free disk space allocated to swap space. To do this, first remove auto-mounting swap at boot:
$ sudo vim /etc/fstab

In the file, comment out the line that is mounting the swap space. It should be obvious. In my case, it reads like:
#/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0

Now, you may want to use gparted or any other utilities and tools to free up the space!

No comments:

Post a Comment