From ffeb6c1007e7364c899bee4128bdc25fd899a3b6 Mon Sep 17 00:00:00 2001 From: Erik Simon Date: Fri, 24 Jul 2026 21:12:17 +0200 Subject: [PATCH] fix --- hosts/terra/disk-config.nix | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/hosts/terra/disk-config.nix b/hosts/terra/disk-config.nix index d222811..949a3e6 100644 --- a/hosts/terra/disk-config.nix +++ b/hosts/terra/disk-config.nix @@ -5,13 +5,27 @@ # `fileSystems.*` entries, so hardware-configuration.nix must NOT define # fileSystems for "/" or "/boot". # -# ⚠️ Root is btrfs (was ext4): the disk previously held a CachyOS btrfs root, -# and disko's `mkfs` create step SKIPS formatting when `blkid` still -# detects a filesystem signature on the freshly-cut partition. A stale -# btrfs superblock survives `wipefs`+repartition inside the new root -# partition's range, so an ext4 root got skipped and `mount -t ext4` -# then failed on the leftover btrfs bytes ("bad superblock"). btrfs's -# create runs `mkfs.btrfs -f`, which reformats past any stale signature. +# ⚠️ disko's `mkfs` create step SKIPS formatting when `blkid` still detects a +# filesystem signature on the freshly-cut partition: +# +# if ! (blkid "$device" -o export | grep -q '^TYPE='); then +# mkfs.btrfs "$device" -f # ← -f only runs WHEN this line runs +# fi +# +# The disk previously held a CachyOS btrfs root. The whole-disk `wipefs` +# disko runs before partitioning clears the signature at the OLD layout's +# offsets, but `sgdisk --clear --align-end` then re-cuts the partitions, so +# a stale btrfs superblock survives at the NEW root partition's own 64 KiB +# offset. `blkid` sees TYPE=btrfs, `mkfs` is skipped entirely, and the +# later `mount` fails on the leftover bytes ("wrong fs type / bad +# superblock"). Switching ext4→btrfs did NOT fix this: `mkfs.btrfs -f` is +# never reached, because the guard is on whether `mkfs` runs at all, not on +# its flags. The ESP hits the same trap (its `mkfs.vfat` gets skipped too). +# +# Fix: `preCreateHook = wipefs --all --force "$device"` on each partition's +# content. The hook runs AFTER sgdisk re-cuts the partition but BEFORE the +# `blkid` guard, so it erases the stale signature at the FINAL offset; +# `blkid` then comes back empty and `mkfs` actually runs. # # ⚠️ This disk is WIPED on install. This is the Kingston SA400 SSD that # currently holds CachyOS (btrfs root+subvols on sdb2, ESP on sdb1). @@ -34,6 +48,8 @@ format = "vfat"; mountpoint = "/boot"; mountOptions = [ "umask=0077" ]; + # erase any stale signature before disko's blkid format-guard (above) + preCreateHook = ''wipefs --all --force "$device"''; }; }; root = { @@ -42,6 +58,9 @@ type = "btrfs"; extraArgs = [ "-f" ]; mountpoint = "/"; + # erase the stale CachyOS btrfs superblock before disko's blkid + # format-guard, otherwise mkfs.btrfs is skipped (see header comment) + preCreateHook = ''wipefs --all --force "$device"''; }; }; };