Update NixOS then system broke. How to solve it?

TLDR: the error message is Kernel panic - not syncing: VFS: Unable to mount root fs on "fstab" or unknown-block(0,0)

Long story:
I am using nixos-26.05. I ran the command nix flake upadte and then nh os switch --show-activation-logs --ask on my laptop then leave my home.
Hours later I came back home, check the laptop and it was not responsive with black screen. I thought it is usual because my laptop sometimes cannot be woke up when sleep, so I long press the power button to turn it off then turn it on again.

The laptop could not recognize nixos and went strict in the bios when I turn it on. Then I used a live-usb, run nixos-enter, rollback to the last working generation, in the stdout it mention installed some grub and efi stuff. Then I turn off the laptop and it can boot into nixos on my SSD again.

Then I use command nh os switch --show-activation-logs --ask again to switch to my latest setup, it run successfully. But when I reboot, it shows

......
List of all partitions:
No filesystem could mount root, tried:

Kernel panic - not syncing: VFS: Unable to mount root fs on "fstab" or unknown-block(0,0)
CPU: 1UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.57 #1 NixOS PREEMPT(lazy)
Hardware name: MY_LAPTOP_HARDWARE
Call Trace:
<TASK>
.......
</TASK>
Kernel Offset : 0x1f000000000 from ....................................

I have to select latest working generation in grub menu to boot into nixos.

the usual plea: show us your config. what filesystem are you using? I guess lsblk / mounts would be useful as well.

This is my lsblk output.

NAME           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
zram0          253:0    0   8.8G  0 disk  [SWAP]
nvme0n1        259:0    0 931.5G  0 disk
├─nvme0n1p1    259:1    0     1G  0 part  /boot/efi
└─nvme0n1p2    259:2    0 930.5G  0 part
  └─nixos_root 254:0    0 930.5G  0 crypt /swap
                                          /home
                                          /.snapshots
                                          /nix/store
                                          /nix
                                          /var/log
                                          /

My config is huge, if it is caused by misconfiguration then i think it is just an easy fix. But I don’t know if it is something corrupted in /nix/store and nh os switch cannot fix.

It can’t be a nix store problem, because you aren’t getting to the nix store. You aren’t even getting root mounted.

I just checkout the git commit of my last successful update (on 2026-10-11), do a nh os switch, then can successfully reboot.
However from this point, I run nix flake update, then nh os switch, (it do not build and download much as I already did that when I left home in the morning), then reboot unsuccessfully, with exactly the above error. I think something is broken in nix store, but I do not know how to fix it.

What do you mean??? sorry I haven’t mention I am using btrfs.

I’m sure someone with more patience than I will show up to dig into this with you, but the store (I am assuming) is on the root file system. The error is telling you that linux can’t mount it. That’s your kernel panic. So in my experience there are some reasons for this:

  1. No kernel module for the fs
  2. media is missing

I notice that you have type crypt, assuming then you are running full disk encryption. honestly super uninterested into trying to guess my way though this. I’m out. Please find some way to share your configuration for the next soul in this thread.

Thank you for your tip!
I am using full disk encryption and btrfs subvolume.

The funny thing is that all of my other machine with similar setup just update fine, just my laptop failed to boot. Maybe I just wait for another nixos-26.05 channel update and try again.

Fixed with nh clean all in an old working generation and then update again.

Base on your solution, is it due to disk space or inode counts being used up on your system partition, or some stateful procedures in the middle of generation activation?