Skip to content

Commit

Permalink
systemd 254: ZFS /usr fix with systemd-stage-1
Browse files Browse the repository at this point in the history
  • Loading branch information
ElvishJerricco committed Oct 6, 2023
1 parent fdd898f commit 524714f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nixos/modules/tasks/filesystems/zfs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,17 @@ let

getPoolMounts = prefix: pool:
let
poolFSes = getPoolFilesystems pool;

# Remove the "/" suffix because even though most mountpoints
# won't have it, the "/" mountpoint will, and we can't have the
# trailing slash in "/sysroot/" in stage 1.
mountPoint = fs: escapeSystemdPath (prefix + (lib.removeSuffix "/" fs.mountPoint));

hasUsr = lib.any (fs: fs.mountPoint == "/usr") poolFSes;
in
map (x: "${mountPoint x}.mount") (getPoolFilesystems pool);
map (x: "${mountPoint x}.mount") poolFSes
++ lib.optional hasUsr "sysusr-usr.mount";

getKeyLocations = pool: if isBool cfgZfs.requestEncryptionCredentials then {
hasKeys = cfgZfs.requestEncryptionCredentials;
Expand Down
3 changes: 3 additions & 0 deletions nixos/tests/installer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,9 @@ in {
"zpool create rpool /dev/vda2",
"zfs create -o mountpoint=legacy rpool/root",
"mount -t zfs rpool/root /mnt",
"zfs create -o mountpoint=legacy rpool/root/usr",
"mkdir /mnt/usr",
"mount -t zfs rpool/root/usr /mnt/usr",
"udevadm settle",
)
'';
Expand Down

0 comments on commit 524714f

Please sign in to comment.