Pages

Install Boot-Repair in Ubuntu 11.04 (Reinstalling GRUB in Ubuntu Made Easy!)

The Boot loader is one of the most important aspects/programs of all operating systems. Whether its GNU/Linux, MS Window or Mac OS, etc it must be present!. And it is also a very fragile one as well. That's why having a recovery disk is also very important otherwise, say you're a bit new to all these "stuff", then you might easily end up losing data on your hard disk drive for instance.

Anyhow, there are primarily two main boot loaders can be seen in computers, one type is called the primary boot loader which represents a small piece of code/instructions that lets you computer to boot or load the most primary software contents without problems (that are closely related to the actual hardware, such as sending display signals to the Monitor screen or checking your RAM for errors for instance). This is usually stored in a ROM (read only memory) or EEPROM chip. The best example for such a Boot loader is the BIOS on your computer's motherboard.

Although the functions of a primary boot loader can be quite limited because those ROM chips usually have smaller capacity + since every operating system has a way of its own doing things, it's almost impossible to add all the details into the ROM. Even if we put our OS boot information into it, yet it can be quite hard to update it whenever the OS developers want since updating a BIOS chip has is "risks".

As an answer to all these issues they came up with another kind of boot loaders that run after the BIOS|primary boot loader is executed called secondary boot loaders. They're usually stored in your HDD/USB, etc, a place called MBR (master boot record). Now, these type of boot loaders are OS specific (not always true because they do have the ability to boot into other OS boot loaders. Multi OS boot for instance) and are behind the perfect execution of your operating system into your RAM.

Although there are several types... yet in GNU/Linux there are primarily two main BL can be identified. One is called Lilo and the other is called GRUB. GRUB is the primary one (if I'm not mistaken) these days which is an official part of the GNU project as well.

There can be many occasions a boot loader can be "corrupted"... say due to a virus attack or while trying to install/reinstall a boot loader or can occur after using a disk repair app in GNU/Linux (yes, it's possible) . When it comes to GRUB, in GNU/Linux you can install/reinstall GRUB loader without any GUI, even if your GNU/Linux PC Laptop is un-bootable, as long as you have the Live CD, etc you can use a command called "grub-install".

But then again, when you have an excellent grub installer GUI, why the heck u wanna do that! :). Sorry to drag you along with all these "related" details (just kinda felt like writing em)... if you want to easily control your GRUB boot loader in Ubuntu, then there is an excellent, GTK written GUI called "Boot-Repair".

This "window" is not available for those of us who use the original, official Ubuntu LiveCD... thus once installed and run we should be prompted by the below one instead...

Main features...

*. Recover or Repair your Grub code in MBR when you can't even boot your OS.

*. Repair it within the OS (you know, even if you removed your boot loader, as long as you don't reboot your PC, you're gonna be fine, for a while :P)

*. Reinstall the loader.


*. Change the location of the GRUB installation (you know, installing it into an another HDD, etc).

*. Restore the original boot sector.

You can install the magnificent :D Boot-Repair in Ubuntu 11.04 Natty Narwhal, 11.10 Oneiric Ocelot, 12.04 Precise Pangolin, 10.10 and 10.04 by entering the below command in your Terminal.
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair
How the heck can I use it if I can't boot into my Ubuntu desktop Gayan!, you... nutcase?

Well my friend, use your Live CD or Live USB... boot into your desktop using those media and simply instal the Boot-Repair using the same command. Or I think you should be able to run it in the "/usr/bin" directory if no internet connection is available. In that sense, we can actually create a Linux recovery disk/LiveCD by using this app that should help to access/recover our data without even losing a single byte! :D. Good luck.

Oh, I should be thankful to this awesome Ubuntu forum thread for this app news as well :).

Update: You can get more information from this official Boot-Repair Ubuntu Help page too. Thanks "Yann" (the developer) for the update :).

56 comments:

Chris said...

Why waste bandwidth on updating ubuntu if its a live install?

Gayan said...

@Chris,

I'm a bit confused Chris (I have such a dull brain ;-)), what did you mean?

Anyhow, this boot-repair is not just a live install utility, you can install it on your "permanent" Ubuntu Linux distro as well...

Vigas Deep said...

Thanks man, you just saved my life :D hehe.. i mean my ubuntu :D

Gayan said...

@Vigas,

My pleasure dude...

Anonymous said...

