Today in my busiest hour, after a fool action I lost grub. And as smart as I am, I rebooted the PC, so I got locked out of it.

Well, time to boot with a live CD and reinstall Grub. This is what I’ve done.

sudo mount /dev/hdb3 /mnt

That will mount my root partition in the mnt directory of the Live CD session.

sudo mount /dev/hdb4 /mnt/boot

As I have a different partition for boot, I need to mount it too, inside the /root partition, if you do not have this scenario, you do not need that line.

grub-install --root-directory=/mnt/ /dev/hda

And I got this error:

/dev/hda does not have any corresponding BIOS drive

Well to solve the problem all you need to do is to edit the file device.map, on the mounted partition.

In my case:

sudo vim /mnt/boot/grub/device.map

Then add there:

(hd0) /dev/hda

Also if needed

(hd1) /dev/hdb

In my case those (hd0) and (hd1) were mapped as /sda and /sdb (They are not SATA but Arch Linux works that way, and I was using old Mandriva Live CD).

Once I made the changes, I was able to reinstall grub, and, before restarting I changed the device.map file to its original state.