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 0x7
Partition num: 2, Filesystem type is ext2fs, partition type 0x83
Partition num: 4, Filesystem type unknown, partition type 0x7
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 0x82
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.
+1! Thanks a lot!
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 0x7
Partition num: 3, Filesystem type unknown, partition type 0x77
Partition num: 4, Filesystem type unknown, partition type 0x7
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.
fantastic! i thought i would have to reinstall!
I succesfully repaired my grub loader with your instructions.
Thnx
Props, thanks for the help. Worked perfectly on the first try. I had an XP/Ubuntu dual-boot whose bootloader was wiped out by an XP reinstall. Total time spend fixing this was less than 5 minutes, including the reboots.
Thanks again.
Too easy!
thanks very much.
Excellent! worked perfectly. I felt such a pratt- trying to install Open Solaris on a spare partition, it failed, and trashed grub – this repaired perfectly. Thanks for a really clear, simple set of instructions.
Thank a lot man
you save me
thanks again
Spot on!
Thanks for the great instructions.
i had a vista/xp/ubuntu triple boot system. and it worked fine till i changed the partition table a bit and got grub error 17. your instructions were great help and the pc is working fine now.
thanks
you sir, are a god.
This is “de best solution on d n/w”
Thanx man!!
A Paragon Boot Manager hosed my grub. And their nice restore original MBR command, didn’t! GRUB GRUB GRUB scrolling down the display upon reboot. Your tip took care of everything. Thanks from a Linux newbie.
wow! i never imagined it to be this easy. More power to you dude.
Absolutely perfect! As is the way you worded worded the instructions. You didn’t leave anything open for questions.
Thank you so much.
Mrdak
Eighteen months after your post and you are still helping people. I spent hours trying to learn how to correct an error 22 and your post was the correct answer. THANK YOU FOR MAKING THE POST!
Awesome!! Thanks for the quick instructions. Solved my problem instantly..
Thank you very very much…
You made the process so easy for me…
Dude, you made my day (actually the whole weekend). thx!
Hello, just to say thanks for that. I just need to get my Windows dual-booting again now. But at least it boots into Linux now :-)
First Class advise. Found your post just before blowing the drive away.
You absolutely rock!!! Saved this tech an all nighter. Thanks for your help!!! Your article is huge. Helpful to many :)
Sincerely,
Ubuntu 8.10, 64-bit, the TAB key doesn’t produce the results documented on this page. It just tabs the cursor to the right one jump.
Cool thanks – worked once I worked out I had to do something a little different.
For those of you that have Ubuntu on a 2nd physical hard drive and re-installed windows on the physical 1st hard drive then all you have to do to sort your grub out is on the last step put the drive number that you installed windows onto not the one that Ubuntu is on.
Cheers for the help :o)
Jed
OH MAN YOU DONT KNOW HOW MUCH THIS HELPED ME!!!!
IF YOU BELIVE IN GOD THEN YOU HAVE WINNED THE HEAVENS!!!
And if you don’t belive in god then at least you have earned my bookmark and everlasting gratitude.
Thanks for the clear and simple instructions: I had got most of the way but realized i didn’t know enough about grub to be sure how to do what I knew I needed to do.
After so many days of searching i finally found real answer,
I would like to buy you a beer or many of them
thx
Hello, and thank you so very much. I have a duo-boot Ubuntu 8.10 and Windows XP. Today while in Windows XP my Thinkpad needed to perform some critical updates which left my computer unbootable. Your instructions and my Ubuntu CD got me back my grub boot loader !!!
Thank you so much! I had a slightly different problem, but following your steps corrected my problem! :)
You, my friend, are an absolute lifesaver and the most wonderful person in the world!
Thank You!
Wow, only my Blackberry and you helped not to reinstall the whole system, I am just a Linux beginner. I hate reinstalling, an annoying mess.Had several ext2 etc and tried them one after the other finally it worked. Great! Problem, I have to embed the Blackberry synchronisation and some CAD-Programs otherwise I had switched to Linux or MAC long time ago.
Just shy of 2 years and your post is still helping someone out. I had a dual boot of Win7/Ubuntu Intrepid Ibex going great. Decided to upgrade to Jaunty Jakalope and spent a lot of time perfecting everything. Then Win7 started acting up. A repair fixed it but trashed grub. Your post quickly bitch slapped Win7 right back in it’s place in less than 3 minutes. SA-WEET!!!
I am glad you are all benefiting from this piece close on 2 years later ;)
I’ll be back with some more hints and tips / news as soon as I have the time to. Take care all of you.
Micro.
Just got to say thank you for your instructions here. It has solved the headache I thought I faced after installing Win 7 and losing the Grub loader. Very grateful to you!
Perfect solution. Thanks!
I had XP installed. Fine. Used GParted to set up a bunch of partitions. Fine. Installed Windows 7 RC1 on one of the partitions. Fine. Installed Linux Mint. Fine-ish. Triple boot. Fine. Except I chose a wrong option during the Linux Mint installation so it created its own partition of absolute minimum size required so any Mint updates filled it’s partition and it wouldn’t boot. I fired up GParted and deleted all partitions except XP, Win 7 Mint ext3 and Linux swap.
As a consequence, it wouldn’t boot at all and I was having a grub loading stage1.5 and error 22 problem.
I then deleted the Linux Mint ext3 and linux swap partitions using GParted leaving just the XP and Vista partitions with a bunch of leftover unallocated space. Formatted the unallocated space as FAT32. Reinstalled Linux Mint, which went ok.
But still no boot past the grub error.
Half an hour of googling later and I found http://forums.linuxmint.com/viewtopic.php?f=46&t=16037 which led me to this post.
Followed it through. No ums, ahs, what ifs or maybes. Just a system that will now triple boot XP, Vista and Linux Mint again.
I’ve added this post to Delicious.
Thanks again for your elegantly explained solution that is still working perfectly over 2 years after it was first posted!
Had a grub error 17 after attempting to resize the windows partition on my laptop. The above worked awesomely!
Cheers!
thanks man!
Wow, thanks a lot man, it worked like a charm.
You’re the best, dude!!
microdotsagamedev, Thanks man, This tutorial is awesome. You Rock !! God bless you
Hey this solution has worked for me. Thnx for the great solution.. It worked 100% for me.. Great work.
You seem to be among the least mad men in the Ubuntu world…at least among those helping with GRUB.
lol now I’m so excited since I read everyone else got so excited, I will put my thanks in right now before I reboot. :)
Worked like a charm, thx man!
Hey thanx man u r awesome!!
the fix is totally usefull!!
This has dug me out of so many GRUB problems, many many thanks. I have Ubuntu on my work computer, and mess with it, so when GRUB dies my work PC dies too. Maybe not so smart to live on the edge with the work PC but once again thanks
David
Too bad it didn’t work for me – either ext2-partition threw the error 15: no grub found (or sth like that)… good motivation to reinstall Ubuntu 9.04 while waiting for 10.04 :)
Worked perfect. Great instructions and incredibly helpful. Had a dual boot Backtrack/XP and a Windows 7 install trashed my bootloader. Popped a live distro in and had it fixed in no time. Thanks!
I haven’t tried yet but will later today.
thanks
San Antonio Computer Repair
I’m Getting same behaviour Ubuntu 9.04. there where no comments on your post, so I guess it is something noob silly. have you or anyone else managed to get past this problem?
I cloned a bootable Debian partition from one USB flash drive to a second USB flash drive. When I tried to boot up using the second USB flash drive it hung at a blank screen with a flashing curser (grub didn’t load or anything). However, I followed your instructions and now I can boot up perfectly! :) Thanks mate for the great instructions! :)
I haven’t unfortunately needed to do this again for some time. I suspect that in Ubuntu 9.04 there were significant grub changes which is a pity – because this bailed so many people out of trouble. Has anyone had success with 9.04+?
If so please respond back so I can amend the original instructions.
gonna try cause i have a prob with bootloader
Thanks a lot. I needed to recover my grub and this is the first tutorial in which I have understood correctly the way to do it (and I use Fedora).
Thanks again from Spain!.
Hey, Ubuntu 10.10 here – you have to make a space between root and (hd0,x) like:
root (hd0,5)
Everything including suggestion works fine.
Thanks for the comments all! Still a great resource years later.