Navigate / search

How to reinstall the grub boot manager on Ubuntu Linux

My new Compaq CQ20 noteobook has a “recovery button” feature which I really haven’t gotten to checkout. The other day while setting up Ubuntu, I inadvertently pressed on the button which resulted to a “missing operating system” message when I got my notebook restarted. That recovery button should really be moved to a separate location or better yet have a disable feature option. I know that my data is still intact and that maybe the boot sector was the only area on the disk that was affected.

I took my Ubuntu Intrepid installer usb stick and booted it. Once Ubuntu was running, I checked my hard disk’s partition table using the program fdisk. I did the following on a terminal:

$ sudo -s# fdisk /dev/sda

After issuing the “p” command of fdisk, I found that my partition is still intact. This got me to thinking that my hard disk’s grub boot manager was the thing that was actually erased. I ran grub and restored my the boot sector. Here’s how I did it:

While still logged in as root, run grub.

# grub

If you know what the root for grub for your system is then key in the root command for grub. You should have something like the one below after the “grub>” prompt:

grub> root (hd0,1)

If you don’t know where it should be then let grub find it by:

grub> find /boot/grub/stage1

At last, now to install the grub boot manager:

grub> setup (hd0)

That’s it, you should now have your Grub boot manager back in the MBR.

Update: Adrimaxi posted a link below to Super Grub Disk — a menu driven way to restore your grub boot loader. Thanks Adrimaxi.

Gerry Ilagan

Gerry Ilagan is into mobile apps and WordPress development at @speeqs. He loves to write about electronics, the Internet of Things, mobile phones, and #crazyideas.

Comments

Adrimaxi
Reply

Why didn’t you used the supergrubdisk that does it automaticaly from either your usb thumb or a cd-r…
http://www.supergrubdisk.org/
It’s is so easy to recover your grub (or windows mbr) with no command lines.
Cdy,

Leave a Reply to AdrimaxiCancel reply

name*

email* (not published)

website