Nov
29

Mount TrueCrypt drive on boot time under Debian / Ubuntu

By rzelazko  //  Linux  //  2 Comments

There are several possibilities to mount encrypted, password protected TrueCrypt drive on boot time. This article describe how to create password protected TrueCrypt drive and mount it on boot time under GNU Linux.
We will create init.d script file and put them command which ask for password, create mount point and mount drive.
Requirements:

  • TrueCrypt – download it and install from truecrypt.org site
  • Debain / Ubuntu :)
  • Root prvivileges (I’m using sudo command)

First step – create encrypted drive

  1. Method 1: encrypting drive with TC GUI: run TrueCrypt from menu, click on Create Volume, Create volume within partition/drive, Standard TC volume, get algorithm, type password (uncheck Use keyfiles option), next, next, next, exit :)
  2. Method 2: encrypting drive from command line. TODO

Second step – write init.d script file

Login as root, download my init.d file, edit it to your needs.

1
2
3
4
5
6
sudo su
cd /tmp
wget -c "http://rafal.zelazko.info/wp-content/uploads/2009/11/29/tc.tgz"
tar -xvzf tc.tgz -C /etc/init.d
cd /etc/init.d/
vim tc

Edit /etc/ini.d/tc file. Find there two constant and rewrite them:

1
2
TC_DEVICE="/dev/sda" # type here path to encrypted device
TC_MOUNT_POINT="/media/truecrypt2" # type here mount point

Notice: above script mounts standard (not hidden) password protected, with no key files, device. To automatically mount other kind of TC volume you must rewrite some script parts (or ask me, write comment, etc)

Test init script:

1
2
3
4
invoke-rc.d tc start # if everything is correct you should be asked for password
ls -la /media/truecrypt # type here mount point
# there should be list of files stored on encrypted volume
invoke-rc.d tc stop # umount encrypted device

Third step – add script which mounts encrypted drive to Debian / Ubuntu autorun
Now when everything is correct you can put your script to debian autorun. To do this simple type following command.

1
update-rc.d tc defaults

Reboot your computer, on next boot there should be password prompt :)

Other solution

Main linux distribution, including Debian and Ubuntu, has alternative for TrueCrypt: LUKS (Linux Unified Key Setup). Maybe later I’ll write article how to use it on Debian / Ubuntu…

2 Comments to “Mount TrueCrypt drive on boot time under Debian / Ubuntu”

Leave a comment