How to enable linux swap partition?
You can simply add a line declaring your swap partition to /etc/fstab
. So, if your swap partition is /dev/sdaX
, add this entry in fstab
:
/dev/sdaX none swap sw 0 0
If your swap partition wasn't properly formatted as such, you can initialize it (make sure you put the right partition name for this command as you might easily destroy the contents of another partition):
sudo mkswap /dev/sdaX
To enable the newly declared swap partition, just use:
sudo swapon -a
(or reboot).
EDIT: if you have an encrypted swap partition, instead of /dev/sdaX
, you will have to use its name (/dev/mapper/something
), look in /etc/crypttab
, the name is on the first column.
GUI way:
- start GParted (builtin Disks utility won't do)
- ensure the partition is formatted as linux-swap (mine was displayed as swap in Disks but non-formatted in GParted), apply the formatting operation
- right-click, 'swapon'. Done.