Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old April 5th, 2005   #1
vnbuddy2002
Gee! These Aren't Roasted!
 
Join Date: Apr 2005
Beans: 65
HOWTO: Restore GRUB (if your MBR is messed up)

Restore GRUB quite simple in Ubuntu, instead going through all the "gain root access" and play with shell commands, you can use the Ubuntu installation CD to restore it without going through all kinds of hassles.

Here are the steps:

1. Boot your computer up with Ubunto CD
2. Go through all the process until you reech "[!!!] Disk Partition"
3. Select Manual Partition
4. Mount your appropriate linux partions

/
/boot
swap
.....

5. DO NOT FORMAT THEM.
6. Finish the manual partition
7. Say "Yes" when it asks you to save the changes
8. It will give you errors saying that "the system couldn't install ....." after that
9. Ignore them, keep select "continue" until you get back to the Ubuntu installation menu
10. Jump to "Install Grub ...."
11. Once it is finished, just restart your computer

Good luck!.
vnbuddy2002 is offline   Reply With Quote
Old April 6th, 2005   #2
remmelt
Just Give Me the Beans!
 
Join Date: Jan 2005
Beans: 65
Re: HOWTO: Restore GRUB (if your MBR is messed up)

Isn't it easier to do this:

1. Pop in the Live CD, boot from it until you reach the desktop.
2. Open a terminal window or switch to a tty.
3. Type "grub"
4. Type "root (hd0,6)", or whatever your harddisk + boot partition numbers are (my /boot is at /dev/sda7, which translates to hd0,6 for grub).
5. Type "setup (hd0)", ot whatever your harddisk nr is.
6. Quit grub by typing "quit".
7. Reboot.

I may be missing your point though, if so, please forgive me

Quote:
Originally Posted by vnbuddy2002
Restore GRUB quite simple in Ubuntu, instead going through all the "gain root access" and play with shell commands, you can use the Ubuntu installation CD to restore it without going through all kinds of hassles.

Here are the steps:

1. Boot your computer up with Ubunto CD
2. Go through all the process until you reech "[!!!] Disk Partition"
3. Select Manual Partition
4. Mount your appropriate linux partions

/
/boot
swap
.....

5. DO NOT FORMAT THEM.
6. Finish the manual partition
7. Say "Yes" when it asks you to save the changes
8. It will give you errors saying that "the system couldn't install ....." after that
9. Ignore them, keep select "continue" until you get back to the Ubuntu installation menu
10. Jump to "Install Grub ...."
11. Once it is finished, just restart your computer

Good luck!.
remmelt is offline   Reply With Quote
Old April 6th, 2005   #3
vnbuddy2002
Gee! These Aren't Roasted!
 
Join Date: Apr 2005
Beans: 65
Re: HOWTO: Restore GRUB (if your MBR is messed up)

Your way is definately faster, but for newbies, many of them try to avoid command line as much as possible. That is why I brought up an alternative.
vnbuddy2002 is offline   Reply With Quote
Old April 6th, 2005   #4
Tomy
A Carafe of Ubuntu
 
Join Date: Oct 2004
Location: Alaska, USA
Beans: 113
Re: HOWTO: Restore GRUB (if your MBR is messed up)

Quote:
Originally Posted by vnbuddy2002
Your way is definately faster, but for newbies, many of them try to avoid command line as much as possible. That is why I brought up an alternative.
Hey thanks, I never thought of doing this. It worked great for me today.

Last time I messed up grub I used the Live CD method but did not write anything down so today I searched for "grub" and found this post. But I couldn't find a Live CD so I used your method with the Install CD.

Thanks
Tomy
Tomy is offline   Reply With Quote
Old April 8th, 2005   #5
wernst
Just Give Me the Beans!
 
Join Date: Feb 2005
Beans: 47
Re: HOWTO: Restore GRUB (if your MBR is messed up)

Don't forget that this method, as described, puts GRUB back on the MBR (master boot record) of the hard drive instead of in the root parititon. This is fine for most people, but not if you already have an alternative boot manager.

In other words, if you use something like Boot Magic or System Commander, the commands you've just read will overwrite what you've got.

If you've installed GRUB into the Root Partition instead of the MBR, the commands are a little different. Here's are the instructions that I have for my system:

How to Restore the Grub Menu after a Re-Ghosting:

1. Boot from a Live CD, like Ubuntu Live, Knoppix, Mepis, or similar.

2. Open a Terminal. Go SuperUser (that is, type "su"). Enter root passwords as necessary.

3. Type "grub" which makes a GRUB prompt appear.

4. Type "find /boot/grub/stage1". You'll get a response like "(hd0)" or in my case "(hd0,3)". Use whatever your computer spits out for the following lines.

5. Type "root (hd0,3)".

6. Type "setup (hd0,3)". This is key. Other instructions say to use "(hd0)", and that's fine if you want to write GRUB to the MBR. If you want to write it to your linux root partition, then you want the number after the comma, such as "(hd0,3)".

