Systemd mount/umount encrypted to specific path

If none of the more specific forums is the right place to ask

Systemd mount/umount encrypted to specific path

Postby Crumbs516 » 2017-04-15 12:18

Switched to Jessie, which means systemd nonsense. What I am trying to do worked in wheezy just using /etc/fstab but under systemd rules everything is more convoluted (wish there were better examples). I am trying to set it up so encrypted drives that do not automount during boot mount to a specific path when the user requests, and unmount when they tell the drive to. I was able to remove the root password request with a udev rule. I am able to mount the drive via path.mount systemd config. Unfortunately this takes away the unmount GUI icon. How to get unmount to work?

What I did...
1. create systemd .mount file
Code: Select all
$ vim /etc/systemd/system/dataTBs.mount
   # unit to map UUID for encrypted drive to a static directory
   [Unit]
   Description=Mount Encrypted Drive Directory
   Conflicts=umount.target
   #Before=local-fs.target umount.target
   #Before=umount.target

   [Mount]
   What=/dev/disk/by-uuid/4faf1458-9217-40e3-83d1-4b7e35ba3145
   Where=/dataTBs
   Type=ext4
   Options=defaults,noauto,x-systemd.automount,x-systemd.device-timeout=3,x-systemd.mount-timeout=3,users,exec,nodev,nosuid,errors=remount-ro

   [Install]
   WantedBy=multi-user.target

$ systemctl enable /etc/systemd/system/dataTBs.mount


2. define udev rule to avoid root password request (this was blocking the .mount from running I think)
Code: Select all
   # ref: https://docs.fedoraproject.org/en-US/Fedora/18/html/Installation_Guide/apcs04s06.html
$ vim /etc/crypttab

   # to allow non-root users to mount encrypted partitions on a specific hard drive
   # pass output of following command to DEVPATH argument where sdb is the drive with the encrypted partition
   #   $ udevadm info -q path -n /dev/sdb
   #   /devices/pci0000:00/0000:00:08.1/ata4/host3/target3:0:0/3:0:0:0/block/sdb
   # reduce to host3/* means all devices on that sata port are mountable by non-root users

   DEVPATH=="/devices/pci0000:00/0000:00:08.1/ata4/host3/*", ENV{UDISKS_SYSTEM}="0"



I also found it interesting that unmounting the destination path as root meant that the next mount of the drive mapped to the standard /media/user/UUID not the systemd mount specified path.

Note I went this route because trying to specify /etc/fstab options made the system unusable (would not boot/login) even with options=noauto,x-systemd.automount,x-systemd.device-timeout=3,x-systemd.mount-timeout=3.

Any help is appreciated.
Crumbs516
 
Posts: 18
Joined: 2012-03-19 17:46

Return to General Questions

Who is online

Users browsing this forum: cybermcm and 10 guests

fashionable