Introduction
I used to encrypt the whole file system when I setup machines but this is a bit overkill for me, these days I just encrypt the home directory during setup and then encrypt any extra drives I have. On my main desktop I have three extra drives I call data1, data2 and data3, once I’ve logged in Ubuntu automatically mounts these drives for me by securely remembering the passwords. Here’s how to set it up.
Encrypting the drive
Ubuntu should could with everything you need already installed but if you need to you can install the cryptsetup package we’ll be using with the following terminal command:
sudo apt-get install cryptsetup
Now we can encrypt our drive with a single command, replace /dev/disk with your device name. Make sure the drive isn’t mounted before you run this command:
sudo cryptsetup luksFormat /dev/disk
This will prompt you to enter a password that will be needed to mount the encrypted drive. Make sure you record your password somewhere safe, Ubuntu will remember it for us but you’ll need it if you ever want to mount the drive manually or use if on a different machine.
Next, we mount the new encrypted drive for the first time, we’ll call it mydisk but you can call it anything:
sudo cryptsetup luksOpen /dev/disk mydisk
Now we’ll format the partition as ext3 with the label of mydisk:
sudo mkfs.ext3 /dev/mapper/mydisk -L mydisk
Reboot your machine, then if you open the file manager you should see your new encrypted volume under the device section:
If you click on the encrypted drive, you’ll be asked you enter the password to mount it, here you can tell the system to always remember your password for you automatically by selecting Remember Forever:
That’s it, you should be to access your new encrypted disk from within the file manager once you’ve logged in:
To automatically mount the drive after you login (without first having to click on it in the file manager) just add the following command as one of your startup application list:
gvfs-mount -d /dev/disk
Credit to How to Forge’s article on how to setup a luks volume properly.






