Encrypted Swap on Debian

Setting up an encrypted swap partition on Debian.

Installation

Install cryptsetup:

# apt-get install cryptsetup

Configuration

Disable any existing swap areas:

# swapoff -a

Wipe the swap partition (we use 1GB /dev/sdb3):

# dd if=/dev/urandom of=/dev/sdb3 bs=10M

Add swap partition to /etc/crypttab:

# cat > /etc/crypttab << EOL
swap /dev/sdb3 /dev/urandom swap
EOL

Add to /etc/fstab:

# echo "/dev/mapper/swap none swap sw 0 0" >> /etc/fstab

Reload cryptdisks and enable all swap devices:

# /etc/init.d/cryptdisks reload 
# swapon -a

References

http://www.microhowto.info/howto/create_an_encrypted_swap_area.html

Leave a Reply

Your email address will not be published. Required fields are marked *