After making some config changes, I ran nixos-rebuild switch ... as usual. And
got a strange error:
error: getting status of '/nix/store/8a1xkznaqzq3a3dgh2q7farm7b7rdk28-source/modules/plugins/mini/diff/default.nix': Bad message
┏━ 1 Errors:
┃ <snip>
┃ error: getting status of '/nix/store/8a1xkznaqzq3a3dgh2q7farm7b7rdk28-source/modules/plugins/mini/diff/default.nix'…
┣━━━
┗━ ∑ ⚠ Exited with 1 errors reported by nix at 19:23:15 after 3s
Error:
0: Failed to build configuration
1: Command exited with status Exited(1)
Bad message? After searching online, it seems like a file system issue. Let’s
check dmesg:
$ sudo dmesg | grep -E "nvme|ext4|EIO|error|corrupt|bad" | tail -40 22:38:32
[32170.209995] EXT4-fs warning (device nvme0n1p2): ext4_dirblock_csum_verify:406: inode #21237380: comm chmod: No space for directory leaf checksum. Please run e2fsck -D.
[32170.209998] EXT4-fs error (device nvme0n1p2): htree_dirblock_to_tree:1083: inode #21237380: comm chmod: Directory block failed checksum
[32170.211080] EXT4-fs warning (device nvme0n1p2): ext4_dirblock_csum_verify:406: inode #21237384: comm chmod: No space for directory leaf checksum. Please run e2fsck -D.
<snip>
[32239.441478] EXT4-fs error (device nvme0n1p2): htree_dirblock_to_tree:1083: inode #21237372: comm rm: Directory block failed checksum
[32239.441486] EXT4-fs warning (device nvme0n1p2): ext4_dirblock_csum_verify:406: inode #21237372: comm rm: No space for directory leaf checksum. Please run e2fsck -D.
[32239.441487] EXT4-fs error (device nvme0n1p2): ext4_empty_dir:3096: inode #21237372: comm rm: Directory block failed checksum
Oof. Okay, boot into Linux using a usb drive that you definitely remember to
keep around. Then run sudo e2fsck -D -f /dev/<your drive>, in my case it’s
/dev/nvme0n1p2 from the dmesg logs.
And that fixed it, for me anyways. If that doesn’t fix it, you may want to start praying (and back up any important data, quickly).
The remainder is cleaning up the errant directory from before:
$ sudo nix-store --delete --ignore-liveness /nix/store/8a1xkznaqzq3a3dgh2q7farm7b7rdk28-source