It is sensible that if you have any sort of block device encryption implemented on your GNU/Linux system, to encrypt your swap partition too, as any decrypted data may be written in cleartext at any time to the swap.
Looking at the debian man page for "crypttab" I see an example of creating a randomly keyed swap partition on boot-up, so the key is set randomly as the boot proceeds and known only to the system itself:
# Encrypted swap device cswap /dev/sda6 /dev/urandom cipher=aes-cbc-essiv:sha256,hash=ripemd160,size=256,swap
In this example the swap device is referred to by a conventional dev path i.e.
Absolute device paths are subject to change and be re-assigned at boot-up if, say a usb drive is plugged in, for example. A user would be very unhappy if
/dev/sda6 happened to be a different partition than expected and it was subsequently overwritten with random swap data!!
So the solution would seem to be: use a UUID instead of a device path (as a UUID shouldn't change), replacing
/dev/disk/by-uuid/<whatever the uuid of dev/sda6 is>
BUT ... here's the problem: Every time cryptsetup recreates the encrypted swap partition at boot time it generates a new UUID for it! Doh!
So we need to preserve the UUID of this encrypted filesystem somehow. I think cryptsetup can do this with its
--offset switch, allowing for preservation of the LUKS header and thus the UUID.
Does anyone know how to implement the solution described for Arch Linux on the Debian OS? The init scripts referred to in the document seem not to exist on the Debian OS
One could use ecryptfs to achieve the same ends (encrypted swap space) using the command:
Without the problems that beset block device encryption.
Have a look at this AskUbuntu query