Repair your GRUB loader
GRUB is the bootloader of choice for Ubuntu, it is flexible and can be edited to load windows partitions if needed. Every once in a while windows may have the inclination to overwrite your bootloader with its own. This will make accessing your Ubuntu box a mission - fear not, I have a quick solution ;) Follow these steps to repair your GRUB loader:
Boot your PC with an Ubuntu Live CD in the drive
Open a shell (Terminal)
Type the following to re-configure GRUB
sudo grub
Type the following followed by the TAB key
root (hd
This will provide you with a list of possible physical drives eg:
hd0 or hd1
Type the number of the drive you installed ubuntu on, not to worry if you unsure, the next step with tell you if you on the right path. Add a ‘,‘ after the number and press the TAB key again:
root (hd0,
You will see something similar to the following:
grub> root (hd0,
Possible partitions are:
Partition num: 0, Filesystem type unknown, partition type 0×7
Partition num: 2, Filesystem type is ext2fs, partition type 0×83
Partition num: 4, Filesystem type unknown, partition type 0×7
Partition num: 5, Filesystem type is fat, partition type 0xb
Partition num: 6, Filesystem type is fat, partition type 0xb
Partition num: 7, Filesystem type unknown, partition type 0×82
Notice the ext2fs partition, this is the one Ubuntu is installed for the above example. I would therefore type:
root (hd0,2)
Now type the following, replacing hd0 with the physical drive Ubuntu is installed
setup (hd0)
Close the terminal, reboot and enjoy your restored GRUB loader. Let me know how it goes for ya ;)

Works like a charm! Thank you! This is the best tutorial I’ve found for recovering Ubuntu’s bootloader after a Windows re-install.
Great, grub was confusing my for quite a while but this explained things. Thank you very much.
Yellow, Belgium
I just formatted a partition on a secondary hard drive that I thought had nothing on it, and grub died. It seems that Ubuntu made that partition bootable, and put grub on that secondary hard drive.
Using your guide, I installed grub on my primary drive, and all is well, thanks!
I am happy this has worked for all of you, really glad I documented this so that the knowledge can be transferred. To think I wasn’t going to document it first time around :P Glad I changed my mind.
To date ‘How to repair your GRUB loader’ is one of my most successful blogs. Take care all of you!
This helped me on the first attempt! Thanks microdotsagamedev!
I just finished installing a different distro on my second drive. No! I couldn’t possibly have let that distro have control over the boot! Yes, it seems I did. Thanks for the bread crumb trail to find my way home to my Ubuntu install. The directions were spot on!
Awesome, thanks.
Thank you very much, my installation and all my virtual machines are accessible from now on.
YOU ARE THE FREAKIN’ MAN!!!! Thank you! I have been struggling with WinXP wiping my grub boot loader all day. This is simple and worked like a charm
it turns out like this:
grub> root (hd0,
Possible partitions are:
Partition num: 0, Filesystem type unknown, partition type 0xfe
Partition num: 1, Filesystem type unknown, partition type 0×7
Partition num: 3, Filesystem type unknown, partition type 0×77
Partition num: 4, Filesystem type unknown, partition type 0×7
I am pretty sure the linux is in num 3, and i try to run it an error turns out.
Error 17: Cannot mount selected partition
Vince >
You definately wont get the partitions mounted if your list can’t see them. What you output indicates there are no longer any linux ext3 partions. None of those will work.
Thanks a million for that.
My problem was nothing to do with Windows. I tried booting SystemRescueCd on my Ubuntu-only Dell Inspiron 1525. It wouldn’t load and it obviously messed GRUB up since I got GRUB… and nothing else when I subsequently tried booting from the HD. There was an external HD involved as well but I don’t know if that’s relevant. I’d got to the point of considering re-installing but, after following your guide, Ubuntu was back in a matter of minutes. Thanks again.