How to auto mount luks encrypted partition?

How to auto mount luks encrypted partition?

Here’s how to set it up:

  1. Create a test luks image. Skip this section if you have a LUKS-encrypted partition or image already. Create a file called .priv in your home directory with size 1GB: truncate -s 1G ~/.priv.
  2. Install and set up pam-mount. Install the package: sudo apt install libpam-mount.
  3. Use for /home/USER.

How to auto mount encrypted drive ubuntu?

Part 2: Automatically mount the HDD on system start-up. Keep the “Disks” application open, and click on the cog. Click “Edit Encryption Options.” “Automatic Encryption Options” will be turned on, and the menu below greyed out.

Is there a way to mount an encrypted disk?

You can now check with lsblk to see the encrypted disk mounted: Try rebooting the system, and you’ll see the partition being mounted automatically. We’re done! However, keep in mind a few things: To mount and un-mount the encrypted disk you must use systemctl rather than the usual mount and umount commands.

How to unlock an encrypted drive in Linux?

Create a systemd unit for unlocking the encrypted device and save it as /etc/systemd/system/unlock-data.service. Make sure you replace the UUID in the command below! Note the StopWhenUnneeded=true line: this will make systemd stop the unit (including running the luksClose operation) automatically when the disk is unmounted.

How can I have the LUKS encryption key stored?

How could I have the LUKS encryption key stored in a secure, remote place, while at the same time being able to have the encrypted disk automatically mounted without manual intervention (e.g. in case of a reboot after a power outage)? In other words, how to have your cake and eat it too.

How to auto mount a disk in systemd?

Note the StopWhenUnneeded=true line: this will make systemd stop the unit (including running the luksClose operation) automatically when the disk is unmounted. Create another systemd unit with the mountpoint for /mnt/data, and save it as /etc/systemd/system/mnt-data.mount.