70 lines
2.9 KiB
Nix
70 lines
2.9 KiB
Nix
{ ... }:
|
|
|
|
# Declarative OS-disk layout (disko). UEFI: GPT with an ESP + btrfs root.
|
|
# disko both PARTITIONS/FORMATS this disk and generates the NixOS
|
|
# `fileSystems.*` entries, so hardware-configuration.nix must NOT define
|
|
# fileSystems for "/" or "/boot".
|
|
#
|
|
# ⚠️ 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).
|
|
# The dev-data disks (sdc ext4 /mnt/hdd_01, LVM vg_ssd /mnt/ssd_01) and the
|
|
# leftover ntfs disks (sda, sdf, nvme0n1) are NOT listed here — they are
|
|
# mounted as plain fileSystems in configuration.nix (or, for the ntfs
|
|
# disks, ignored entirely) so they are never touched.
|
|
{
|
|
disko.devices.disk.os = {
|
|
type = "disk";
|
|
device = "/dev/disk/by-id/ata-KINGSTON_SA400S37480G_50026B738072F6C6";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
ESP = {
|
|
size = "512M";
|
|
type = "EF00";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "vfat";
|
|
mountpoint = "/boot";
|
|
mountOptions = [ "umask=0077" ];
|
|
# erase any stale signature before disko's blkid format-guard (above)
|
|
preCreateHook = ''wipefs --all --force "$device"'';
|
|
};
|
|
};
|
|
root = {
|
|
size = "100%";
|
|
content = {
|
|
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"'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|