7. Type "quit".

8. Restart the system. Remove the bootable CD.

Hope this helps. Since I use Norton Ghost to make regular backups and restores (I do a lot of testing), I do this all the time...

-Warr
wernst is offline   Reply With Quote
Old May 12th, 2005   #6
rpakdel
First Cup of Ubuntu
 
Join Date: May 2005
Beans: 2
Re: HOWTO: Restore GRUB (if your MBR is messed up)

Here is another way:

1. Boot with any live CD (I've done it with Knoppix 3.x and Ubuntu)
2. Get a root shell and make a folder (mkdir ubuntu)
3. mount the root (/) partition of ubuntu (e.g. mount /dev/hdb ubuntu if you have two disks)
4. chroot the mounted partition (chroot ubuntu)
5. grub-install /dev/hda [1]
5. Exit the shell
6. Reboot

[1] Important: If you are multi-booting with Windows, make sure you do NOT install the MBR on the active partition (say /dev/hda1) but on the drive (/dev/hda). At least with Windows XP, you will have to re-install it (FIXMBR/FIXBOOT won't work).
rpakdel is offline   Reply With Quote
Old May 12th, 2005   #7
Heliode
A Carafe of Ubuntu
 
Heliode's Avatar
 
Join Date: Mar 2005
Beans: 143
Re: HOWTO: Restore GRUB (if your MBR is messed up)

Since all you need for these fixes is a command prompt, you don't need to load the GUI. For Knoppix I believe you type something like 'knoppix 3'. For the Ubuntu Live-cd I don't know. I'll edit this post when I figure it out.
__________________
"Windows is something to overcome"

Howto's by me:
Tweak firefox! (URL now works..)
Backup/Restore your system!
Avoid having to reboot


Compentux.org
, the Linux Tip & Howto gathering initiative!
Heliode is offline   Reply With Quote
Old June 10th, 2005   #8
H3AsO4
First Cup of Ubuntu
 
H3AsO4's Avatar
 
Join Date: Apr 2005
Beans: 3
Re: HOWTO: Restore GRUB (if your MBR is messed up)

at step 10, I encountered a problem: it asks you if you want to proceed when you click the Install Grub, and in all the previous steps, "yes" or "continue" was the correct response, at step 10, if you select "yes" the ubuntu disk will proceed and attempt to install ubuntu.... which will ruined my current install... ah well....

Quote:
Originally Posted by vnbuddy2002
Restore GRUB quite simple in Ubuntu, instead going through all the "gain root access" and play with shell commands, you can use the Ubuntu installation CD to restore it without going through all kinds of hassles.

Here are the steps:

1. Boot your computer up with Ubunto CD
2. Go through all the process until you reech "[!!!] Disk Partition"
3. Select Manual Partition
4. Mount your appropriate linux partions

/
/boot
swap
.....

5. DO NOT FORMAT THEM.
6. Finish the manual partition
7. Say "Yes" when it asks you to save the changes
8. It will give you errors saying that "the system couldn't install ....." after that
9. Ignore them, keep select "continue" until you get back to the Ubuntu installation menu
10. Jump to "Install Grub ...."
11. Once it is finished, just restart your computer

Good luck!.
H3AsO4 is offline   Reply With Quote
Old June 24th, 2005   #9
jsimmons
A Carafe of Ubuntu
 
jsimmons's Avatar
 
Join Date: Jun 2005
Location: Texas
Beans: 116
Re: HOWTO: Restore GRUB (if your MBR is messed up)

I currently have a mobile rack so that I can have Ubuntu on one drive, and Windows on another. When I need to change OS's, I turn off the system, swap drives, and turn it back on again. I've decided this is too much of a hassle (and not necessarily easy on the electronics).

I am going to install another SATA drive and I want to move my current Ubuntu install over to that drive (without having to reinstall Ubuntu), and then setup GRUB on my Windows drive so I can dual boot.

Will I experience any problems doing this? The reason I ask is because I'll be moving Ubuntu from /dev/hda to /dev/sdb, and I'm wondering if any OS-specific stuff cares about that kind of thing.


Should I just throw in the towel and reinstall Ubuntu from scratch on the new drive, or is what I want to do doable?
jsimmons is offline   Reply With Quote
Old August 24th, 2005   #10
Rikko
First Cup of Ubuntu
 
Join Date: Aug 2005
Beans: 7
Re: HOWTO: Restore GRUB (if your MBR is messed up)

Hi guys,
The problem I'm having is that Ubuntu installed GRUB onto /hdb1, but my primary partition (as far as my BIOS is concerned) is /sda1
I can run 'grub' and reinstall grub like described by remmelt, but I don't know what the ID of /sda1 is. (hd1,0)? (hd2,1)? What command can I use to get the mapping?
I'm able to boot off the Live CD only at the moment.
Rikko is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:53 AM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry