Loading...


bookmark - Restoring Grub Boot Loader

Restoring Grub Boot Loader

 
 Discussion by masterio with 20 Replies.
 Last Update: May 28, 2010, 10:10 pm
 
bookmark - Restoring Grub Boot Loader  
Quickly Post to Restoring Grub Boot Loader  w/o signup Share Info about Restoring Grub Boot Loader  using Facebook, Twitter etc. email your friend about Restoring Grub Boot Loader Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Hi guys,

Few days ago my friend ask me to reinstall Windows on his computer. The problem is he has dual OS, ubuntu linux(Dapper Drake) and Windows XP. If I reinstall the Windows the Grub loader on MBR will overwritten by Windows XP. i know after reinstalling Windows we cannot boot to Ubuntu.

I'm newbie, So my question is, How we restore the Grub Loader back? I've try to boot from ubuntu using Live CD mode. But I still confuse :) the step-by-step how to restore the grub.

Please help



Thanks! :D







   Wed Nov 15, 2006    Reply         

I'm not familiar with Ubuntu. I do this kind of things with Mandrake of Mandriva.
It should be the same kind of problem and the same solution on all distros, just try my way, it's not harmful as long as you do not clik "format the hard disk".
With Mandrake or Mandriva, and probably with Ubuntu, you boot on the first install CD (or on the install DVD), choose "install or update", then choose "update", it verifies a lot of things and you see "installing the bootloader". Choose to put the boot loader on your first disk, and everything should go fine.
Hope this helped.
Yordan






   Wed Nov 15, 2006    Reply         

You Have Two Options............

1) The Usual Way....
After Installing WindowsXP, Boot a Linux Rescue Disk and Re-Install Grub with the command. "grub-install"

read man grub for more info.

typically....

CODE


mount /dev/your_boot_partiton /boot
grub-install --root-directory /boot /dev/hda



2) The Easy, 733T haX0r Linux GuRu Way....

The Boot Sector is Stored on the first 512 Bytes of the physical Disk.

so... Backup your boot sector to a file like so...

CODE


dd if=/dev/hda of=/BootSectorBackup.bin bs=512 count=1


Copy the backup file to a floppy disk / whatever.

Install Windows XP.

Boot a Linux Rescue Disk.

then Copy your Origonal Boot Sector Over whatever Garbage WindowsXP put there with the command

CODE


dd if=/BootSectorBackup.bin of=/dev/hda bs=512 count=1




If at all in Doubt... Use Method 1..
If you Make a Mistake With Method 2, you can waye boodbye to your Partiton Table... File System, and look forward to a full re-partiton and re-format.

Good Luck.

   Wed Nov 15, 2006    Reply         


Hi qwijibow,

I have tried the first method but it seems the parameter is wrong because when I run

$ grub-install --root-directory /boot /dev/hda

the grub-install just return same as we only typed $ grub-install. When run the grub shell, I saw a few command (I think) that can be used to fix grub. Like "setup" or "install",

CODE


grub> help setup
setup: setup [--prefix=DIR] [--stage2=STAGE2_FILE] [--force-lba] INSTALL_DEVICE
[IMAGE_DEVICE]
Set up the installation of GRUB automatically. This command uses
the more flexible command "install" in the backend and installs
GRUB into the device INSTALL_DEVICE. If IMAGE_DEVICE is
specified, then find the GRUB images in the device IMAGE_DEVICE,
otherwise use the current "root device", which can be set by the
command "root". If you know that your BIOS should support LBA but
GRUB doesn't work in LBA mode, specify the option `--force-lba'.
If you install GRUB under the grub shell and you cannot unmount
the partition where GRUB images reside, specify the option
`--stage2' to tell GRUB the file name under your OS.

grub>


I'm still confuse about INSTALL_DEVICE.

CODE

grub> setup --prefix=/boot/grub --stage2=/boot/grub/stage2 (hd0,0)

Error 12: Invalid device requested

OR

grub> setup --prefix=/boot/grub --stage2=/boot/grub/stage2 /dev/hda

Error 11: Unrecognized device string


For method 2, I'll not do it because it's to danger and can make my partition table corrupt!. So, there is another way? :)

Thanks

   Wed Nov 15, 2006    Reply         

GRUB handles each partition as a number... so if I want to install it into the the MBR, usually it would be:

grub-install hd(0,0)


xboxrulz

   Wed Nov 15, 2006    Reply         

QUOTE (masterio)


Hi guys,

Few days ago my friend ask me to reinstall Windows on his computer. The problem is he has dual OS, ubuntu linux(Dapper Drake) and Windows XP. If I reinstall the Windows the Grub loader on MBR will overwritten by Windows XP. i know after reinstalling Windows we cannot boot to Ubuntu.

I'm newbie, So my question is, How we restore the Grub Loader back? I've try to boot from ubuntu using Live CD mode. But I still confuse :D the step-by-step how to restore the grub.

Please help
Thanks! ;)

Link: view Post: 91787


If you can boot from CD, simplest method is to mount linux partitions, then chroot to it, then run grub-install.
TIP: fdisk -l will display all partitions at all drives.

In general, for any distro, even you havn't live CD, restoring can be done in such steps:
1) Find any working linux sustem
2) Create GRUB boot floppy:
# cd /usr/share/grub/i386-pc
# dd if=stage1 of=/dev/fd0 bs=512 count=1
1+0 records in
1+0 records out
# dd if=stage2 of=/dev/fd0 bs=512 seek=1
153+1 records in
153+1 records out
3) Boot from that floppy, then (quote from GRUB info page):

Once started, GRUB will show the command-line interface (*note
Command-line interface:;). First, set the GRUB's "root device"(1)
(*note Installing GRUB natively-Footnote-1::) to the partition
containing the boot directory, like this:

grub> root (hd0,0)

If you are not sure which partition actually holds this directory,
use the command `find' (*note find::D, like this:

grub> find /boot/grub/stage1

This will search for the file name `/boot/grub/stage1' and show the
devices which contain the file.

Once you've set the root device correctly, run the command `setup'
(*note setup::D:

grub> setup (hd0)


For more information type info grub

   Fri Nov 17, 2006    Reply         


QUOTE (ignite)

If you can boot from CD, simplest method is to mount linux partitions, then chroot to it, then run grub-install.
TIP: fdisk -l will display all partitions at all drives.

In general, for any distro, even you havn't live CD, restoring can be done in such steps:
1) Find any working linux sustem
2) Create GRUB boot floppy:
# cd /usr/share/grub/i386-pc
# dd if=stage1 of=/dev/fd0 bs=512 count=1
1+0 records in
1+0 records out
# dd if=stage2 of=/dev/fd0 bs=512 seek=1
153+1 records in
153+1 records out
3) Boot from that floppy, then (quote from GRUB info page):

