[Nix-dev] Recovering from a failed GRUB update.

roconnor at theorem.ca roconnor at theorem.ca
Wed Jul 8 17:20:22 CEST 2015


For some unknown reason my NixOS update on my laptop last night failed to 
properly install GRUB (even though I claim that GRUB completed 
sucessfully).  When I rebooted I was met with a simple grub prompt

grub>

and no boot menu.


Here is what I did to recover.

(1) I booted from a NixOS install media and logged in as root.

(2) I mounted my hard disk at /mnt:
     mount /dev/sda /mnt

(3) I browsed the system profiles to select the one I wanted to reactive:
     ls -l /mnt/nix/var/nix/profiles/system*

My lastest generation is system-27-link.  For safety I decided I 
wanted to active system-26-link.

(4) Bind dev and friends:  Loosely following the nixos-install script, I 
ran the following commands:
     mount --rbind /dev /mnt/dev
     mount --rbind /proc /mnt/proc
     mount --rbind /sys /mnt/sys

(5) I reactivated the system-26-link generation
     NIXOS_INSTALL_GRUB=1 chroot /mnt /nix/var/nix/profiles/system-26-link/bin/switch-to-configuration boot

After that I rebooted, and I was fine.


This is all written from memory, so there may be errors.

Also, I didn't actually run the command in step (5).  I actually ran
     chroot /mnt /bin/sh
and from the shell I ran the switch-to-configuration command.


Currently, I'm too scared to try to reproduce the GRUB install failure.

-- 
Russell O'Connor                                      <http://r6.ca/>
``All talk about `theft,''' the general counsel of the American Graphophone
Company wrote, ``is the merest claptrap, for there exists no property in
ideas musical, literary or artistic, except as defined by statute.''


More information about the nix-dev mailing list