Tuesday, March 13, 2012

Running fsck on a Truecrypt Volume

We use an external hard drive encrypted with Truecrypt for backups, and I always forget how to run fsck on it, so I'm just going to document it here. It is actually really simple to do from a Linux terminal.

Since Truecrypt mounts volumes when it decrypts them, it can be a little confusing how to run an fsck (file system check) on them, since you shouldn't run fsck on a mounted filesystem. The solution is to not mount it when you decrypt it, by passing the "--filesystem=none" argument. So if you normally use this command to decrypt the volume:
sudo truecrypt -p secretpassword -k "" --protect-hidden=no /path/to/disk /media/secretspystuff

You would instead use this command to decrypt it without mounting:
sudo truecrypt -p secretpassword -k "" --protect-hidden=no /path/to/disk --filesystem=none

To see where the raw volume is, simply run:
truecrypt -l

And you will get output similar to this:
1: /path/to/disk /dev/mapper/truecrypt1

Now you can run fsck on that how you normally would:
sudo fsck -f /dev/mapper/truecrypt1

Once you are done, you can dismount it with:
sudo truecrypt -d /path/to/disk

or this (which will dismount ALL truecrypt drives):
sudo truecrypt -d

Easy peasy.

5 comments:

  1. Thanks. This saved me after accidentally switching off my HDD while mounted!

    ReplyDelete
  2. TrueCrypt was the most well known encryption programming. The sudden desert of the open source extend left numerous hypotheses and even prompted numerous paranoid ideas. Official Truecrypt site began diverting to SourceForge page.

    ReplyDelete
  3. Information still valid also for veracrypt. Great article.
    Thank you.

    ReplyDelete
  4. Works also for realcrypt. Thanks.

    ReplyDelete