LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to reinstall GRUB after WIndows installation (https://www.linuxquestions.org/questions/linux-software-2/how-to-reinstall-grub-after-windows-installation-383002/)

Oracbase 11-14-2005 07:40 AM

How to reinstall GRUB after WIndows installation
 
Hi there,

I wonder if anyone here knows how to reinstall GRUB after installing winXP.

My problem is, I have a dual boot machine (WinXP and CentOS Linux).
GRUB is configured to be the bootloader.

Recently, my XP got corrupted, so have to reinstall.
But I forgot to make a boot disk for linux.
XP and Linux are installed on different partitions.

So now, I have a fresh install of XP, but cant start linux as I think the MBR got over-written by windows boot loader.

I would like to use GRUB again as the boot loader.

Is there any possibility to install only GRUB so that I can access my original Linux again?

(PS. I have installed and configured a Database properly on my Linux, do not want to go thru the hassle to re-install Linux and DB again)

Please help.

Cheers
Oracbase

homey 11-14-2005 07:46 AM

Just boot up with CD#1 and type: linux rescue
or use a livecd which has grub.
There are a ton of posts here on what to do next. :)

saikee 11-14-2005 11:49 AM

The standard technique of rescuing a working but unbootable is to boot up a kernel, either from the Linux original CD or any Live CD, mount the Linux root partition, change root to it and do a

grub-intall /dev/hda

Oracbase 11-15-2005 04:19 AM

Hi there,

Thank you all for your help.

I found the exact steps to reload grub.

Like you said....
1) Bootup using CD1, into rescue mode

2) chroot /mnt/sysimage

(found the below detail steps in another thread, solution provided by user WhatsHisname)
3)Start grub:

>grub

grub>find /boot/grub/stage1

(it will return something like this)
grub>(hd0,5)


grub>root (hd0,5)

grub>setup(hd0)

grub>exit

viola! done.

Cheers
Oracbase

saikee 11-15-2005 05:00 AM

Look using a Grub shell and root+setup statements are identical to doing a grub-install /dev/hda in bash shell.

Oracbase 11-16-2005 03:49 AM

Hi Saikee,

Before executing the grub + root + setup statements, I did try grub-install /dev/hda.

However, since my kernel detected my HD as /dev/sda and also my Linux partition was on /dev/sda6, I have tried the following and was not really successful. Dont know for what reason, but the 2.6.x kernel detect SATA HD as /dev/sda.

grub-install /dev/sda

exit and reboot, nothing was changed, still bootup to WinXP

grub-install /dev/sda6

exit and reboot, got GRUB menu back again and can see my multi-boot menu. Choose Linux, boot ok. But if I choose WinXP from the menu, it can't boot to WinXP and the grub menu keep on repeating itself going back to the grub multiboot menu.

Anyway, thanks again for your input and assistance.

Cheers
Oracbase

saikee 11-16-2005 05:27 AM

Oracbase

Look you must be inside the Linux that you want to restore its boot loader first when issuing a grub-install because Grub fetches the information of the loaded Linux partition and put into the destination specified by you.

/dev/sda means go to MBR of 1st Sata
/dev/sda6 means inside the root partition of / if you have installed the root of the GNU/Linux there
/dev/fd0 means to put Grub into a bootable floppy.

The first and last alternative can boot the system directly. For the second choice the GNU/Linux cannot boot itself but can be "chainloaderable" by another boot loader, which can be XP'sNTldr, Lilo or another Grub.

I stated in my reply that you need to "change root" to it!

So if you boot up from a Live CD the complete instructions are

mkdir /mnt/sda6
mount /dev/sda6 /mnt/sda6
chroot /mnt/sda6
grub-install /dev/sda

If you do a grub-install from the Linux off the CD it wouldn't have the necessary files and if it has the partition reference would be nothing like sda6 so of course it wouldn't work.

Do you still have a problem?

If the answer is yes then do a fdisk -l and list its content

List Linux's /boot/grub/menu.lst too

Oracbase 11-17-2005 10:17 PM

Hi Saikee,

I did do a chroot /mnt/sysimage and was able to see my original / partition as /dev/sda6.

Appreciate your detail explaination here.

But I would prefer the grub + root + setup statements, since it worked for me.

Thanks for all the sharing.

Cheers
Oracbase

saikee 11-18-2005 02:25 AM

OK I am not here to impose whatever method a user should use to rescue a Linux. I tried to explain the steps and hope the user appreciate the commands.

Here are a few points for future reference

(1) The change root method works for all systems "including" a Linux with Lilo.

(2) You can make a bootable Grub floppy, unattacthed to a Linux, boot it up and type the same 2 lines of

grub>root (hd0,5) <-----Tell Grub the root of the partition you are interested is (hd0,5)

grub>setup(hd0) <------ Set up the Grub boot loader in (hd0) using root information obtained from above.

to get to where you are now.

tinybit 11-18-2005 08:43 PM

Try GRUB for DOS please. It is a cross-platform boot loader based on GNU GRUB. The GRUB.EXE can be started from DOS/Win9x; and GRLDR can be started from BOOT.INI of Windows NT/2K/XP/2003; and even more, the GRUB.EXE can be started from LINUX via the KEXEC tool.

By using GRUB.EXE or GRLDR, you don't have to touch your MBR. It is the safest way coexisting with DOS/Windows.

You needn't install GRUB for DOS. Just run GRUB.EXE from DOS, or append a line of "C:\GRLDR=START GRUB" into your BOOT.INI(restart and select the "START GRUB" menu item), that will do.

Download GRUB for DOS here: http://freshmeat.net/projects/grub4dos/


All times are GMT -5. The time now is 04:36 PM.