aboutsummaryrefslogtreecommitdiff
path: root/custom/install-archzfs
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-01-19 23:20:24 -0600
committerCraig Jennings <c@cjennings.net>2026-01-19 23:20:24 -0600
commit5ed8c9567ca2075d29ac00078fa6dd5ad7580629 (patch)
tree89349f7c4ae719c928e2fe553d625a35aa8ae92d /custom/install-archzfs
parent2cf3e88b630b2a6287926c02ca8024ffc5065deb (diff)
downloadarchangel-5ed8c9567ca2075d29ac00078fa6dd5ad7580629.tar.gz
archangel-5ed8c9567ca2075d29ac00078fa6dd5ad7580629.zip
Fix hostid mismatch bug that prevented booting installed systems
Root cause: The `hostid` command returns a value even without /etc/hostid, but `zgenhostid` generates a DIFFERENT random value. The install script was calling `hostid` for the GRUB kernel parameter, then later calling `zgenhostid` to create /etc/hostid - resulting in a mismatch. ZFS refuses to auto-import pools when spl.spl_hostid doesn't match /etc/hostid, causing "Failed to mount /sysroot" at boot. Fix: Generate hostid with zgenhostid FIRST (in configure_bootloader), then read the consistent value for the GRUB kernel parameter. The configure_zfs_services function now just copies the already-existing /etc/hostid to the installed system. Verified in VM: GRUB and /etc/hostid both show identical values after installation.
Diffstat (limited to 'custom/install-archzfs')
-rwxr-xr-xcustom/install-archzfs18
1 files changed, 10 insertions, 8 deletions
diff --git a/custom/install-archzfs b/custom/install-archzfs
index c604868..a6679eb 100755
--- a/custom/install-archzfs
+++ b/custom/install-archzfs
@@ -1071,7 +1071,14 @@ EOF
configure_bootloader() {
step "Configuring GRUB Bootloader"
- # Get hostid for kernel parameter
+ # Ensure hostid exists BEFORE reading it
+ # This is critical: hostid command returns a value even without /etc/hostid,
+ # but zgenhostid creates a DIFFERENT value. We must generate first, then read.
+ if [[ ! -f /etc/hostid ]]; then
+ zgenhostid
+ fi
+
+ # Now get the consistent hostid for kernel parameter
local host_id
host_id=$(hostid)
@@ -1156,13 +1163,8 @@ configure_zfs_services() {
arch-chroot /mnt systemctl enable zfs-import.target
# Copy hostid to installed system (ZFS uses this for pool ownership)
- if [[ -f /etc/hostid ]]; then
- cp /etc/hostid /mnt/etc/hostid
- else
- # Generate hostid if it doesn't exist
- zgenhostid
- cp /etc/hostid /mnt/etc/hostid
- fi
+ # Note: hostid is generated in configure_bootloader, so it always exists here
+ cp /etc/hostid /mnt/etc/hostid
# Generate zpool cache
mkdir -p /mnt/etc/zfs