Encryption and Corruption - how I saved my encyrpted volume

My dell laptop battery is slowly losing it's moxy. It's juice so to speak. This does not mix well with Florida summer time weather as the power tends to go out A LOT.

A few months or years ago, I decided I needed to encipher my /home directory. I keep just about everything, neatly stored away, and if I were to ever lose my laptop then it would be a small gift of my inner most workings to the ill-gotten new owner.

I used truecrypt for this task.

For a long time, this worked well:
Bootup scripts run, prompt for passphrase for harddrive, mount it to /home directory, done

Yet, after multiple power outages, I started getting lock ups on the laptop. Eventually, I narrowed it down to some processes being stuck in D mode (for waiting on DATA). As I poked around, I learned it was stuck on the /home volume. Oh oh. Corruption.

I had to boot into linux's version of "safe mode", and check all my volumes:

$ xfs_check /dev/mapper/vol1-root
$ xfs_repair /dev/mapper/vol1-root

The truecrypt volume checked out alright, however, I still needed to be sure, so I created a new volume, and moved all the old data. I mounted my old /home volume in /mnt/backup, and mounted the new one in /home

$ lvcreate -n home.new -L 5G vol1
$ truecrypt -c /dev/mapper/vol1-home.new # follow instructions and create my volume
$ truecrypt /dev/mapper/vol1-home.new /home --filesystem=none
$ truecrypt /dev/mapper/vol1-home.old /mnt/backup --filesystem=none
$ mkfs.xfs /dev/mapper/vol1-home.new
$ mount /dev/mapper/vol1-home.new /home
$ mount /dev/mapper/vol1-home.old /mnt/backup -r #mount it read only
$ xfsdump -J - /mnt/backup | xfsrestore -J - /home
$ truecrypt -d /mnt/backup

After about 10 minutes, the xfs volumes were mirrors of each other. I rebooted, and everything came back as snappy and perfect as I could have hoped. Sometimes you just have to perform clean up every now and again.

Don't forget to remove the old volume:

$ lvremove vol1/home.old

If this has helped you, please drop me an email!

Recent comments