From e9affb4274a4d72d6aa1fde9d34862dfd93173cc Mon Sep 17 00:00:00 2001 From: "Ricardo M. Correia" Date: Thu, 23 Oct 2014 04:59:06 +0200 Subject: nixos: Add system-wide option to set the hostid The old boot.spl.hostid option was not working correctly due to an upstream bug. Instead, now we will create the /etc/hostid file so that all applications (including the ZFS kernel modules, ZFS user-space applications and other unrelated programs) pick-up the same system-wide host id. Note that glibc (and by extension, the `hostid` program) also respect the host id configured in /etc/hostid, if it exists. The hostid option is now mandatory when using ZFS because otherwise, ZFS will require you to force-import your ZFS pools if you want to use them, which is undesirable because it disables some of the checks that ZFS does to make sure it is safe to import a ZFS pool. The /etc/hostid file must also exist when booting the initrd, before the SPL kernel module is loaded, so that ZFS picks up the hostid correctly. The complexity in creating the /etc/hostid file is due to having to write the host ID as a 32-bit binary value, taking into account the endianness of the machine, while using only shell commands and/or simple utilities (to avoid exploding the size of the initrd). --- nixos/modules/system/boot/stage-1-init.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'nixos/modules/system/boot/stage-1-init.sh') diff --git a/nixos/modules/system/boot/stage-1-init.sh b/nixos/modules/system/boot/stage-1-init.sh index 5a9beeeafa1d..7ecc95aa079c 100644 --- a/nixos/modules/system/boot/stage-1-init.sh +++ b/nixos/modules/system/boot/stage-1-init.sh @@ -122,6 +122,9 @@ for o in $(cat /proc/cmdline); do esac done +# Set hostid before modules are loaded. +# This is needed by the spl/zfs modules. +@setHostId@ # Load the required kernel modules. mkdir -p /lib -- cgit 1.4.1