Disko and ZFS, emergency mode during boot

Greetings,

I’m fairly new to NixOS and I’m trying to setup a NAS for use at home. During the installation of a new server (NixoS 24.11) I used Disko to setup a ZFS pool, here is the relevant section:

zpool = {
  ironwolf = {
    type = "zpool";
    mode = {
      topology = {
        type = "topology";
        vdev = [{
          mode = "mirror";
          members = ["sda" "sdb"];
        }];
      };
    };
    mountpoint = "/mnt/ironwolf";
    datasets = {
      media = {
        type = "zfs_fs";
        #options.mountpoint = "legacy";
        mountpoint = "/mnt/ironwolf/media";
      };
      appdata = {
        type = "zfs_fs";
        #options.mountpoint = "legacy";
        mountpoint = "/mnt/ironwolf/appdata";
      };
    };
  };
};

When the server boots it successfully imports the pool, but fails to mount the datasets, here is the output:

[ OK ] Finished Import ZFS pool "ironwolf".
[ OK ] Reached target ZFS pool import target.
          Mounting /mnt/ironwolf...
          Starting Mount ZFS filesystems...
[FAILED] Failed to mount /mnt/ironwolf.
See 'systemctl status mnt-ironwolf.mount' for details.
[DEPEND] Dependency failed for Local File Systems.
[DEPEND] Dependency failed for /mnt/ironwolf/appdata
[DEPEND] Dependency failed for /mnt/ironwolf/media

Then it goes into emergency mode. If I press Ctrl-D to continue, the system boots successfully and my ZFS pool is online and healthy with all datasets mounted.

After reading some similar posts here, I’ve found both ZFS and Systemd are attempting to mount the datasets, but I don’t know which one is failing or how to tell it to use just one. As you can see from the Disko config I’ve tried using legacy mountpoints but this doesn’t seem to work. I’ve also tried adding boot.zfs.extraPools = [ "ironwolf" ]; to the main configuration at various points and there are no filesystems defined in the hardware configuration, but I always end up in emergency mode.

Any help here is much appreciated, thank you in advance :slight_smile:

I’ve managed to get the server to boot without going into emergency mode by telling systemd to not mount the zfs datasets. I added systemd.services.zfs-mount.enable = false; to my configuration and now it’s working.

Does anyone know if doing this is not recommended and if so, how do I get systemd to mount the datasets correctly?