Man i have 2 HDD. One running Windows 7 and the other one has ubuntu. I have a dual boot. Windows 7 works fine but when booting in ubuntu i can't by pass the grub screen. I can't go to Ubuntu desktop at all. It's just stuck on the grub screen. If i use the boot loader how can i be sure it is not going to mess up my windows 7 ?

Gayan said...

@Anonymous,

Okay... now I assume that you have installed GRUB to the other HDD in which you have Ubuntu and the Win 7 is in a separate HDD.

If you have the Ubuntu Live CD, then this is what you can do. Boot the Live CD and install the app and run it.

1. First remove/uninstall your current GRUB from the app.

2. Then re-install the GRUB which should detect both your Win7 and Ubuntu and make sure to install the GRUB in the HDD that you have Ubuntu.

Then reboot and your system should work fine. Now I know that you know this, but wrote just in case.

But as a direct answer to your question.

If you install the GRUB into the other HDD where you have your Ubuntu, then the WIN 7 MBR will not be modified my GRUB under any circumstances. Anyhow, just make sure...

*. to install the GRUB on the Ubuntu HDD thus no matter what the GRUB does all these changes will be made within the HDD that you have Ubuntu, not Win7. So partition table, Data, MBR, etc in Win7 HDD should be fine since the GRUB is not installed in that HDD.

But I cannot personally guarantee anything... so use it at your own risk. Hope this was helpful. You can manually override the original Win 7 MBR by using the below method if necessary.

http://support.microsoft.com/kb/927392

Anonymous said...

i already installed windows 7 in C drive and Ubuntu 11.04 in F drive in my computer. Due to some problem of windows 7, i had to format c drive and re-install windows 7 on c drive.Now my system directly load windows 7.Now it doesn't show Ubuntu in windows boot manager window. How can I show that Ubuntu option in windows boot manger window and How can I enter into Ubuntu OS without reinstalling Ubuntu. please help me..............

Gayan said...

@AKHIL,

I deleted two of my previous comments because I thought they may confuse you a bit more :/... so in general you should do the below steps to recover the original Ubuntu GRUB menu.

1. Insert the Ubuntu 11.04 Live CD and boot into the desktop. Then install the application using the command in the post.

Then use the below command in your Terminal window to run it.

sudo boot-repair

Even though in the post you can see two screenshots but apparently (I update a little "description on the first screenshot) you won't be getting that window with 4 choices thus once run it should open a new window that looks like the second screenshot instead.

Now I assume that you have a single HDD with multiple partitions and then from that window click on the "Apply" button. Now THIS SHOULD FIX YOUR ISSUE.

2. If however this does not, then you can try clicking on the "advanced" option and use the one that says..

"(Required Internet) Manually Purge and reinstall of the GRUB of..."

But as said.. the first method should solve your issue but if everything fails.. then you can read more from the below link to find a way out

http://ubuntuforums.org/showthread.php?s=7dfa8e7510823620365ec63d282149cc&t=1769482&page=2

I'm sorry for my Bad English mess ;-)

Anonymous said...

After many failed attempts at sudo this and that, I rebooted from the live cd (Ubuntu 11.04 64 bit) and clicked on System settings and then found the "repair boot menu" and voila!

Gayan said...

@Anonymous,

Cool ;-)...

damned_7 said...

I've to reinstall grub after installing Seven. I've only one hdd with Seven on c: and ubuntu 11.04 with /boot,/root, and /home partitions.
The standard execution of boot-repair doesn't give errors, but after reboot there's still the Seven menu with his list (Seven, Seven safe?...etc).
In the advanced options, in the list with the default OS there's only Ubuntu.
If I choose to manually delete and reinstall grub the command

sudo chroot /mnt/clean/sda5 apt-get purge -y grub grub-pc grub-common

