How to automatically mount a LUKS-encrpyted iSCSI device at boot time

1

I have a Debian Lenny server and a client with Kubuntu 10.10. The server provides some iSCSI storage. One of the devices is the /home of the Kubuntu client.

I know how to add devices to /etc/crypttab and /etc/fstab but I have no clue how to make that wait until network init and iSCSI init have finished.

Any hints highly appreciated.

daniel

Posted 2011-04-12T19:58:36.153

Reputation: 11

Answers

1

In the meantime I found a solution on my own. One has to make the process wait for the iSCSI device to appear. By default this makes /etc/rc.local inappropriate but wait, there's process forking!

This is my complete /etc/rc.local and it works nice. When the graphical login manager appears it still takes 1-2 seconds for the filesystem to be mounted, so don't type in your password too fast.

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

(
        # wait for mount device to appear
        until [ -e /dev/mapper/iscsi_crypt ]
        do
                sleep 1s
        done

        # try to mount once and exit
        mount /home
        exit $?
)&

exit 0

Daniel

Posted 2011-04-12T19:58:36.153

Reputation: 11