← Back to Pull requests

nixos/zfs: improve forceImportRoot docs #590151

Merged
nh2 merged 1 files (21 lines) on Nov 26, 2026 14:39 UTC
View on GitHub
nh2 nh2 commented on Nov 18, 2026 23:27 UTC
Author

Fixes:

  • https://github.com/NixOS/nixpkgs/pull/495581#pullrequestreview-5963341796
  • FYI @ThinkChaos

    Things done

    <!--
    Please check what applies. Note that these are not hard requirements but merely serve as information for reviewers.

    Entries that cannot apply to your change may be left unchecked or removed if your summary reads better without them, for example NixOS tests when the change does not touch NixOS.
    You are welcome and encouraged to add new entries if they are relevant to your change, e.g. stdenv or specific subsystems testing instructions.
    Please keep the section headings and do not remove the template as a whole, even when nothing is checked.
    -->

  • Fits [CONTRIBUTING.md], [pkgs/README.md], [maintainers/README.md] and other READMEs.

  • Follows the [automation/AI policy].

  • Built on platform:

  • - [x] x86_64-linux
    - [ ] aarch64-linux
    - [ ] aarch64-darwin
  • Tested, as applicable:

  • - [ ] Basic functionality of all binary files, usually in ./result/bin/.
    - [ ] Ran nixpkgs-review on this PR. See [nixpkgs-review usage].
    - [ ] [Package tests] at passthru.tests.
    - [ ] [NixOS tests] in [nixos/tests].
    - [ ] Tests in [lib/tests] or [pkgs/test] for functions and "core" functionality.
  • [Nixpkgs Release Notes]

  • - [ ] Package update: when the change is major or breaking.
  • [NixOS Release Notes]

  • - [ ] Module addition: when adding a new NixOS module.
    - [ ] Module update: when the change is significant.

    Diff: 21 lines (+16 / -5) across 1 files Reviewer: ThinkChaos Review duration: 10991m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.21) × (1 − Review Confidence (0.77)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.21 · 21 lines diff across 1 files
    0.21
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.54 · 5 substantive comment(s)
    0.54
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    76%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.185
    Real PR Conversation Timeline
    21 items
    ThinkChaos ThinkChaos commented on code on Nov 19, 2026 00:03 UTC
    Code Review
    nixos/modules/tasks/filesystems/zfs.nix:1
    @@ -359,13 +359,39 @@ in
             description = ''
               Forcibly import the ZFS root pool(s) during early boot.
     
    -          It is highly recommended to keep this option disabled as it bypasses ZFS
    -          safeguard that protect your pools.
    +          ZFS has a feature to protect users from accidentally mounting the same file system
    +          on multiple machines simultaneously (which leads to pool corruption).
    +
    +          This can usually only happen through
    +
    +          * hibernation, and then booting another OS that wants to use the same file system
    +          * shared VM images or shared network-attached drives
    +
    +          ZFS implements that protection by refusing to `zpool import` when the
    +          pool wasn't `zpool export`ed before, and was last imported under a different
    +          `hostid` (see {option}`networking.hostId`)
    +          ("previously in use from another system" error message).
    +          A force import (`zpool import -f`) disables that protection;
    +          this option controls that.
    +
    +          You should only need a force import if the pool was last imported
    +          by another system (e.g. a live ISO, or plugged into a different computer)
    +          without being `zpool export`ed from it.
    +
    +          Thus it is recommended to keep this option disabled, keeping the protection.
    +
    +          However, on machines where the mentioned situations are unlikely,
    +          you may enable this option to avoid failing boots after having used
    +          the pool on another machine and forgotten `zpool export`, such as
    +          on headless servers whose boot you may sometimes need to fix by
    +          mounting their root filesystems on another server.
     

    I don't think we should have any text recommending using this

    ThinkChaos ThinkChaos commented on Nov 19, 2026 00:09 UTC
    Reviewer

    Thanks for following up!

    I didn't understand you'd include the full comment, and I think this is a bit long and buries the lede.
    Here's what I had come up with in parallel:

    Forcibly import the ZFS root pool(s) during early boot (zpool import -f).

    > It is highly recommended to keep this option disabled as it bypasses ZFS safeguards.

    > Instead of enabling this option, if NixOS fails to boot because a pool was "previously in use

    from another system", you can boot once with the zfs_force=1 kernel parameter

    (e.g. added interactively in your bootloader menu).

    You should only need to use zfs_force=1 if the pool was last imported by a different host (see {option}networking.hostId).

    This can happen after using the pool from a different host (e.g. a live ISO) and forgetting to export it (see {manpage}zfs-export(1)).

    ---

    I think improving the docs is good. Additionally, I'm in favor of fully removing this in the next NixOS cycle as I can't come up with any use case for having this enabled all the time.
    The only close to be use-case is sharing a pool, which you'd better be served by always exporting on shutdown, to keep this safety mechanism functional.

    nh2 nh2 commented on code on Nov 19, 2026 00:45 UTC
    Code Review
    nixos/modules/tasks/filesystems/zfs.nix:1
    @@ -359,13 +359,39 @@ in
             description = ''
               Forcibly import the ZFS root pool(s) during early boot.
     
    -          It is highly recommended to keep this option disabled as it bypasses ZFS
    -          safeguard that protect your pools.
    +          ZFS has a feature to protect users from accidentally mounting the same file system
    +          on multiple machines simultaneously (which leads to pool corruption).
    +
    +          This can usually only happen through
    +
    +          * hibernation, and then booting another OS that wants to use the same file system
    +          * shared VM images or shared network-attached drives
    +
    +          ZFS implements that protection by refusing to `zpool import` when the
    +          pool wasn't `zpool export`ed before, and was last imported under a different
    +          `hostid` (see {option}`networking.hostId`)
    +          ("previously in use from another system" error message).
    +          A force import (`zpool import -f`) disables that protection;
    +          this option controls that.
    +
    +          You should only need a force import if the pool was last imported
    +          by another system (e.g. a live ISO, or plugged into a different computer)
    +          without being `zpool export`ed from it.
    +
    +          Thus it is recommended to keep this option disabled, keeping the protection.
    +
    +          However, on machines where the mentioned situations are unlikely,
    +          you may enable this option to avoid failing boots after having used
    +          the pool on another machine and forgotten `zpool export`, such as
    +          on headless servers whose boot you may sometimes need to fix by
    +          mounting their root filesystems on another server.
     

    @ThinkChaos I am definitely not in favour of removing this option, because while learning more about this, I concluded that I actually want to have this option on at all times on my servers.

    The situation ZFS protect against here is extremely unlikely, especially on servers, and the situation that will be broken by it is very likley (every time some NixOS upgrade messes up and breaks booting, I have to shut down the AWS machine, attach the disk volume to another running disk, mount it, fix its contents, and reattach to the original machine), so I figured there will actually be a group of users for which this option being true is the most sensible setup.

    ThinkChaos ThinkChaos commented on code on Nov 19, 2026 01:41 UTC
    Code Review
    nixos/modules/tasks/filesystems/zfs.nix:1
    @@ -359,13 +359,39 @@ in
             description = ''
               Forcibly import the ZFS root pool(s) during early boot.
     
    -          It is highly recommended to keep this option disabled as it bypasses ZFS
    -          safeguard that protect your pools.
    +          ZFS has a feature to protect users from accidentally mounting the same file system
    +          on multiple machines simultaneously (which leads to pool corruption).
    +
    +          This can usually only happen through
    +
    +          * hibernation, and then booting another OS that wants to use the same file system
    +          * shared VM images or shared network-attached drives
    +
    +          ZFS implements that protection by refusing to `zpool import` when the
    +          pool wasn't `zpool export`ed before, and was last imported under a different
    +          `hostid` (see {option}`networking.hostId`)
    +          ("previously in use from another system" error message).
    +          A force import (`zpool import -f`) disables that protection;
    +          this option controls that.
    +
    +          You should only need a force import if the pool was last imported
    +          by another system (e.g. a live ISO, or plugged into a different computer)
    +          without being `zpool export`ed from it.
    +
    +          Thus it is recommended to keep this option disabled, keeping the protection.
    +
    +          However, on machines where the mentioned situations are unlikely,
    +          you may enable this option to avoid failing boots after having used
    +          the pool on another machine and forgotten `zpool export`, such as
    +          on headless servers whose boot you may sometimes need to fix by
    +          mounting their root filesystems on another server.
     

    That situation you're mentioning should happen rarely, and if it does running zfs export is easy. Then reboot without -f will just work<sup>TM</sup>.
    To make that even less of an issue, I think the live ISO should auto zpool export -a as was discussed previously.

    Agreeing on how to use -f doesn't matter for this specific change, you do you, but I do think it matters we don't recommend anything potentially unsafe. IMO, if a user wants to make that decision they should understand the ins and outs, and not do it because the docs said so.

    amarshall amarshall commented on code on Nov 19, 2026 03:20 UTC
    Code Review
    nixos/modules/tasks/filesystems/zfs.nix:1
    @@ -359,13 +359,39 @@ in
             description = ''
               Forcibly import the ZFS root pool(s) during early boot.
     
    -          It is highly recommended to keep this option disabled as it bypasses ZFS
    -          safeguard that protect your pools.
    +          ZFS has a feature to protect users from accidentally mounting the same file system
    +          on multiple machines simultaneously (which leads to pool corruption).
    +
    +          This can usually only happen through
    +
    +          * hibernation, and then booting another OS that wants to use the same file system
    +          * shared VM images or shared network-attached drives
    +
    +          ZFS implements that protection by refusing to `zpool import` when the
    +          pool wasn't `zpool export`ed before, and was last imported under a different
    +          `hostid` (see {option}`networking.hostId`)
    +          ("previously in use from another system" error message).
    +          A force import (`zpool import -f`) disables that protection;
    +          this option controls that.
    +
    +          You should only need a force import if the pool was last imported
    +          by another system (e.g. a live ISO, or plugged into a different computer)
    +          without being `zpool export`ed from it.
    +
    +          Thus it is recommended to keep this option disabled, keeping the protection.
    +
    +          However, on machines where the mentioned situations are unlikely,
    +          you may enable this option to avoid failing boots after having used
    +          the pool on another machine and forgotten `zpool export`, such as
    +          on headless servers whose boot you may sometimes need to fix by
    +          mounting their root filesystems on another server.
     

    We should not give a recommendation contrary to upstream, as the default is not -f upstream, and afaik neither upstream’s docs nor any other distro’s docs recommend it as the default. If it should be recommended in some cases, IMO that should go in upstream’s docs or perhaps the wiki.

    amarshall amarshall requested changes on Nov 19, 2026 03:28 UTC
    Changes Requested Reviewer

    This makes the option docs far too verbose. Almost no one should really be enabling this option, instead they should be (as already in the doc) using zfs_force=1 to temporarily enable it on an as-needed basis.

    And really we should fix (at least) the installer to export the pool on shutdown to avoid the most common innocuous case.

    ---

    The main issue with the existing doc is that “You should only need to do this after unclean shutdowns.” is incorrect, and we should just fix that, and ThinkChaos’s comment does that and clarifies the situation that causes this. Perhaps a reference that it is the equivalent of zpool import -f and to see man zpool-import would be helpful to defer to upstream’s docs a bit.

    nh2 nh2 commented on Nov 19, 2026 04:18 UTC
    Author

    This makes the option docs far too verbose.

    The point is to describe what the NixOS option does. It took me half an hour to really figure out what it does and what ZFS's idea is here; I shouldn't have to, and writing a couple sentences will save many other people this time. The wiki is not the place to document NixOS options; it inevitably gets out of date, which is why option descriptions are better.

    Saying "it passes -f" is clearly not enough, as the zpool-import man page only describes what it does, not in which situation one would need it.

    If there's a clear upstream explanation that explains the same thing, we can refer to that instead (please post a link).

    Almost no one should really be enabling this option, instead they should be (as already in the doc) using zfs_force=1 to temporarily enable it on an as-needed basis.

    There are people with swathes of servers for whom the declarative point of NixOS is that they do not need to press buttons on as-needed basis. Other file systems don't require you to do this extra dance on shutdown, so it makes sense that NixOS allows to declare it away.

    ---

    Anyway, I have removed the block about in which situations one might want to use this (even though I think people would be abel to make better decisions with it).

    nh2 nh2 commented on code on Nov 19, 2026 04:18 UTC
    Code Review
    nixos/modules/tasks/filesystems/zfs.nix:1
    @@ -359,13 +359,39 @@ in
             description = ''
               Forcibly import the ZFS root pool(s) during early boot.
     
    -          It is highly recommended to keep this option disabled as it bypasses ZFS
    -          safeguard that protect your pools.
    +          ZFS has a feature to protect users from accidentally mounting the same file system
    +          on multiple machines simultaneously (which leads to pool corruption).
    +
    +          This can usually only happen through
    +
    +          * hibernation, and then booting another OS that wants to use the same file system
    +          * shared VM images or shared network-attached drives
    +
    +          ZFS implements that protection by refusing to `zpool import` when the
    +          pool wasn't `zpool export`ed before, and was last imported under a different
    +          `hostid` (see {option}`networking.hostId`)
    +          ("previously in use from another system" error message).
    +          A force import (`zpool import -f`) disables that protection;
    +          this option controls that.
    +
    +          You should only need a force import if the pool was last imported
    +          by another system (e.g. a live ISO, or plugged into a different computer)
    +          without being `zpool export`ed from it.
    +
    +          Thus it is recommended to keep this option disabled, keeping the protection.
    +
    +          However, on machines where the mentioned situations are unlikely,
    +          you may enable this option to avoid failing boots after having used
    +          the pool on another machine and forgotten `zpool export`, such as
    +          on headless servers whose boot you may sometimes need to fix by
    +          mounting their root filesystems on another server.
     

    I removed this part.

    adamcstephens adamcstephens commented on Nov 19, 2026 04:44 UTC
    Contributor

    How about something like this. I think there's still a bit too much narration.

    Forcibly import the ZFS root pool(s) during early boot.
    
    ZFS pools are tied to a single hostid. This means that moving
    ZFS pools between systems or hostid without first running `zfs export`
    will require manual intervention in order for import to succeed.
    
    This NixOS-only option overrides that default ZFS behavior by forcibly 
    importing any ZFS root pools on every boot. 
    
    Preferably, setting {option}`networking.hostId` instead of enabling
    this option will provide a NixOS managed persistent hostid.
    
    Recovery from boot failures when this is disabled can be achieved by
    adding `zfs_force=1` to kernel parameters in your bootloader for a single boot.
    

    I feel it's premature to discuss removing this, and would probably not support doing so even though I wouldn't use it. We haven't even shipped the default change in a stable release yet.

    amarshall amarshall commented on Nov 19, 2026 04:53 UTC
    Contributor

    I opened https://github.com/NixOS/nixpkgs/pull/590221 to add an option to export on shutdown and enable it in the installer by default. I think this should resolve the main use case for force import (forgetting to zpool export after a new installation) and give opt-in to always export, which is better than forced import. It doesn’t obviate the need for force import entirely, but probably by default it does.

    (I also did minimal reword of these docs there…but see comment on that PR)

    nh2 nh2 commented on Nov 19, 2026 05:12 UTC
    Author

    This NixOS-only option

    @adamcstephens what's a non-NixOS-only option? We're in a NixOS option description here.

    I think there's still a bit too much narration.

    I think it should definitely say

              ZFS has a feature to protect users from accidentally mounting the same file system
              on multiple machines simultaneously (which leads to pool corruption).
    
              This can usually only happen through
    
              * hibernation, and then booting another OS that wants to use the same file system
              * shared VM images or shared network-attached drives
    

    as that was the main point from https://github.com/NixOS/nixpkgs/pull/495581#pullrequestreview-5963341796. The first thing any user will think when reading "ZFS pools are tied to a single hostid" is "... OK, why? My other FS don't need this." We should make clear that this is some ZFS extra protection against a specific type of mistake, and when that mistake can happen.

    Rest looks also OK to me.

    adamcstephens adamcstephens commented on Nov 19, 2026 14:23 UTC
    Contributor

    @adamcstephens what's a non-NixOS-only option? We're in a NixOS option description here.

    I'm well aware. My point here was to call out this is a behavior that diverges from upstream and every other distro. I don't feel strongly about this.

    I think it should definitely say

    I don't think we should explain and try to enumerate the upstream why behind this. Options don't need to explain all of upstream's reasoning behind their decisions. How about skipping this entire why and linking this instead. https://openzfs.github.io/openzfs-docs/Basic%20Concepts/Operations/Boot%20Process.html

    "... OK, why? My other FS don't need this."

    ZFS isn't another FS and I don't agree it's the job of a NixOS option description to describe why and in what scenarios upstream was designing for. It's not necessary to explain to users why nginx and traefik configs are different and the same should hold for ZFS and ext4.

    We don't have official documentation for how to set up a root filesystem with ZFS so I think it's fair to put responsibility on users for learning and understanding of ZFS behaviors outside of the option description. The two locations I found (upstream and our wiki) both document using networking.hostId which avoids users even looking at this option (and is required by this assertion).

    nh2 nh2 commented on Nov 19, 2026 17:24 UTC
    Author
    nh2 nh2 commented on Nov 26, 2026 03:25 UTC
    Author

    @amarshall @adamcstephens @ThinkChaos Please take another look at my admendments

    SuperSandro2000 SuperSandro2000 commented on code on Nov 26, 2026 13:12 UTC
    Code Review
    nixos/modules/tasks/filesystems/zfs.nix:1
    @@ -359,13 +359,24 @@ in
             description = ''
               Forcibly import the ZFS root pool(s) during early boot.
     
    -          It is highly recommended to keep this option disabled as it bypasses ZFS
    -          safeguard that protect your pools.
    +          ZFS has a feature to protect users from accidentally mounting the same file system
    +          on multiple machines simultaneously (which leads to pool corruption).
    +          This option disables that by passing `-f` to `zpool import` on boot, see
    +          https://openzfs.github.io/openzfs-docs/Basic%20Concepts/Operations/Boot%20Process.html#hostid-and-importing-on-the-wrong-machine
    +
    +          You should only need a force import if the pool was last imported
    +          by another system (e.g. a live ISO, or plugged into a different computer)
    +          without being `zpool export`ed from it.
    +
    +          Thus it is recommended to keep this option disabled, keeping the protection.

    I would vouche against keeping this option disabled with the current form of things.
    No one I know does zpool export by hand after debugging a boot failure or something else in a live ISO and afterwards the machine silently no longer boots. Nothing in console hints at this and after debugging for an hour and getting helpful hints like install Debian, eventually someone thinks about this.

    If this should be kept, then we should definitely prominently document to always do ZFS export in an ISO and definitely add a shutdown unit that does that automatically, because why would you want to do an unlcean shutdown?

    Also why is this import failure silent in the console? Can't we print an informative message when the pool failed to import because of that?

    SuperSandro2000 SuperSandro2000 commented on code on Nov 26, 2026 13:13 UTC
    Code Review
    nixos/modules/tasks/filesystems/zfs.nix:1
    @@ -359,13 +359,24 @@ in
             description = ''
               Forcibly import the ZFS root pool(s) during early boot.
     
    -          It is highly recommended to keep this option disabled as it bypasses ZFS
    -          safeguard that protect your pools.
    +          ZFS has a feature to protect users from accidentally mounting the same file system
    +          on multiple machines simultaneously (which leads to pool corruption).
    +          This option disables that by passing `-f` to `zpool import` on boot, see
    +          https://openzfs.github.io/openzfs-docs/Basic%20Concepts/Operations/Boot%20Process.html#hostid-and-importing-on-the-wrong-machine
    +
    +          You should only need a force import if the pool was last imported
    +          by another system (e.g. a live ISO, or plugged into a different computer)
    +          without being `zpool export`ed from it.
    +
    +          Thus it is recommended to keep this option disabled, keeping the protection.
     
    -          If NixOS fails to boot because it cannot import the root pool, you should boot
    +          If NixOS fails to boot because the root pool cannot be imported
    +          (with this option disabled), you should boot
               with the `zfs_force=1` option as a kernel parameter (e.g. by manually
    -          editing the kernel params via your bootloader).
    -          You should only need to do this after unclean shutdowns.
    +          editing the kernel params via your bootloader) to disable
    +          the protection just for that boot. Upon success, the pool will record this
    +          machine's `hostid` (see {option}`networking.hostId`),
    +          so subsequent boots work without `zfs_force=1` again.

    This conflicts with the security recommendation to disable editing boot parameters 😅

    nh2 nh2 commented on code on Nov 26, 2026 13:53 UTC
    Code Review
    nixos/modules/tasks/filesystems/zfs.nix:1
    @@ -359,13 +359,24 @@ in
             description = ''
               Forcibly import the ZFS root pool(s) during early boot.
     
    -          It is highly recommended to keep this option disabled as it bypasses ZFS
    -          safeguard that protect your pools.
    +          ZFS has a feature to protect users from accidentally mounting the same file system
    +          on multiple machines simultaneously (which leads to pool corruption).
    +          This option disables that by passing `-f` to `zpool import` on boot, see
    +          https://openzfs.github.io/openzfs-docs/Basic%20Concepts/Operations/Boot%20Process.html#hostid-and-importing-on-the-wrong-machine
    +
    +          You should only need a force import if the pool was last imported
    +          by another system (e.g. a live ISO, or plugged into a different computer)
    +          without being `zpool export`ed from it.
    +
    +          Thus it is recommended to keep this option disabled, keeping the protection.

    This is also my opinion (see https://github.com/NixOS/nixpkgs/pull/590151#discussion_r4622876067).

    @amarshall @adamcstephens @ThinkChaos Would you be OK with

    -Thus it is recommended to keep this option disabled, keeping the protection.
    +This option is controversial, see https://github.com/NixOS/nixpkgs/pull/590151?
    

    ?

    My main interest in this PR is to fix current wording which is just misleading.

    nh2 nh2 commented on code on Nov 26, 2026 14:05 UTC
    Code Review
    nixos/modules/tasks/filesystems/zfs.nix:1
    @@ -359,13 +359,24 @@ in
             description = ''
               Forcibly import the ZFS root pool(s) during early boot.
     
    -          It is highly recommended to keep this option disabled as it bypasses ZFS
    -          safeguard that protect your pools.
    +          ZFS has a feature to protect users from accidentally mounting the same file system
    +          on multiple machines simultaneously (which leads to pool corruption).
    +          This option disables that by passing `-f` to `zpool import` on boot, see
    +          https://openzfs.github.io/openzfs-docs/Basic%20Concepts/Operations/Boot%20Process.html#hostid-and-importing-on-the-wrong-machine
    +
    +          You should only need a force import if the pool was last imported
    +          by another system (e.g. a live ISO, or plugged into a different computer)
    +          without being `zpool export`ed from it.
    +
    +          Thus it is recommended to keep this option disabled, keeping the protection.
     
    -          If NixOS fails to boot because it cannot import the root pool, you should boot
    +          If NixOS fails to boot because the root pool cannot be imported
    +          (with this option disabled), you should boot
               with the `zfs_force=1` option as a kernel parameter (e.g. by manually
    -          editing the kernel params via your bootloader).
    -          You should only need to do this after unclean shutdowns.
    +          editing the kernel params via your bootloader) to disable
    +          the protection just for that boot. Upon success, the pool will record this
    +          machine's `hostid` (see {option}`networking.hostId`),
    +          so subsequent boots work without `zfs_force=1` again.

    @SuperSandro2000 Which ones, can you link?

    Also sounds a bit dubious to me whether such a disabling would really be effective vs people with physical access to a computer.

    adamcstephens adamcstephens commented on code on Nov 26, 2026 14:32 UTC
    Code Review
    nixos/modules/tasks/filesystems/zfs.nix:1
    @@ -359,13 +359,24 @@ in
             description = ''
               Forcibly import the ZFS root pool(s) during early boot.
     
    -          It is highly recommended to keep this option disabled as it bypasses ZFS
    -          safeguard that protect your pools.
    +          ZFS has a feature to protect users from accidentally mounting the same file system
    +          on multiple machines simultaneously (which leads to pool corruption).
    +          This option disables that by passing `-f` to `zpool import` on boot, see
    +          https://openzfs.github.io/openzfs-docs/Basic%20Concepts/Operations/Boot%20Process.html#hostid-and-importing-on-the-wrong-machine
    +
    +          You should only need a force import if the pool was last imported
    +          by another system (e.g. a live ISO, or plugged into a different computer)
    +          without being `zpool export`ed from it.
    +
    +          Thus it is recommended to keep this option disabled, keeping the protection.

    definitely prominently document to always do ZFS export in an ISO

    Export is documented in every install guide I reviewed recently. There is no official NixOS documentation on setting up zfs root so nothing to update.

    Regarding auto export, amarshall already has a PR for that.

    No, I don’t think it’s appropriate to call this controversial. I’m sorry if Sandro doesn’t like the way zfs works but I think following upstream and other distros is appropriate here.

    adamcstephens adamcstephens commented on code on Nov 26, 2026 14:35 UTC
    Code Review
    nixos/modules/tasks/filesystems/zfs.nix:1
    @@ -359,13 +359,24 @@ in
             description = ''
               Forcibly import the ZFS root pool(s) during early boot.
     
    -          It is highly recommended to keep this option disabled as it bypasses ZFS
    -          safeguard that protect your pools.
    +          ZFS has a feature to protect users from accidentally mounting the same file system
    +          on multiple machines simultaneously (which leads to pool corruption).
    +          This option disables that by passing `-f` to `zpool import` on boot, see
    +          https://openzfs.github.io/openzfs-docs/Basic%20Concepts/Operations/Boot%20Process.html#hostid-and-importing-on-the-wrong-machine
    +
    +          You should only need a force import if the pool was last imported
    +          by another system (e.g. a live ISO, or plugged into a different computer)
    +          without being `zpool export`ed from it.
    +
    +          Thus it is recommended to keep this option disabled, keeping the protection.
     
    -          If NixOS fails to boot because it cannot import the root pool, you should boot
    +          If NixOS fails to boot because the root pool cannot be imported
    +          (with this option disabled), you should boot
               with the `zfs_force=1` option as a kernel parameter (e.g. by manually
    -          editing the kernel params via your bootloader).
    -          You should only need to do this after unclean shutdowns.
    +          editing the kernel params via your bootloader) to disable
    +          the protection just for that boot. Upon success, the pool will record this
    +          machine's `hostid` (see {option}`networking.hostId`),
    +          so subsequent boots work without `zfs_force=1` again.

    If someone has locked their bootloader they hopefully know how to unlock it to change these. It’s not a default configuration either.

    Reviewers
    Assignees
    nh2 nh2
    Labels
    risk: low confidence: 76.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 21.5% (LOW) · Higher = larger blast radius
    21.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 76.7% · Lower = rushed or shallow review
    76.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 5% · Safe to merge
    5%
    Repository