Ubuntu - Auto-mount an encrypted drive
My new computer has a "small" SSD and a large HDD. Solid-State Drives are the popular choice for startup disks as they are blazing fast, while ordinary Hard-Disk Drives are excellent for long time storage.
[As an aside, don't ignore your backup strategy. I've written (and published) my own open-source backup utility.]
When I installed Ubuntu, I encrypted both drives, which is cool. However, when I started the computer for the first time, the HDD did not mount. Bummer.
I managed to semi-auto-mount the HDD with the Disks Utility (encryption options -> Unlock at system startup) and with Nautilus, but I still had to manually navigate to the HDD (in Nautilus) before I could work. Not good.
Recently, I solved this problem and I'm sharing the solution with you. It's not as hard as it seems.
First, you need some code to mount the HDD. This code will not work.
First, you need to create a mount point. Then you need to mount the HDD. Once you have the mount point created, you will not need to create it again.
This code will create the mount point:
This code will mount the HDD:
/dev/dm-3 is the HDD on my machine. You can find this info with the Disks Utility.
Second, you need to create a /etc/rc.local file with your favorite text editor.
The contents:
Third, you need to make this an executable file.
Fourth, you need to create a /etc/init.d/rc.local file.
The contents:
Fifth, make it an executable file.
... and that's it.
You can test the setup by using the following code:
This code didn't do anything for me, but after restarting the computer, the HDD did auto-mount.
[As an aside, don't ignore your backup strategy. I've written (and published) my own open-source backup utility.]
When I installed Ubuntu, I encrypted both drives, which is cool. However, when I started the computer for the first time, the HDD did not mount. Bummer.
I managed to semi-auto-mount the HDD with the Disks Utility (encryption options -> Unlock at system startup) and with Nautilus, but I still had to manually navigate to the HDD (in Nautilus) before I could work. Not good.
Recently, I solved this problem and I'm sharing the solution with you. It's not as hard as it seems.
First, you need some code to mount the HDD. This code will not work.
First, you need to create a mount point. Then you need to mount the HDD. Once you have the mount point created, you will not need to create it again.
This code will create the mount point:
> sudo mkdir /media/hans/HDD/
This code will mount the HDD:
> sudo mount /dev/dm-3 /media/hans/HDD/
/dev/dm-3 is the HDD on my machine. You can find this info with the Disks Utility.
Second, you need to create a /etc/rc.local file with your favorite text editor.
> sudo geany &
The contents:
#!/bin/sh -e
#mkdir /media/hans/HDD <<< this line is not needed
sudo mount /dev/dm-3 /media/hans/HDD
exit 0
Third, you need to make this an executable file.
> sudo chmod +x /etc/rc.local
Fourth, you need to create a /etc/init.d/rc.local file.
> sudo geany &
The contents:
#! /bin/sh
### BEGIN INIT INFORMATION
# Provides: rc.local
# Required-Start: $remote_fs $syslog $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO
Fifth, make it an executable file.
> sudo chmod +x /etc/init.d/rc.local
... and that's it.
You can test the setup by using the following code:
> service rc.local start
> sudo systemctl status rc-local.service
This code didn't do anything for me, but after restarting the computer, the HDD did auto-mount.
Comments
Post a Comment