my computer shut down when I was doing nixos-rebuild switch now no grub boot is to be…
- User
my computer shut down when I was doing nixos-rebuild switch now no grub boot is to be loading hence cant enter the system? what to do ?
- Assistant
my computer shut down when I was doing nixos-rebuild switch now no grub boot is to be loading hence cant enter the system? what to do ?
If your computer shut down during a nixos-rebuild switch, it’s possible that the system is in a state that prevents it from booting properly. Here are steps you can take to troubleshoot and potentially resolve the issue:
Once you've booted into the live environment:
Open a terminal.
Determine your root filesystem by running:
lsblk
Look for your root partition (it’s usually labeled something like /dev/sda1, /dev/nvme0n1p1, etc.).
Mount your root partition. Replace /dev/sdXn with your actual root partition:
sudo mount /dev/sdXn /mnt
If you have a separate boot partition, mount it as well:
sudo mount /dev/sdXn /mnt/boot
(replace with the appropriate device for your boot partition).
Change Root: Enter your system's environment:
sudo nixos-enter --root /mnt
Rebuild: Attempt to rebuild your system:
sudo nixos-rebuild switch
Ensure that GRUB is installed properly:
sudo grub-install /dev/sdX
(Replace /dev/sdX with your disk, such as /dev/sda, not a partition like /dev/sda1.)
Re-generate your GRUB configuration:
sudo grub-mkconfig -o /boot/grub/grub.cfg
Exit the chroot environment:
exit
Unmount your partitions and reboot:
sudo umount /mnt/boot
sudo umount /mnt
reboot
If after following these steps you still cannot boot, you may want to investigate any logs that could provide clues:
/mnt/var/log after you mount your NixOS root.If nothing works, you might consider backing up your data from the live USB environment and performing a clean installation.
Take this opportunity to back up any important data before making more changes.
These steps should help you recover from a failed nixos-rebuild switch. If you encounter any specific errors or issues in the process, please provide that information for further assistance.
Not yet included in a published release.