Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following scenario:

I want to automatically backup some data from my Laptop(Fedora Core 17) to a external encrypted(luks) hard disk. The disk can be opened by a key file, which lies on the also encrypted root partition of my laptop. The hard disk is attached to my docking station and therefore only "present" when I am at home (which is approximately 1/2 of the time the Laptop runs)

I have everything set up the way I want it with one exception.

I don't get a decent way to mount the hard disk automatically at boot if and only if it is present.

If I add it to crypttab and fstab without noauto it tries to mount it at boot and takes a lot(!) of time and error messages when it is not present. If I add noauto, well it does not mount automatically ;)

Is there a way to configure luks/crypttab to do the following:

  • check whether the disk is present
  • if yes: decrypt/mount
  • if no: just don't
share|improve this question
    
Removed 'backup' tag because the question is unrelated to backups per se. – Michael Kjörling Sep 25 '12 at 11:57
    
Yeah, sorry I did add it because I want to use this setup for backup purposes. But yeah, it is totally irrelevant, thanks. – Frederick Roth Sep 25 '12 at 13:26
up vote 2 down vote accepted

I don't have a ready-made answer with exact file names and commands for you, but I would add something to a late-running init script such as /etc/init.d/local that would look in one of the /dev/disk/by-* directories to see if the LUKS partition is available, and proceed if it is.

Perhaps something similar to:

start_luks_backup_disk() {
  cryptdisks_start yourlukspartition && \
  mount /mnt /dev/mapper/yourlukspartition
}

test -b /dev/disk/by-uuid/8317fb0e-0707-11e2-8a07-5b563062136f \
&& start_luks_backup_disk
share|improve this answer
    
Thanks, I had hoped, that there would be an answer which does not involve scripting. But if I don't find something better I will use your approach. – Frederick Roth Sep 25 '12 at 13:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .