Home > GRUB, Kubuntu, Ubuntu, Unix > Repair your GRUB loader

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 ;)

About these ads
Categories: GRUB, Kubuntu, Ubuntu, Unix
  1. June 27, 2007 at 12:27 pm

    Works like a charm! Thank you! This is the best tutorial I’ve found for recovering Ubuntu’s bootloader after a Windows re-install.

    • Matt
      August 15, 2009 at 9:08 am

      +1! Thanks a lot!

  2. Yellow
    July 31, 2007 at 6:54 pm

    Great, grub was confusing my for quite a while but this explained things. Thank you very much.

    Yellow, Belgium

  3. moo
    August 12, 2007 at 2:40 am

    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!

  4. August 12, 2007 at 12:35 pm

    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!

  5. Thankful
    August 19, 2007 at 11:10 pm

    This helped me on the first attempt! Thanks microdotsagamedev!

  6. Steve
    September 16, 2007 at 9:43 pm

    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!

  7. someone
    November 29, 2007 at 9:39 pm

    Awesome, thanks.

  8. Gerard
    December 17, 2007 at 11:33 pm

    Thank you very much, my installation and all my virtual machines are accessible from now on.

  9. rob
    March 29, 2008 at 5:36 am

    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

  10. vince
    March 31, 2008 at 9:36 am

    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

  11. April 11, 2008 at 12:21 pm

    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.

  12. Andy D
    May 11, 2008 at 10:45 pm

    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.

  13. aclub
    August 8, 2008 at 5:36 am

    fantastic! i thought i would have to reinstall!

  14. Martin
    August 9, 2008 at 10:22 pm

    I succesfully repaired my grub loader with your instructions.
    Thnx

  15. August 29, 2008 at 7:12 pm

    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.

  16. kol
    September 9, 2008 at 6:18 am

    Too easy!

    thanks very much.

  17. gerry
    September 18, 2008 at 12:07 am

    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.

  18. taz
    September 24, 2008 at 4:36 pm

    Thank a lot man
    you save me
    thanks again

  19. yazman
    September 26, 2008 at 6:12 am

    Spot on!

    Thanks for the great instructions.

  20. sk
    September 28, 2008 at 6:34 am

    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

  21. anon
    September 30, 2008 at 4:55 am

    you sir, are a god.

  22. AAjai
    October 3, 2008 at 8:24 pm

    This is “de best solution on d n/w”
    Thanx man!!

  23. Mark
    November 3, 2008 at 5:43 pm

    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.

  24. chebar
    November 15, 2008 at 11:23 pm

    wow! i never imagined it to be this easy. More power to you dude.

  25. Mrdak
    November 17, 2008 at 6:47 pm

    Absolutely perfect! As is the way you worded worded the instructions. You didn’t leave anything open for questions.
    Thank you so much.

    Mrdak

  26. Steve S
    November 19, 2008 at 5:43 am

    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!

  27. Mihael Johnson
    November 20, 2008 at 6:28 pm

    Awesome!! Thanks for the quick instructions. Solved my problem instantly..

  28. December 14, 2008 at 4:41 pm

    Thank you very very much…

    You made the process so easy for me…

  29. a
    December 19, 2008 at 10:20 pm

    Dude, you made my day (actually the whole weekend). thx!

  30. Paul Duncan
    January 5, 2009 at 4:44 pm

    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 :-)

  31. LoneHDRider
    January 10, 2009 at 9:34 am

    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,

  32. January 17, 2009 at 9:00 am

    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.

  33. Jed
    January 27, 2009 at 8:13 pm

    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

  34. phylwx
    February 2, 2009 at 6:23 pm

    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.

  35. john
    February 13, 2009 at 8:50 pm

    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.

  36. Vanja
    February 17, 2009 at 11:11 pm

    After so many days of searching i finally found real answer,
    I would like to buy you a beer or many of them

    thx

  37. Rob Bowman
    March 6, 2009 at 2:15 am

    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 !!!

  38. Jonny
    March 8, 2009 at 3:06 pm

    Thank you so much! I had a slightly different problem, but following your steps corrected my problem! :)

  39. May 19, 2009 at 6:23 pm

    You, my friend, are an absolute lifesaver and the most wonderful person in the world!

    Thank You!

  40. Klaus Herbertz
    May 31, 2009 at 12:24 pm

    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.

  41. Rolo
    June 1, 2009 at 5:25 am

    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!!!

  42. June 1, 2009 at 9:09 am

    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.

  43. Martin Jameson
    June 15, 2009 at 3:17 pm

    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!

  44. wes
    June 30, 2009 at 12:08 am

    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!

  45. Dim
    July 9, 2009 at 7:07 am

    Had a grub error 17 after attempting to resize the windows partition on my laptop. The above worked awesomely!

    Cheers!

  46. July 26, 2009 at 4:53 pm

    thanks man!

  47. Diego
    September 4, 2009 at 5:55 pm

    Wow, thanks a lot man, it worked like a charm.

    You’re the best, dude!!

  48. September 24, 2009 at 4:43 pm

    microdotsagamedev, Thanks man, This tutorial is awesome. You Rock !! God bless you

  49. November 4, 2009 at 12:55 pm

    Hey this solution has worked for me. Thnx for the great solution.. It worked 100% for me.. Great work.

  50. Mean Mister Mustard
    November 15, 2009 at 4:34 am

    You seem to be among the least mad men in the Ubuntu world…at least among those helping with GRUB.

  51. Faithful Wonder
    December 1, 2009 at 5:51 am

    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. :)

  52. Elis
    January 16, 2010 at 1:56 am

    Worked like a charm, thx man!

  53. Akshay
    January 30, 2010 at 1:59 pm

    Hey thanx man u r awesome!!

    the fix is totally usefull!!

  54. david wright
    March 28, 2010 at 4:54 pm

    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

  55. Vassago
    March 30, 2010 at 6:58 am

    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 :)

  56. Renek
    April 15, 2010 at 3:21 pm

    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!

  57. satechheads
    May 17, 2010 at 1:56 pm

    I haven’t tried yet but will later today.

    thanks

    San Antonio Computer Repair

  58. dbld
    June 3, 2010 at 10:20 am

    Steve Withers :
    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.

    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?

  59. August 13, 2010 at 10:27 am

    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! :)

  60. August 13, 2010 at 11:09 am

    dbld :

    Steve Withers :
    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.

    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 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.

  61. dark
    February 24, 2011 at 1:34 am

    gonna try cause i have a prob with bootloader

  62. Javi
    June 21, 2011 at 6:22 pm

    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!.

  63. RicoElectrico
    August 31, 2011 at 11:30 am

    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.

  64. September 19, 2011 at 1:44 pm

    Thanks for the comments all! Still a great resource years later.

  1. August 31, 2008 at 6:57 am
  2. December 26, 2008 at 11:41 pm
  3. September 19, 2009 at 2:23 am
  4. October 29, 2009 at 2:19 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: