I am running KDE desktop and have a separate hard drive set up for my data files.
I set up the drive using Yast as an encrypted drive on sdb1 with an XFS partition with the label ‘old_data’ which mounts on /run/media/alastair/old_data but is set not to mount on boot.
My problem is that once I have mounted the drive it remains mounted and open even if I have logged out and in again.
What I want is to be able to have the drive umounted when I log out and require me, once I have logged in, to always have to enter my encryption key. I expect the root pw will be required also but it is the encryption that is important.
Tried to set up a service to umount and mount but I cannot get even this to work and am still not sure it will do what I want. Here is my umount service file:-
[Unit] Description=Unmount /run/media/alastair/old_data on user logout [Service] Type=oneshot ExecStart=/bin/true ExecStop=/bin/umount /run/media/alastair/old_data [Install] WantedBy=default.target
I enabled without any error but then when I try and start I get:-
alastair@HP-Z640-1:~> sudo systemctl enable old_data-umount.service alastair@HP-Z640-1:~> sudo systemctl start old_data-umount.service Job for old_data-umount.service failed because the control process exited with error code. See "systemctl status old_data-umount.service" and "journalctl -xeu old_data-umount.service" for details. alastair@HP-Z640-1:~>
Following the advice given here is the first result;-
alastair@HP-Z640-1:~> systemctl status old_data-umount.service × old_data-umount.service - Unmount /run/media/alastair/old_data on user logout Loaded: loaded (/etc/systemd/system/old_data-umount.service; enabled; preset: disabled) Active: failed (Result: exit-code) since Wed 2023-09-06 14:25:53 BST; 1min 59s ago Process: 21527 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Process: 21528 ExecStop=/bin/umount /run/media/alastair/old_data (code=exited, status=32) Main PID: 21527 (code=exited, status=0/SUCCESS) CPU: 7ms alastair@HP-Z640-1:~>
and I get no messages from the journalctl command above
For the mount service I have:-
[Unit] Description=Mount /run/media/alastair/old_drive on user login [Service] Type=oneshot ExecStart=/bin/mount /run/media/alastair/old_drive [Install] WantedBy=default.target
And the result:-
alastair@HP-Z640-1:~> systemctl --user status old_data-mount.service × old_data-mount.service - Mount /run/media/alastair/old_data Drive on user login Loaded: loaded (/home/alastair/.config/systemd/user/old_data-mount.service; enabled; preset: disabled) Active: failed (Result: exit-code) since Wed 2023-09-06 14:43:12 BST; 43s ago Process: 21993 ExecStart=/bin/mount /run/media/alastair/old_data (code=exited, status=1/FAILURE) Main PID: 21993 (code=exited, status=1/FAILURE) CPU: 5ms Sep 06 14:43:12 HP-Z640-1 systemd: Starting Mount /run/media/alastair/old_data Drive on user login... Sep 06 14:43:12 HP-Z640-1 mount: mount: /run/media/alastair/old_data: can't find in /etc/fstab. Sep 06 14:43:12 HP-Z640-1 systemd: old_data-mount.service: Main process exited, code=exited, status=1/FAILURE Sep 06 14:43:12 HP-Z640-1 systemd: old_data-mount.service: Failed with result 'exit-code'. Sep 06 14:43:12 HP-Z640-1 systemd: Failed to start Mount /run/media/alastair/old_data Drive on user login. alastair@HP-Z640-1:~>
Where am I going wrong and if it can be made to work, is it what I need?