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.
- TrueCrypt – download it and install from truecrypt.org site
- Debain / Ubuntu
- Root prvivileges (I’m using sudo command)
First step – create encrypted drive
- 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
- 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.
wget -c "http://rafal.zelazko.info/wp-content/uploads/2009/11/29/tc.tgz"
tar -xvzf tc.tgz -C /etc/init.d
/etc/ini.d/tc file. Find there two constant and rewrite them:
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:
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.
update-rc.d tc defaults
Reboot your computer, on next boot there should be password prompt
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…