Enable/Disable Swap on Ubuntu at startup

For enabling swap on startup, you have to check your fstab file to see if some there has been some changes to be made since you first made swap. Edit the fstab file with gedit with the sudo command.

If you are new to Ubuntu then you might be wondering what is Swap? Swap is a space created on your hard disk as a Virtual Memory and used to store memory pages for applications when your have less free RAM, you can read more about Swap and Ubuntu at Swapfaq.

Normally swap partitions are advised to be created at the time of installation, but it can be resized with partition editors later. Once swap partition is created, you can view the swap usage on system monitor on Ubuntu, But if by any chance you see that Swap is not being used then you might have to try this to enable it on the start up. You can manually enable or disable swap usage from Gparted Partition Editor.

For enabling swap on startup, you have to check your fstab file to see if some there has been some changes to be made since you first made swap. Edit the fstab file with gedit with the sudo command.

sudo gedit /etc/fstab
gedit fstab

fstab edit

This will open the geditor to edit the fstab settings. Check to see if the line having swap hasn’t been commented out with a ‘#‘ sign at the beginning. If it is, you’ll have to remove it for Swap to be enabled at boot. If it isn’t then you have to check the UUID to see if it matches the UUID of the swap partition.

To check, you can use Gparted. Left click on the partition labled linux-swap and view information. There you will find the UUID for the partition. You’ll have to replace the UUID on the fstab file with this one to enable swap at startup.

Then save the fstab file on gedit, and recheck any mistakes. Do not make any changes to other lines if you don’t know what you’re doing. Then restart Ubuntu.

Leave a Reply