Merge pull request #95751 from srhb/forceImportAll
nixos/zfs: Fix boot.zfs.forceImportAll
This commit is contained in:
commit
66c98ec550
@ -151,6 +151,15 @@
|
|||||||
<literal>vim</literal> switched to Python 3, dropping all Python 2 support.
|
<literal>vim</literal> switched to Python 3, dropping all Python 2 support.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<link linkend="opt-boot.zfs.forceImportAll">boot.zfs.forceImportAll</link>
|
||||||
|
previously did nothing, but has been fixed. However its default has been
|
||||||
|
changed to <literal>false</literal> to preserve the existing default
|
||||||
|
behaviour. If you have this explicitly set to <literal>true</literal>,
|
||||||
|
please note that your non-root pools will now be forcibly imported.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -175,14 +175,10 @@ in
|
|||||||
|
|
||||||
forceImportAll = mkOption {
|
forceImportAll = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Forcibly import all ZFS pool(s).
|
Forcibly import all ZFS pool(s).
|
||||||
|
|
||||||
This is enabled by default for backwards compatibility purposes, but it is highly
|
|
||||||
recommended to disable this option, as it bypasses some of the safeguards ZFS uses
|
|
||||||
to protect your ZFS pools.
|
|
||||||
|
|
||||||
If you set this option to <literal>false</literal> and NixOS subsequently fails to
|
If you set this option to <literal>false</literal> and NixOS subsequently fails to
|
||||||
import your non-root ZFS pool(s), you should manually import each pool with
|
import your non-root ZFS pool(s), you should manually import each pool with
|
||||||
"zpool import -f <pool-name>", and then reboot. You should only need to do
|
"zpool import -f <pool-name>", and then reboot. You should only need to do
|
||||||
@ -507,6 +503,7 @@ in
|
|||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
};
|
};
|
||||||
|
environment.ZFS_FORCE = optionalString cfgZfs.forceImportAll "-f";
|
||||||
script = (importLib {
|
script = (importLib {
|
||||||
# See comments at importLib definition.
|
# See comments at importLib definition.
|
||||||
zpoolCmd="${packages.zfsUser}/sbin/zpool";
|
zpoolCmd="${packages.zfsUser}/sbin/zpool";
|
||||||
|
@ -18,7 +18,7 @@ let
|
|||||||
maintainers = [ adisbladis ];
|
maintainers = [ adisbladis ];
|
||||||
};
|
};
|
||||||
|
|
||||||
machine = { pkgs, ... }: {
|
machine = { pkgs, lib, ... }: {
|
||||||
virtualisation.emptyDiskImages = [ 4096 ];
|
virtualisation.emptyDiskImages = [ 4096 ];
|
||||||
networking.hostId = "deadbeef";
|
networking.hostId = "deadbeef";
|
||||||
boot.kernelPackages = kernelPackage;
|
boot.kernelPackages = kernelPackage;
|
||||||
@ -26,6 +26,24 @@ let
|
|||||||
boot.zfs.enableUnstable = enableUnstable;
|
boot.zfs.enableUnstable = enableUnstable;
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.parted ];
|
environment.systemPackages = [ pkgs.parted ];
|
||||||
|
|
||||||
|
# Setup regular fileSystems machinery to ensure forceImportAll can be
|
||||||
|
# tested via the regular service units.
|
||||||
|
fileSystems = lib.mkVMOverride {
|
||||||
|
"/forcepool" = {
|
||||||
|
device = "forcepool";
|
||||||
|
fsType = "zfs";
|
||||||
|
options = [ "noauto" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# forcepool doesn't exist at first boot, and we need to manually test
|
||||||
|
# the import after tweaking the hostId.
|
||||||
|
systemd.services.zfs-import-forcepool.wantedBy = lib.mkVMOverride [];
|
||||||
|
systemd.targets.zfs.wantedBy = lib.mkVMOverride [];
|
||||||
|
boot.zfs.forceImportAll = true;
|
||||||
|
# /dev/disk/by-id doesn't get populated in the NixOS test framework
|
||||||
|
boot.zfs.devNodes = "/dev/disk/by-uuid";
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
@ -57,6 +75,21 @@ let
|
|||||||
"zpool destroy rpool",
|
"zpool destroy rpool",
|
||||||
"udevadm settle",
|
"udevadm settle",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
with subtest("boot.zfs.forceImportAll works"):
|
||||||
|
machine.succeed(
|
||||||
|
"rm /etc/hostid",
|
||||||
|
"zgenhostid deadcafe",
|
||||||
|
"zpool create forcepool /dev/vdb1 -O mountpoint=legacy",
|
||||||
|
)
|
||||||
|
machine.shutdown()
|
||||||
|
machine.start()
|
||||||
|
machine.succeed("udevadm settle")
|
||||||
|
machine.fail("zpool import forcepool")
|
||||||
|
machine.succeed(
|
||||||
|
"systemctl start zfs-import-forcepool.service",
|
||||||
|
"mount -t zfs forcepool /tmp/mnt",
|
||||||
|
)
|
||||||
'' + extraTest;
|
'' + extraTest;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user