5. Automatic mounting
In order to make the mounting of the USB stick and EHD happen automatically we need to resort back to some shell scripting and also to setting up an init script.
Shell script
First, download the usbcrypthd bash script into your home directory.
Then, copy the script to /usr/local/sbin
with the following command:
sudo cp usbcrypthd.txt /usr/local/sbin/usbcrypthd
Make the script executable only by the root
user:
sudo chmod 700 /usr/local/sbin/usbcrypthd
Note: if you use different device names or a different location for the key file, then you need to adapt this script.
Setup init script
Install sysv-rc-conf
, a terminal-based tool for managing the init scripts:
sudo apt-get install sysv-rc-conf
Then, download the usbcrypthd_init script and copy it into /etc/init.d
:
sudo cp usbcrypthd_init.txt /etc/init.d/usbcrypthd
And set the correct permissions:
sudo chmod 755 /etc/init.d/usbcrypthd
Fire up sysv-rc-conf
:
sudo sysv-rc-conf
usbcrypthd
and enable it for run-leves 2, 3 and 5. Exit the tool by pressing “q”.
You can now mount the EHD and USB stick as follows:
sudo /etc/init.d/usbcrypthd start
and unmount it like this:
sudo /etc/init.d/usbcrypthd stop
As a final test, reboot your machine. The USB stick and the EHD should be already mounted when you log into your X session (or terminal).
That’s it, folks! 🙂