Hi, when using zfs in combination with systemd, users run into the following problem:
- zfs manages mountpoints on its own and systemd is not aware of those. - this leads to problems, when mountpoints for other filesystems are mounted on directories in a zfs dataset or files are created in a directory before zfs could mount its dataset there. - the default behaviour in zfs case is to refuse to mount a filesystem on top of a non-empty directory. In case zfs is loaded via initrd (to allow to use zfs as bootfs) during early boot, writing a generator should be easy: ``` $ zfs get all -H | grep mountpoint zroot/home mountpoint /home local zroot/journal mountpoint /var/lib/journal local zroot/postgres mountpoint /var/lib/postgres local zroot/root mountpoint / local zroot/root/nix mountpoint /nix local zroot/root/tmp mountpoint /tmp local ``` It should be also noted that those filesystems will be not mounted using mount(2), but the command interface `zfs mount` except mountpoint is set the `legacy` However currently some zfs services exists which import zfs pools after the generator run: ```/usr/lib/systemd/system/zfs-import-scan.service [Unit] Description=Import ZFS pools by device scanning DefaultDependencies=no Requires=systemd-udev-settle.service After=systemd-udev-settle.service After=cryptsetup.target Before=dracut-mount.service ConditionPathExists=!/etc/zfs/zpool.cache [Service] Type=oneshot RemainAfterExit=yes ExecStartPre=/sbin/modprobe zfs ExecStart=/usr/bin/zpool import -aN -o cachefile=none [Install] WantedBy=zfs-mount.service WantedBy=zfs.target ``` ```/usr/lib/systemd/system/zfs-mount.service [Unit] Description=Mount ZFS filesystems DefaultDependencies=no After=systemd-udev-settle.service After=zfs-import-cache.service After=zfs-import-scan.service After=systemd-remount-fs.service Before=local-fs.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/zfs mount -a [Install] WantedBy=zfs-share.service WantedBy=zfs.target ``` As generators will run before unit I run into a Chicken or the egg problem. I would appreciate, if you have suggestions how to make this scheme compatible with the way systemd handle mounts. Thanks Jörg Thalheim.
pgpxt6SYytffZ.pgp
Description: OpenPGP digital signature
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel