melp.nl

< Return to main page

How to restore grub with a live CD

I borked my primary boot device's grub installation last week because I wanted to start Windows 7 to play some LAN games. Windows 7 wouldn't boot from grub, so I thought I'd install a new grub version. I reinstalled grub before regenerating the config file and rebooted. Too bad the Arch packages don't handle that for you, as I was used to in Debian. This caused the grub to fail booting both Windows and Arch, so I resorted to changing my primary boot device in the BIOS.

Now, one week later, I decided to fix it, and as I can never recall by heart what the steps to take are, here's a recipe, pretty much for my own convenience.

I'm running Arch Linux currently, but the same principle should work for any Linux flavour you might be using.

Recipe

  1. Boot from whatever live CD you have lying around
  2. Login in a shell
  3. Create a local mount point for your hard disk's root device (eg /mnt/root)
  4. Mount the root partition onto that mount point

    #!shell
    # mount /dev/sda1 /mnt/root
    
  5. Mount the device system

    #!shell
    # mount -o bind /dev /mnt/root/dev
    
  6. Mount the proc file system

    #!shell
    # mount -t proc none /mnt/root/proc
    
  7. Change root

    #!shell
    # chroot /mnt/root
    
  8. Make sure the boot partition is mounted, if you have one.

    #!shell
    # mount /boot
    
  9. Regenerate grub config

    #!shell
    # grub-mkconfig -o /boot/grub/grub.cfg
    
  10. Reinstall grub

    #!shell
    # grub-install /dev/sda
    
  11. Reboot and enjoy.

    #!shell
    # shutdown -r now
    

Of course, you need to substitute the device names with your own.


< Return to main page


You're looking at a very minimalistic archived version of this website. I wish to preserve to content, but I no longer wish to maintain Wordpress, nor handle the abuse that comes with that.