Once started, GRUB will show the command-line interface (*note
Command-line interface:;). First, set the GRUB's "root device"(1)
(*note Installing GRUB natively-Footnote-1::P to the partition
containing the boot directory, like this:

grub> root (hd0,0)

If you are not sure which partition actually holds this directory,
use the command `find' (*note find:;), like this:

grub> find /boot/grub/stage1

This will search for the file name `/boot/grub/stage1' and show the
devices which contain the file.

Once you've set the root device correctly, run the command `setup'
(*note setup:;):

grub> setup (hd0)
For more information type info grub
Link: view Post: 91958






The RHEL installer provides the GRUB boot loader, GRUB (the GRand Unified Boot-loader).

/boot/grub/grub/grub.conf has a format of global options followed by boot stanzas. Here is a sample grub.conf:


timeout=5
splashimage=(hd0,0) /grub/splash.xpm.gz
password --md5 $1$/iX9y$Bkskfdsd4443gnff
default=0
title Red Hat Enterprise Linux AS (2.6.9-648_EL)
root(hd0,1)
kernel /vmlinuz-2.6.9.EL ro root=/dev/VolGroup00/LogVol00

initrd /initrd-2.6.9-648.EL.img
title Windows XP Pro
rootnoverify (hd0,0)
chainloader +1


IF ggrub-install fails for some reason try the following:

1. type the command grub and press enter

2. type root (hd0,0)

3. type setup (hd0)

4. type quit



IF still problem occures, then reinstall the grub by

/sbin/grub-install /dev/hda or use these three commands:

Have a nice day

   Mon Feb 26, 2007    Reply         

QUOTE (abhay)

1. type the command grub and press enter

2. type root (hd0,0)

3. type setup (hd0)

4. type quit
Link: view Post: 98618


root(hd0,0) means partition where kernel is stored w.m. where /boot/ directory is stored
hd0 = first IDE disk, 0 means first partition on this disk - you can use tab key to show alternatives

setup(hd0) means where to install grub to MBR, on which disk - so in this case in the MBR on the first IDE disk

   Sat Mar 10, 2007    Reply         

Restoring Red Hat Enterprise Linux Boot Loader
Restoring Grub Boot Loader

Hi

I had dual boot system of windows xp and RHEL 3.0.After some days I have reinstalled XP.But now I want to get back RHEL 3.0 again.

How Can I restore Grub boot loader again?if I can restore the grub boot loader again,will it give me the option of selecting the operating system?

Please help me out...

-question by ruhul

   Tue Mar 4, 2008    Reply         

Dual Boot - Solaris 10 and Windows XP
Restoring Grub Boot Loader

Hi,
I installed solaris 10 first.Then I install windows xp in another partition.When I boot my system,there is no options for os choices.It directly goes to the windows xp ,how to get os choices menu.

Thanks in Advance.

By,
Ruban demel.

-reply by Ruban

   Thu Mar 13, 2008    Reply         

how to get my ubuntu back after windows xp installation?Restoring Grub Boot Loaderhi everyone!

this is rocky.

I am new to ubuntu. At first, I had ubuntu and swap files installed in the last two partitions. The next, I installed win xp in the first partition. And now, my ubuntu is gone! who is out there to help me?

-question by wraaquee

   Sun Apr 12, 2009    Reply         

dual booting: Fixing Grub Boot Loader after installing windowsRestoring Grub Boot Loader

If you already have linux installed and you install windows afterwards, I found this was the cleanest and easiest way to fix my grub boot loader if I had to reinstall windows and my boot loader disappeared.

TO FIX THE GRUB BOOT LOADER:1. Load a live CD2. Find where the linux partition is installed (/dev/sda4) $ fdisk -l3. Make a directory to mount the real root partition on $ sudo mkdir realroot4. Mount the linux partition in the real root folder so you can access the boot loader $ sudo mount /dev/sda4 realroot5. Use grub-install to redirect the real boot loader to the windows boot partition (the first part of the disk sector) $ grub-install --root-directory=realroot /dev/sda

-reply by KnogleMopwater

 

   Fri May 1, 2009    Reply         

It seems IRestoring Grub Boot Loader

Ok ,heres the long and short of it:

 I have this stupid anal obession of cleaning up things. I managed to make my windows xp go away from my boot loader. I have Mandriva 2009 spring editon. Of course loaded on the first past of my primary drive. I have a second drive on a seperate  IDE. It of course is  Windows XP.  So lately I have been going in to BIOS and just flipping the drives and it works fine. But I really want my windows back on the boot loader line of. 

dev/sdb1 isn't working I tried that on the add feature on the second page  of the boot loader in the boot loaders "menu" for lack of better word  and then tried loading it as a  "other os windos os" of course. I tried all the ones there and it still wouldn't boot. I tried it in root too  but I think I need more info for milling around in there.

I actually didn't blow out the linux, liunx safe boot or windows. I blew out the two files that came up after a few time booting up linux  i586 , I removed them from the loaders  menu.  Then added  "clean /tmp at boot" checked on the loaders  advanced section  on the first page of the menu.

I don't think I hurt or damaged any files in doing what I've done. Could someone help me figure this out? I just want my Boot laoder to recognized Windows and boot it according to my key stroke at time of boot. 

-question by an_ok_joe

   Fri Sep 18, 2009    Reply         

doesnt workRestoring Grub Boot Loader

all this is good I'm sure but when I boot instead of the command line being just grub> and waiting for me to enter a command its actually displaying grup rescue> and NONE of the commands listed above work... Any ideas for the grub rescue> command line?

   Sun Dec 27, 2009    Reply         

Thank youRestoring Grub Boot Loader

I'd like to thank KnogleMopwater very much for his informative and very simple how-to. Without that how-to, I would be utterly ****ed. Thank you very much. :D

 

<3

 

- Anonymous

   Sun Jan 10, 2010    Reply         

Dunno if u got this fixed yet or not but I had a similar issue and that should work, first boot to live cd then in terminalUse root account, on live cd no pass should be neededSu

then run grubGrub

In grub run the following

find /boot/grub/stage1

returns hd(0,5)
root (hd0,5)   note the space between 'root' and '(hd0...'

Setup (hd0)   use whatever number was given to you from the fist find command

Quit

   Wed Jan 13, 2010    Reply         

Fixing Grub missing

While other distributions install or run the fixmbr command to me - recover
mbr Windows XP, probably installed grub on the mbr will be lost. To
deal with this, use the following steps:

1. Prepare to enter the LiveCD distro keterminal, for example: using distributions
Kanotix.
2. Booting - it was the LiveCD, so that it can enter the distribution system
it. Open a terminal and then type grub command to enter the
grub console.

$ Grub
grub>

3. After entry into the main grub menu, type the following command, for
stage1 file information contained on your computer. Grub
stage1 file needs to - setup grub.

grub> find / boot / grub / stage1
(hd0, 4)
(hd0, 5)
(hd0, 6)

4. In the example above, detected three stage1 files contained in the system
tesebut. Grub is in the back is hidupakan contained Linux distribution
on the partition / dev / hda4 or (hd0, 4).

5. Next, well-located to grub stage1 files that have been detected and
want to use.
grub> root (hd0, 4)

6. Continue with installing grub to the mbr, and then exit the grub menu.

grub> setup (hd0)
grub> quit

note: command setup (hd0), can you replace with the command
setup (hdX, Y), where X is the disk, and Y is a disk partition
want to use grub.


Hopefully useful. ;)

   Sat Jan 16, 2010    Reply         

