How to enable linux swap partition?

I've got a swap partition, but the System Monitor in Linux Mint says, 'Swap not available'. I guess I've forgot to set 'Use as: swap' on install.

How to fix this?


Solution 1:

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.

Solution 2:

GUI way:

  1. start GParted (builtin Disks utility won't do)
  2. ensure the partition is formatted as linux-swap (mine was displayed as swap in Disks but non-formatted in GParted), apply the formatting operation
  3. right-click, 'swapon'. Done.