Hi,
I have the following setup - a workstation with 2 SSDs on RAID1 (boot/root/home) and 2 HDDs also on RAID1 (slow but huge data hoarding).
The home directory is on a separate encrypted partition, the same goes for the slow HDD data.
So I have /dev/md/Home for the home partition and /dev/md/Data for the slow HDD data (movies etc).
I have created an entry in /etc/pam.d/sddm to execute two scripts to decrypt these on login:
auth optional pam_exec.so expose_authtok /etc/pam_cryptsetup1.sh
auth optional pam_exec.so expose_authtok /etc/pam_cryptsetup2.sh
The scripts:
/etc/pam_cryptsetup1.sh:
#!/usr/bin/env bash
if "$PAM_USER" == "MyUserName" && ! -e "/dev/mapper/cr_home" ]]; then
/usr/sbin/cryptsetup open "/dev/md/Home" "cr_home"
fi
/etc/pam_cryptsetup2.sh:
#!/usr/bin/env bash
if "$PAM_USER" == "[FONT=monospace]MyUserName" && ! -e "/dev/mapper/cr_opt" ]]; then [/FONT]
/usr/sbin/cryptsetup open "/dev/md/Data" "cr_opt"
fi
This succesfully decrypts these on user login, can confirm with:
WorkStation**:~ #** dmsetup ls --target crypt
cr_home (254, 0)
cr_opt (254, 1)
After that, I create a systemd.mount file in /etc/systemd/system/home-[FONT=monospace]MyUserName.mount[/FONT]:
[Unit]
Requires=user@1000.service
Before=user@1000.service
[Mount]
Where=/home/[FONT=monospace][FONT=monospace]MyUserName[/FONT]
What=/dev/mapper/cr_home
Type=ext4
Options=rw,relatime,data=ordered
[Install]
RequiredBy=user@1000.service
[/FONT]
This works perfectly and my home directory is mounted after the encrypted partition is opened!
The second (movies etc) partition however, is not.
/etc/systemd/system/home-[FONT=monospace]MyUserName-Videos.mount:[/FONT]
Unit]
Requires=user@1000.service
Before=user@1000.service
[Mount]
Where=/home/[FONT=monospace][FONT=monospace][FONT=monospace]MyUserName[/FONT][/FONT]/Videos
What=/dev/mapper/cr_opt
Type=ext4
Options=rw,relatime,data=ordered
[Install]
RequiredBy=user@1000.service
[/FONT]
The /home/MyUserName/Videos exists and belongs to the user. In fact, whatever the mount point, it never gets mounted - it’s as if the second .mount file is never read by systemd.
If I delete the first .mount file (the Home one) and only leave the Videos mount, it gets mounted.
I don’t see any errors in journalctl -f or when the user logs in.
I’m very new to systemd, so please feel free to scold me.
Thank you!