How should I correctly set up my encrypted swap partition? How can I ensure that the setup persists?

I'm running 14.04 using encrypted home folder. I noticed that occasionally my machine would grind to a complete halt for a minute or so. I finally realized that my machine showed that it did not have any swap space set up and my memory was filling up and nothing could be swapped when this happened.

/dev/sda6 is the partition of interest in my case.

How I Made Swap Work Yesterday

I reformatted the swap partition to linux-swap format via gparted and put its UUID, obtained from blkid /dev/sda6, in the appropriate /etc/crypttab entry. I then rebooted the system. Swap file was available and working correctly.

How Swap Stopped Working Again


Steps I've taken to diagnose this situation, things I modified, etc.:

  • free -m shows 0MB total swap space available

    dmays@vipertooth:~$ free -m
                 total       used       free     shared    buffers     cached
    Mem:          5875       2238       3636        270         98       1007
    -/+ buffers/cache:       1133       4741
    Swap:            0          0          0
  • gparted shows the swap partition as "Unknown"

gparted screenshot -- /dev/sda6 is partition of interest

  • blkid /dev/sda6 returns exit code 2.

  • swapon -s shows only column headers

    dmays@vipertooth:~$ swapon -s
    Filename                Type        Size    Used    Priority
  • swapon -a fails with exit code 255

    dmays@vipertooth:~$ sudo swapon -a
    [sudo] password for dmays: 
    swapon: /dev/mapper/cryptswap1: stat failed: No such file or directory
  • modified /etc/crypttab from yesterday

    cryptswap1 UUID=4602a330-ead0-4198-be26-47a5b16666e1 /dev/urandom swap,cipher=aes-cbc-essiv:sha256
  • examined fstab -- it appears my /home may not be encrypted???

    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    # / was on /dev/sda5 during installation
    UUID=b09ec379-a94d-4905-b4ac-2f5c62b5605d /               ext4    errors=remount-ro 0       1
    # /home was on /dev/sda7 during installation
    UUID=d57bf732-77df-44fe-b547-d15a48dd1857 /home           ext4    defaults        0       2
    # swap was on /dev/sda6 during installation
    /dev/mapper/cryptswap1 none swap sw 0 0

1 Answer 1


This appears to be a known bug.

Credit to redsandro's answer on a duplicate question for info about the bug and a quick fix for it.

I implemented the "Easy Fix" as stated in the above answer and by user foenhn-2 in a comment to the bug report. Even though this fix is functional I may attempt to get the offset=X method to work in order to keep the swap partition's UUID intact.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.