NixOS fails to boot after Windows install

I’m facing a boot issue after installing Windows 11 alongside my existing NixOS setup. Windows seems to have overwritten the GRUB bootloader or filesystem of nixos is corrupted. When I boot into NixOS, and select latest build, the boot process fails.

I’ve tried to identify partitions:

Ok so no, the boot loader is fine. You wouldn’t get that far if the boot loader were broken.

The system is failing to find your root partition during initrd. And looking at your GParted output, it doesn’t seem to think your partition has a file system on it, which explains why initrd doesn’t find the partition (the uuid is retrieved from the file system on the partition, not from the partition uuid in the GPT).

How did you resize nixos to make room for windows? It seems like whatever you did didn’t actually relocate the file system, and it may now be wiped.

1 Like

Fixed it.

  1. Boot with a NixOS live USB
  2. Enter Terminal
  3. First, check if the NVMe drive has any partitions:
    sudo fdisk -l /dev/nvme0n1
  4. Try to recover the partition table using testdisk:
    sudo nix-shell -p testdisk
    sudo testdisk /dev/nvme0n1
  5. If you can see the partitions but can’t mount them, try checking the filesystems:
    # For ext4 partitions
    sudo fsck -f /dev/nvme0n1px # Replace x with partition number
  6. If you still can’t access the partition, try repairing the GPT table first:
    sudo gdisk /dev/nvme0n1
    Type r for recovery/transformation menu
    Type b to rebuild the GPT table from backup
    Type w to write changes and exit
  7. After fixing the GPT table, try mounting again:
    sudo mkdir -p /mnt
    sudo mount /dev/nvme0n1x /mnt