NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.31k stars 13.54k forks source link

nixos/zfs: how to specify custom import procedure #278418

Open tyalie opened 8 months ago

tyalie commented 8 months ago

Describe the bug

When I tried to follow the "ZFS on Root for NixOS" guide I hit upon the curious problem of having two bpool and rpool pools on my computer as I'm already running a ZFSonRoot with Ubuntu and I was trying out something new on an external flash drive.

When doing so the system wouldn't boot as the zfs import statement would fail due to non-unique pool names. This can be fixed by either pinning the device or by using the pool ID (instead of the name).

Steps To Reproduce

Steps to reproduce the behavior:

  1. use two disks and create an rpool and/or bpool on each
  2. try to automatically mount one of them using the zfs driver

Expected behavior

I would expect to be able to specify more clearly which pool I meant using other ways than just the name or at least be able to overwrite the poolImport function / supply a custom set of imports.

Notify maintainers

@Luflosi @nikstur @pacien @JulienMalka @philiptaron

amarshall commented 7 months ago

While it should be possible to do this, why not just rename your pools to be unique (e.g. with unique host name or some random ID suffix)? That’s what I do, anyway, as it greatly reduces confusion and mistakes.

tyalie commented 6 months ago

Not sure. I think because I'm accustomed to the naming scheme that ZFS on root often comes with. I installed the other OS on an external drive and I could imagine that other people might run into similar issues if they tried to boot a drive they just took out of a (possibly) broken PC or so.

amarshall commented 6 months ago

As far as I can tell, boot.zfs.devNodes can be used to pin the device, but currently it will probably only work if the pool only has one device—I haven’t tested it.

tyalie commented 6 months ago

Hmh. I'm honestly not that interested rn to setup a new NixOS system for this purpose, as just changing the names worked for me in the end. But I hope that somebody else might find it useful that I reported it here.