LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-14-2005, 07:40 AM   #1
Oracbase
LQ Newbie
 
Registered: Aug 2005
Posts: 9

Rep: Reputation: 0
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
 
Old 11-14-2005, 07:46 AM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
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.
 
Old 11-14-2005, 11:49 AM   #3
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
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
 
Old 11-15-2005, 04:19 AM   #4
Oracbase
LQ Newbie
 
Registered: Aug 2005
Posts: 9

Original Poster
Rep: Reputation: 0
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
 
Old 11-15-2005, 05:00 AM   #5
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
Look using a Grub shell and root+setup statements are identical to doing a grub-install /dev/hda in bash shell.
 
Old 11-16-2005, 03:49 AM   #6
Oracbase
LQ Newbie
 
Registered: Aug 2005
Posts: 9

Original Poster
Rep: Reputation: 0
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
 
Old 11-16-2005, 05:27 AM   #7
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
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
 
Old 11-17-2005, 10:17 PM   #8
Oracbase
LQ Newbie
 
Registered: Aug 2005
Posts: 9

Original Poster
Rep: Reputation: 0
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
 
Old 11-18-2005, 02:25 AM   #9
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
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.
 
Old 11-18-2005, 08:43 PM   #10
tinybit
Member
 
Registered: Jul 2005
Location: China
Distribution: Mandriva
Posts: 84

Rep: Reputation: 15
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/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grub error 17, and wont reinstall using grub-install! chiefreborn Linux - General 6 06-06-2007 10:29 AM
reinstall windows, reinstall GRUB too? leupi Linux - Software 1 05-07-2005 10:50 AM
What will happen to GRUB if i reinstall windows? ksoma Linux - Software 7 02-04-2004 02:53 PM
Can't get rid of LILO or GRUB bootloaders to reinstall Windows on Laptop CorpChAoS Linux - Newbie 5 11-25-2003 01:23 AM
how to reinstall grub after a winxp installation? zovres Linux - Newbie 1 04-28-2003 09:17 PM


All times are GMT -5. The time now is 10:27 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration