summary refs log tree commit diff
path: root/nixos/modules/installer/cd-dvd
diff options
context:
space:
mode:
authorRicardo M. Correia <rcorreia@wizy.org>2014-10-23 04:59:06 +0200
committerRicardo M. Correia <rcorreia@wizy.org>2014-11-12 22:31:49 +0100
commite9affb4274a4d72d6aa1fde9d34862dfd93173cc (patch)
tree0b5be35e36c74321b6f7d9109f6e564973dcba31 /nixos/modules/installer/cd-dvd
parent12e77fdc3f6f223be1a4d5c88d6c79bff63ae70c (diff)
downloadnixlib-e9affb4274a4d72d6aa1fde9d34862dfd93173cc.tar
nixlib-e9affb4274a4d72d6aa1fde9d34862dfd93173cc.tar.gz
nixlib-e9affb4274a4d72d6aa1fde9d34862dfd93173cc.tar.bz2
nixlib-e9affb4274a4d72d6aa1fde9d34862dfd93173cc.tar.lz
nixlib-e9affb4274a4d72d6aa1fde9d34862dfd93173cc.tar.xz
nixlib-e9affb4274a4d72d6aa1fde9d34862dfd93173cc.tar.zst
nixlib-e9affb4274a4d72d6aa1fde9d34862dfd93173cc.zip
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).
Diffstat (limited to 'nixos/modules/installer/cd-dvd')
-rw-r--r--nixos/modules/installer/cd-dvd/installation-cd-base.nix3
1 files changed, 3 insertions, 0 deletions
diff --git a/nixos/modules/installer/cd-dvd/installation-cd-base.nix b/nixos/modules/installer/cd-dvd/installation-cd-base.nix
index 89d50b7460c9..e453a629f74f 100644
--- a/nixos/modules/installer/cd-dvd/installation-cd-base.nix
+++ b/nixos/modules/installer/cd-dvd/installation-cd-base.nix
@@ -45,6 +45,9 @@ with lib;
   # Add support for cow filesystems and their utilities
   boot.supportedFilesystems = [ /* "zfs" */ "btrfs" ];
 
+  # Configure host id for ZFS to work
+  networking.hostId = "8425e349";
+
   # Allow the user to log in as root without a password.
   users.extraUsers.root.initialHashedPassword = "";
 }