Finally A Simple SolutionRestoring Grub Boot Loader

iGuest thanks for that post and method to restore the grub. I've crawled all over the internet looking for the simple solution. Your instructions are succinct and to the point and it actually worked!!

Kudos to you for sharing that simple fix. I've wondered why I was having such a hard time trying to restore the grub in linux mint. A couple of times I've bitten the bullet and reinstalled in order to have my dual boot option restored.

Again...THANKS!

 

-reply by Spud

   Fri Dec 18, 2009    Reply         

access EISA configuration partition using grub if only xp OS is installedRestoring Grub Boot Loader

I want to run rescue and recovery partition in IBM thinkpad R52 which is having one partition in harddisk and which is accessible only by access ibm key. But now it is not working. Partition is existing. I want to take backup of data of that partition. How to get it . 

-question by geeta

   Tue Jan 19, 2010    Reply         

grub loaderRestoring Grub Boot Loader

HiI had dual boot system of windows xp and fedora.After someDays I have uninstalled fedora.But now I want to get back windows xp again.How Can I restore Grub boot loader again?Please help me out...

-question by sriharsha

 

   Wed Jul 28, 2010    Reply         

Stage1 not existRestoring Grub Boot Loader

I don't know why but wen I tryey the folowing commane

find / boot / grub / stage1

UBUNTU say:

ERROR 15 : File not found

and there is not Stage1 in grub directory so I can not recover that

how can I recover my UBUNTU grub now?

 

-reply by hassan=

   Fri May 28, 2010    Reply         

Quickly Post to Restoring Grub Boot Loader  w/o signup Share Info about Restoring Grub Boot Loader  using Facebook, Twitter etc. email your friend about Restoring Grub Boot Loader Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Similar Topics:

Bootloader Problem

my friends computer died some time ago and i installed ubuntu on it so that he could still use it a bit. to do this i had to partition the last part of the drive and install in there becasue he wanted to still be able to access his old windows files. they were fine but some system files had been del ...more

   26-Mar-2006    Reply         

Boot Screen Edit

I Installed Windows first and then SuSe linux on another partition. Now everytime i start my laptop, i get GRUB to load a selective boot screen of SuSe , that allows me to select : 1) SuSe Boot 2) Windows Boot 3) SuSe Safe Boot By default the select is made on s ...more

   06-Sep-2006    Reply         

Ubuntu 7.10 + Windows Xp Dual Boot

Ok so for a long time I had my dual boot working great, windows and ubuntu. But 2 days ago my windows required a wipe and clean install because of some issues, like it usually happens after 8 months. So I reinstalled windows, well, first deleted the windows partition using the windows X ...more

   27-Mar-2008    Reply         

Problem With Fedora Core 5 Installation In fact after installation.....   Problem With Fedora Core 5 Installation In fact after installation..... (14) (2) Ssh Tips Some usefull SSH tips  Ssh Tips Some usefull SSH tips