How do I setup an encrypted swap file?
Thanks to this guide I set up an encrypted swap file (can't be used for hibernation). On Debian based distributions, you will need the cryptsetup
package for these instructions.
Firstly create an appropriately sized file (here 4 gigabytes) to store the swap data:
fallocate -l 4G /cryptswap
Add the following to
/etc/crypttab
:cryptswap /cryptswap /dev/urandom swap
Activate the newly created encrypted drive:
service cryptdisks reload
Add the following to
/etc/fstab
:/dev/mapper/cryptswap none swap sw 0 0
Activate the new swap file:
swapon -a
Skip the reboot:
sudo cryptdisks_start cryptswap
where cryptswap
is the name in /etc/crypttab