Pages

24/05/2014

[Ubuntu] Add swap partition and change swappiness

If for some reason(s) you decided to install Ubuntu without specifying a swap partition, you can still add one (or a swapfile) later on without too much hassle.


To sum up the above linked steps:

1. add a swap partition with gparted
2. find the newly created swap partition UUID by right-clicking on it and selecting "Information"
3. add the swap partition to you fstab file:

gksu gedit /etc/fstab

and find the line that contains "swap". Edit it to add the UUID of your swap partition, eg:

UUID=YOUR_UUID none swap sw 0 0

save and exit

4. enable the swap partition:

sudo swapon --all

5. check if everything is good by confirming that the swap partition appears in the output of:

cat /proc/swaps 

Note: you now have a working swap partition but you're still missing some configuration to use it for hibernation.

Another useful setting to edit is the swappiness which suggests to the system how to handle swapping. It goes from 0 to 100 where 0 is "try to avoid swapping at all costs" and 100 is "swap as much as you can"; default is 60.

To permanently edit that value simply run:

gksudo gedit /etc/sysctl.conf

then find the line:

vm.swappiness=60

and edit as per your preference


No comments:

Post a Comment

With great power comes great responsibility