Swap vanished after reboot

Solution 1:

This is not happening in the reboot. After you finish your setup (running ecryptfs-setup-swap), go back to gparted and reload the table & open a terminal and run: sudo fdisk -l /dev/sda. You gonna find that partition still having Id 83 Linux Swap and became in Unknown format.

Why is that?! It became an encrypted partition already.

In /etc/fstab:

  • Old swap partition was commented.
  • New mapped one inserted:

    /dev/mapper/cryptswap1 none swap sw 0 0
    

This is fine.

In /etc/crypttab:

  • A new line added to map the swap:

    cryptswap1 UUID=xxxx /dev/urandom swap,cipher=aes-cbc-essiv:sha256
    

But there is something wrong here, Does an encrypted partition have a UUID (non-encrypted)?!!!

  1. So set the dev path directly as this example:

    cryptswap1 /dev/sdXX /dev/urandom swap,cipher=aes-cbc-essiv:sha256
    
  2. Reboot then the Swap will be on.

BTW, This should be reported as a bug. ecryptfs-setup-swap should use device path instead of uuid.

Update: I could find same answered question which include the bug report too.

  • Swap not working on clean 14.04 install using encrypted home
  • Bug report#953875 Encrypted swap no longer mounted at bootup

It contains the canonical answer by adding an offset= in the crypttab options.