From d6df27277b97ba6700f6774cdc66fc038e158c56 Mon Sep 17 00:00:00 2001 From: Evgeny Egorochkin Date: Sun, 5 May 2013 16:31:10 +0300 Subject: [PATCH] ZFS: automatically import zpools and mount zfs filesystems. Patch contributed by Jack Cummings. --- modules/tasks/filesystems/zfs.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/tasks/filesystems/zfs.nix b/modules/tasks/filesystems/zfs.nix index 44c265b20d2..b76c50f420f 100644 --- a/modules/tasks/filesystems/zfs.nix +++ b/modules/tasks/filesystems/zfs.nix @@ -63,6 +63,28 @@ in ''; }; + systemd.services."zpool-import" = { + description = "Import zpools"; + after = [ "systemd-udev-settle.service" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = "${kernel.zfs}/sbin/zpool import -f -a -d /dev"; + }; + }; + + systemd.services."zfs-mount" = { + description = "Mount zfs volumes"; + after = [ "zpool-import.service" ]; + wantedBy = [ "local-fs.target" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = "${kernel.zfs}/sbin/zfs mount -a"; + ExecStop = "${kernel.zfs}/sbin/zfs umount -a"; + }; + }; + system.fsPackages = [ kernel.zfs ]; # XXX: needed? zfs doesn't have a fsck environment.systemPackages = [ kernel.zfs ]; services.udev.packages = [ kernel.zfs ]; # to hook zvol naming, etc.