The way to do it is the following, commands or files are in bold:
- sudo swapoff -a (turns off swap)
- comment existing swap configuration in /etc/crypttab
ex.
cryptswap1 /dev/sdb8 /dev/urandom swap,cipher=aes-cbc-essiv:sha256 - comment existing swap configuration in /etc/fstab
ex.
/dev/mapper/cryptswap1 none swap sw 0 0 - re-format swap partition with gparted as linux-swap
- sudo mkswap /dev/sdXX (create new swap, XX depends on your system and is the partition you formatted earlier, in my case it was sdb8)
- mark somewhere the UUID value that the previous command returns
ex.
Setting up swapspace version 1, size = 4208636 KiB
no label, UUID=06a9be15-d05b-466d-bfe3-a086bb9cdba0 - update /etc/initramfs-tools/conf.d/resume with the new UUID
ex.
RESUME=UUID=06a9be15-d05b-466d-bfe3-a086bb9cdba0 - sudo update-initramfs -u (update initramfs)
- sudo swapon /dev/sdXX (enable swap, XX depends on your setup)
- sudo ecryptfs-setup-swap (encrypt swap)
now you can check that swap is on by using the commands
free -m
total used free shared buffers cached
Mem: 11950 6662 5287 0 126 4002
-/+ buffers/cache: 2533 9416
Swap: 4109 0 4109
or
swapon -s
Filename Type Size Used Priority
/dev/mapper/cryptswap1 partition 4208636 0 -1