Reinstalling ‘grub’ boot loader

OK. Documenting this here for the next time I have to do this.

I’m working on setting up a computer that dual-boots into Linux and XP.

Rule 1: Always put Windows on the first primary partition on the drive. Linux can go pretty much anywhere else.

Rule 2: Always install Windows first, then Linux, so the boot loader will get set up properly. I knew this, but chose to do things the other way around anyhow (yep, I’m stupid that way). And of course, the XP install hosed the Linux boot loader, so I had to manually restore it, which was a big pain.

Here’s how I reinstalled the boot loader, for the next time I ignore my own advice…

  1. Boot into the Debian netinst CD, or Knoppix, or Tom’s Root Boot, or whatever flavor of standalone Linux you prefer.

    With netinst, you’ll need to walk through the install process until it gets to the disk partitioning part (this ensures that the disk devices are loaded). Then, hit ALT-F2 to get a shell.

  2. Create a mount point, say /disk, and mount your root filesystem there. Example: mount /dev/hda5 /disk
  3. chroot /disk
  4. Mount any additional filesystems you might need, like /boot, etc.
  5. grub-install /dev/hda

That’s all I needed to do, but it took several unsuccessful attempts to arrive at this.

References: here and here.

1 thought on “Reinstalling ‘grub’ boot loader

Comments are closed.