Wednesday, 19 September 2012

Fixing a Broken Encrypted Swap Partition (Ubuntu and Xubuntu 12.04)

For some reason, with all of the Ubuntu derivatives I end up with a busted SWAP partition. This manifests itself in no defined SWAP at all, and a blacked out SWAP partition when viewed in Gparted. The solution is to redefine the SWAP partition, as follows. (If in doubt where your SWAP partition is, run 'sudo fdisk -l'.)
sudo swapoff -a
sudo cryptsetup remove /dev/mapper/cryptswap1
sudo gedit /etc/crypttab
Remove the SWAP line (e.g. /dev/sda3)
sudo /sbin/mkswap /dev/sda3
sudo swapon /dev/sda3
sudo gedit /etc/fstab 
Replace /dev/mapper/cryptswap1 with /dev/sda3.

If you're feeling brave and fancy trying to re-encrypt it, use...
sudo ecryptfs-setup-swap
If it all goes wrong, just repeat the process above.

N.B. Obviously /dev/sda3 in the above example is just that, an example. Replace it with whatever you find in your 'sudo  fdisk -l' results.

** To test whether swap is enabled use:
free -m

No comments:

Post a Comment