gives this error:
chroot: failed to run command `apt-get': Exec format error

Any suggestions?
thank you

Gayan said...

@damned_7,

Well as far as I know (as said I ain't an advanced geek at this... sorry about that :/) if you remove the "grub" using the apt-get you'll run into trouble.

Although I'm not sure but when apt-get removes "grub" it only removes the installed files not the actual "grub" portions on the MBR.

So you'd basically have a PC with Grub in the HDD MBR but the real "grub-engine" (installed files of the GRUB) on the Ubuntu is missing... which is certainly not good.

I may be wrong here since if you go with the above command and when apt-get removes the "grub" packages, it might also uninstall/remove the GRUB on your MBR properly.

Anyhow it seems that even after running the boot-repair, it has failed to install the GRUB on your HDD and again what's the point of removing GRUB when it's not installed.

But, since you have a the usual suspects list of MS Windows (safe-mode, etc) rather than the standard booting straight away, may I humbly advice you to first properly boot into MS Win7 and log-in to your desktop and then do a proper reboot.

The idea is to get rid of the "Win 7 boot-list" which only appear if the OS wasn't able to boot properly in the last occasion and let the Win7 to "update" its MBR properly.

So first get rid of the "list" and after solving that again try to re-install the GRUB using the tool in Ubuntu LiveCD environment???

OR if it fails then

You can try to reinstall the original Win7 boot-loader by using the steps laid-out in the below link

http://support.microsoft.com/kb/927392

and then try to re-install the GRUB in LiveCD using the tool (an update is appreciated :) )

Gayan said...

@damned_7,

Little update!

Make sure to install the GRUB loader on the same HDD or the partition where you previously had it installed.

Because you have the separate 3 main partitions (boot/root/home) perhaps the installer failed to update the system properly in your last attempt (just a guess though).

And also don't worry about boot-repair only showing "Ubuntu" since it only shows the currently running OS rather than the all installed operating systems.

Anonymous said...

i have installed ubuntu 11.04 inside windows. it was working fine for few days after installing necessary updates for it now it can not boot ubuntu 11.04 without help of usb boot disc. instead it shows only black screen with grub command prompt. help me out cannt always use my usb drive!!!

Gayan said...

@Anonymous,

Well, thanks to you I just realized that A new version of Boot Repair is released which makes the whole process so much easier!.

Just boot to an Ubuntu liveCD/USB disk environment and simply install the app using the commands given in the post. Then press "Alt" + "F2" keys and enter the below command

boot-repair

After few seconds, you should see a window with two options and from that choose "Recommended Repair" which should solve most of the GRUB related issue...

Restart your PC and if you're lucky, the GRUB should be fixed... if you want more additional options then click the "advanced" button but if you don't know what you're doing, better stick with the above mentioned "Recommended repair" option... good luck.

Gints said...

Thank You!
This saved me a lot of effort.
In my case Samsung N145 I mistakenly chose Vista recovery option in boot menu and then I just could not wait for it to finish and just turned off the notebook. After that boot menu wasn't loading. This brilliant tool saved it.
Thanks again!

Gayan said...

@Gints,

You are welcome :).

Sanchit said...

I have my Ubuntu installed on C: partition with no other OS(on C:). Now when I boot Ubuntu a black screen comes with gurb cmd promt. Can you please help me out......

zombie said...

Thanks, Just upgraded from 11.04 to 11.10 and Grub2 wouldn't load. I tried manually re-installing grub to no avail, but boot-repair worked perfectly with no effort. thanks again :)

Gayan said...

@zombie,

Nice to hear it worked out for you, lol :).

Gayan said...

@Sanchit,

Well, recently the boot repair team released a new version that comes with a lot of features ... you can read my new post from here

http://mygeekopinions.blogspot.com/2011/09/boot-repair-tool-for-ubuntu-is-updated.html

But concerning your problem, as always, boot-into using LiveCD and install the application and then simply press "Recommended Repair" which should fix your situation.

Anonymous said...

alrightttttt finally some1 knows something about linux and boot loaders. hmmmmmmmmmmm how come they tell you to google and it takes days to get to this page?? you rock my friend.

kindest regards

ben

Gayan said...

@Ben,

Apart from the small income from the ads on this blog ;-) ... "small" appreciations likes these just make my day friend. Ben, you are welcome :D.

Anonymous said...

Thank you thank you thank you! You're such a saver <3

Gayan said...

@Anonymous,

The pleasure is all mine :).

Anonymous said...

I used this information this morning to rescue my blunder with StartUp-Manager tool. I had it booting into Memtest accidentally as I was trying to steer my GRUB away from the 3.0.0.13 Kernel. My Lenovo w520 doesn't play nice at boot time with the upgrade. 2.6.38 is what works for me. What a mess. Your post was most helpful and easy to follow. I'm a linux enthusiast and folks like you make it possible for everyone to enjoy Linux if they are just willing to "look into it" when they have a problem. Thanks much

Gayan said...

@Anonymous,

Thank you, you're most welcome! :D.

..::MANORANJAN::.. said...

dear friend i'm using both win7 and ubuntu 11.10.to day lost my grub now automatic boot only win7 not show any grub menu and not boot ubuntu plz help friend .urgent b,coz now i'm only use win7 i want both os and don't want to re install ubuntu agn b,coz i installed very good software in ubuntu .plz help me how to back my ubuntu (bgub menu)

Gayan said...

@MASTER MANORANJAN,

First use your Ubuntu LiveCD or USB, etc to boot into a Ubuntu Live desktop. Then install Boot-repair using the method described in the post.

Then open boot-repair and from its main window under the "Main options" tab make sure the following settins are activated/selected.

*. Reinstall GRUB

*. Unhide boot menu

*. Repair file systems

These are selected by defalult.

And then simply click on the "Apply" button to your right-bottom. That should re-install the GRUB in most cases with your previous boot-menu and your problem should be solved (again most of the time).

I've written a bit updated post about Boot-repair and some of its new features which you can read from the below link as well.

http://mygeekopinions.blogspot.com/2011/09/boot-repair-tool-for-ubuntu-is-updated.html

Good luck.

Yann said...

Please update this article:
- the package to install is not "boot-repair-ubuntu", but "boot-repair".
- screenshots are obsolete

Up-to-date informations are on https://help.ubuntu.com/community/Boot-Repair

Gayan said...

@Yann,

Thanks mate, I updated the post (including the other one) and included a link to the new Ubuntu help page as well. Awesome tool btw! :D.

Yann said...

Thanks Gayan!

(by-the-way, you can also update the title: Boot-Repair is available for any Ubuntu version, currently from 10.04 to 12.04 ! )

Gayan said...

@Yann,

You are welcome :).

I guess I'd keep the title just for now (traffic purposes, etc ;-) ). But will change it in the near future though, lol.

Anonymous said...

hello friend, i am using ubuntu 11.04 and i am having trouble with install/remove package from ubuntu software center due to some boot-repair problems...and also i checked for the exact problem using command "dpkg --configure -a" as a root-user and i am getting error as like below:

dpkg: dependency problems prevent configuration of boot-repair:
boot-repair depends on clean-gui; however:
Package clean-gui is not installed.
dpkg: error processing boot-repair (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
boot-repair

So, please help me out to solve this problem.

Thanks & Regards,
Raj

Gayan said...

@Anonymous,

ell "clean-gui" is automatically installed with "boot-repair". But I'm guessing is that perhaps you were trying to install it while "YannUbuntu" (the developer) was updating his PPA.

Try installing boot-repair after sometime (few mins or an hour for instance).

As long as you've added the boot-repair PPA to Ubuntu these packages should be automatically installed. So as far as I know there's very little we can do about it.

But you can try to install it manually by using the below command (the boot-repair PPA must be added to Ubuntu first)

sudo apt-get install clean-gui

If this succeeds, then put the boot-repair installation command (as shown in the article) and try proceeding.

If this is simply some other issue (bug or something beyond my knowledge) then you might wanna go to the below link (PPA of boot-repair) and have a loot at "Bugs" and "Answers" tabs or you can put together a question yourself as well.

Perhaps someone is having the same issues and who knows you might find your answer there if waiting few mins doesn't work. Good luck.

Here's the link = https://launchpad.net/~yannubuntu

Neeraj said...

http://paste.ubuntu.com/795741/


I made a live usb to install ubuntu-10.04.3-desktop-i386 using
Universal-USB-Installer-1.8.7.6. I ran it, and clicked on install
inside windows. After some processing, I was given an option to reboot
my pc either now or later. I clicked on later, and when I rebooted, I
didn't have an option to go to Ubuntu.

I installed boot repair via terminal method as given on
https://help.ubuntu.com/community/Boot-Repair

Then a clicked on recommended repair. It did its work, but when I
rebooted, I still don't have an option to boot into ubuntu.
Boot-repair displayed the link http://paste.ubuntu.com/795741/

Gayan said...

@Neeraj,

Well, as far as I know the Wubi (the installer that installs Ubuntu inside Windows file system) Ubuntu installer does not use GRUB. Instead it edits the existing MS Windows "boot.ini" file (and I've never tried that myself either).

So I don't think there's anything that Boot-repair can do here since there's no GRUB to begin with.

The best thing that you can do now is to uninstall the Ubuntu installation and try doing a re-installation.

If that doesn't still work and you'd wanna install Ubuntu, then I humbly advice you to install it the standard way (having a separate partition, with GRUB, etc) which should work almost all the time.

Good luck.

PS: You can find more about Wubi installer from the below links as well ...

https://help.ubuntu.com/community/Wubi

https://wiki.ubuntu.com/WubiGuide

Anonymous said...

12-01-2012
Deleted an Ubuntu install and had Grub errors.
This worked like a charm!! Many thanks!

Gayan said...

@Anonymous,

You are welcome.

Anonymous said...

WOW! This worked PERFECTLY! I just finished a triple-boot (Lubuntu 11.04, Mint 11 LXDE, and CrunchBang Statler) on my Asus 1215, then did a little bit of resizing with gParted. I don't know what I did wrong, but I got the No Partition error. ~PANIC~ Discovered and downloaded Boot Repair ISO on my desktop machine, created a bootable version with UNetbootin. Fired it up on the Asus, clicked the first button "Recommended Repair", and moments later, I got my triple-boot Asus back...like nothing ever happened. Great tool!

Gayan said...

@Anonymous,

"Great tool!" ... I know! :D. lol.

Anonymous said...

While trying to format a flash drive, I rushed into using some commands (dd if=/dev/zero of=/dev/sda).I was not sure if it was working, so I forced kill the terminal window before logging off. When I tried to boot my laptop later, I get a message that no boot sector found.

Is it possible to fix it, if not then is it possible to get my data from the disk

Gayan said...

@ Anonymous,

Well, unlike in the past, in recent versions of GNU/Linux, the "sda" refers to your HDD rather than the Flash drive (flash drive is referred using the "sdb" device name, by default).

So I think that, "dd" has erased the MBR of your HDD rather than of the USB drive.

And I think, yes, you could use "Boot-Repair" tool as explained in the article to fix it.

Chris K said...

Thanks for the article! Previously, I just use ms-sys, however, it is no longer in the repos for ubuntu!!! My last live usb for fixing Windows MBR was probably 10.04, so I'm not sure when ubuntu stopped ms-sys.

Anyhow, thanks so much. This is needed when I "reflash" a new HDD onto a computer... I just dd file contents and fix the MBR and on with life.

Gayan said...

@CK,

No problemo :)

Anonymous said...

Thank you so much for this. This article saved me when I accidently deleted my grub partition, a day before starting a new job..

I used a Ubuntu live usb to do this. Just wondering is there anyway to "save" the bootrepair app to the USB so it can be used again without connecting to the internet to redownload it?

Thanks again.

Gayan said...

@Anonymous,

You are welcome.

Anonymous said...

Great article! I just followed the steps, ran the boot repair wizard, and the computer started up again perfectly! Looks like it was a simple case of an update corrupting the boot loader. Thanks a million!

Gayan said...

@Anonymous,

I'm glad you found it useful!.

hfrankjr said...

My system is a laptop running windows 7 as the host for virtualbox with ubuntu 11.10 as the guest. Almost as soon as I click Start in vbox manager memtest starts up and I'm dead in the water. How can I access grub in this situation to repair it? I think memtest got started when I did a kernal change in startup manager.

Gayan said...

@hfrankjr,

Well, I'm not an expert on Virtualization, so cannot say much friend. Sorry about that :).

Paresh said...

I use Ubuntu on my apple Macbook Pro. I've been using Ubuntu 9.04 for years and loving it. It sounds like today I need to reinstall GRUB though. Here is my description of the problem:

My MBP is set up with rEFIt, so when you boot up it first goes to the rEFIt menu screen where you select OSX or Linux. If you select Linux (which I do 99% of the time), it then goes to the standard GRUB menu screen, where upon selecting Ubuntu (the only OS set up there), it boots up into Ubuntu. This morning out of the blue when I boot up and select Linux at the rEFIt screen, it acts as though a GRUB menu screen is about to appear. But instead of that, it just gives a black screen with the words "GRUB" appearing in the upper left hand corner of the screen. So I am guessing that perhaps GRUB became corrupted somehow. What do I have to do to get GRUB working again? (This is urgent-- I can't do any of my work until GRUB works, so I can get into Ubuntu.) Thank you!

A SImple Man said...

I thought my little HP Mini was dead. I would only boot into mem test and stay there. It sat collecting dust then I trew in a liveusb and it booted from that so I new it was software and not hardware. I found your site using duckduckgo. Spent a few minute ad my little netbook is alive again and no lost data or need to reinstall. Thank You!

Gayan said...

@A Simple Man,

You're welcome.

Anonymous said...

Thanks for this article, Gayan !
I have been spending a day trying to get grub installed on a 4K sector disk, after migrating and aligning partitions from a 512byte sector disk.
Boot-repair solved it all instantly, saving me from a fatal headache....

Gayan said...

@Anonymous,

You're welcome (sorry about the late response).

Post a Comment