Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In short: Please provide me with a up-to-date best practice solution to mount my Truecrypt volumes at boot with secure password prompt! I may accept a answer that has nothing to do with Truecrypt and just shows me how the get some prompt at a boot stage, most likely a Truecrypt command will work at that point as well!

This command can be used to test it.

read -n1 -r -p "Press any key to continue..." key

I wish to not discuss any Truecrypt or drive related matters, or anything else think you might think are related or could help. I like to get a prompt at boot nothing else.

Is this maybe possible with upstart script? Or do they run in in background as well?

What I tried already:

  1. rc.local - get ignored for whatever reason
  2. KDE start script set to "before login" with my autologin in KDE it get executed in background during KDE load (harddisk symbol) and stops there I see nothing can't do anything but rename the script to get into KDE
  3. .profile - gets ignored (or runs silently in background as well)
  4. KDE start script set to "login" is to late it get executed when the GUI is fully loaded, by backup services (crashplan and dejapub) are already running and don't have the the disk mounted thats setup for backups what leads to things I want to avoid.
share|improve this question
    
I'm not sure what you would like to accomplish. Do you want to encrypt your disk and get a prompt asking for the password before your system can boot? OR do you want a script that halts your boot process and displays a prompt (for whatever reason)? –  Wolfer Mar 5 '13 at 17:40
    
My disk is already encrypted, and yes i want the boot process to halt, ask me for the password and then mount the truecrypt data disk/partition (this is not my linux partitions they are taken care of) and continue boot. –  James Mitch Mar 5 '13 at 18:32
add comment

1 Answer 1

I use the following script, which I've added to my Startup Applications, to automount my "favourite" truecrypt partitions upon login and to autodismount them when I logout/shutdown.

When logging in, truecrypt starts and prompts me for my admin password and for the passwords to the truecrypt volumes (with keys if you use them). Note that storing the path to the key in this script is optional - I include it here to show that it can be done.

#!/bin/bash
truecrypt --auto-mount=favorites -k /path/to/truecrypt/keyfile --background-task &

# store the PID of the truecrypt process
tcPid=$!

tcTerm()
{
# unset the DISPLAY
# (otherwise it tries to contact X server which somehow fails during logout)
  unset DISPLAY
  truecrypt -d
}

# trap signals to this script and unmount
trap "tcTerm; exit 0" 1 2 15
wait "${tcPid}"
exitStatus=$?

# unmount only if truecrypt exited abnormally
if [ $exitStatus -eq 1 -o $exitStatus -eq 2 -o $exitStatus -eq 15 ]; then
  tcTerm
  rm -f "${HOME}"/.TrueCrypt-lock-*
fi

exit 0
share|improve this answer
    
"which I've added to my Startup Applications" clarify that statement! As I said already in the question i use KDE and when i set scripts like this into the KDE autostart to "login" it's to late the backup programs are most likely loaded already at this point, and if not they will load white i type my password into the truecrypt dialog. Or is this a console script? Does it ask you for password on the console at boot stage? My guess is not. I don't really understand the X server thing either, you can give Truecrypt some witch to run in console mode so it not needs to contact a X server. –  James Mitch Mar 4 '13 at 21:04
    
So if a am wrong about what i said above i am sorry. If I am right you failed to carefully read my question and this is not what i asked for! –  James Mitch Mar 4 '13 at 21:06
    
this is a bash script, so it can be run in the console; however, I run it in my xsession at login. I'm sorry if this isn't exactly what you had hoped for, but at the very least I hope you (or others) can see the commands I'm using and modify this script for your own purposes (i.e., run the core of the script - the line after the shebang - in terminal at boot, without needing to be logged in). –  amc Mar 4 '13 at 23:05
    
Well, I had some command very much like this running until i discovered it was to late... –  James Mitch Mar 5 '13 at 18:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.