16

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?

1
  • Just a warning: in mint Disks gui, I used the same value that my ram size. It created a smaller partition. I guess its because they use power of10 instead of power of 2 values.
    – Jerome_B
    Aug 13, 2020 at 9:50

4 Answers 4

27

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.

5
  • Interestingly, GParted added the following line: /dev/mapper/cryptswap1 none swap sw 0 0
    – ansgri
    Jan 10, 2015 at 9:57
  • ah interesting, it seems that there is some disk encryption enabled, at least for the swap partition...
    – Ale
    Jan 10, 2015 at 9:58
  • 2
    ... Encrypted swap? Good grief. Jan 10, 2015 at 17:53
  • 3
    @Shadur: Not sure if you're being serious, but if you're using any kind of disk encryption (say, you don't want your files and passwords to be stolen if you lose your laptop), then you most certainly do want to use encrypted swap, too. Otherwise, you compromise security as soon as you hibernate your laptop. Besides, there's no good reason not to encrypt swap nowadays, since the cost of encryption is totally negligible compared to the cost of swapping the data to disk in the first place. Jan 10, 2015 at 19:22
  • 1
    @Shadur: encrypted swap will possibly become default in the future. It is already the case in MacOS X since version 10.8, and can be enabled (from command line) on Windows since Vista. Except on very low-end hardware, I don't see a reason not to use encrypted swap.
    – Ale
    Jan 11, 2015 at 14:38
8

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.
2
  • 2
    This won't be persistent across reboot. Or does gparted automatically edit fstab?
    – Ruslan
    Jan 10, 2015 at 10:39
  • @Ruslan: seems it does (see ansgri's comment to my post)
    – Ale
    Jan 10, 2015 at 12:15
0

I had a similar problem.

  1. I used the "GUI way" posted by ansgri to change the format for the swap partition from unknown to linux-swap.This didn't solve the problem, but may have helped.

  2. I found that the UUID shown in /etc/crypttab was incorrect.

  3. I ran blkid to find the correct UUID for the swap partition.

  4. Modifed /etc/crypttab to read the correct UUID.

    and swap is now loaded correctly.

Hope that helps.

0

I did the GUI method as well but also changed the UUID in both /etc/crypttab and /etc/fstab to match the info displayed by blkid, i restarted and it worked, as a side note with my SWAP being at 36gb and my RAM being 32gb my hibernation button works now, since the SWAP is larger than the RAM.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .