LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-30-2002, 02:31 AM   #1
Alinuxnoob
Member
 
Registered: Feb 2002
Location: Van city
Distribution: Ubuntu
Posts: 204

Rep: Reputation: 30
How to reinstall GRUB to MBR?


I need to reinstall my windows Parititon (Because Windows has too many problems and you always have to reinstall to fix it) and if I do this my grub file will be gone so I need to know how do you reinstall GRUB?
 
Old 03-30-2002, 04:45 AM   #2
linuxcool
LQ Addict
 
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
To reinstall grub run /sbin/grub-install /dev/hda. That will install grub into the mbr of the primary master drive ( hda ). Remember to make a boot disk so that you can boot back into linux after reinstalling windows. I got the info for reinstalling grub here .
 
Old 03-30-2002, 09:13 AM   #3
greenhornet
Member
 
Registered: Mar 2002
Location: Sydney, Australia
Distribution: RHEL, Fedora, Yellow Dog
Posts: 43

Rep: Reputation: 15
In Red Hat you can also boot with the install cdrom and select rescue mode. This will load a simple shell and you can install grub again.

Handy if you forgot to make a boot disk!

I assume other distros would have a rescue mode as well.
 
Old 04-02-2002, 09:36 AM   #4
Alinuxnoob
Member
 
Registered: Feb 2002
Location: Van city
Distribution: Ubuntu
Posts: 204

Original Poster
Rep: Reputation: 30
REran /sbin/grub-install /dev/hda

Now when I boot I get the grub prompt... and Now I have no clue what to do.......
 
Old 04-02-2002, 07:39 PM   #5
greenhornet
Member
 
Registered: Mar 2002
Location: Sydney, Australia
Distribution: RHEL, Fedora, Yellow Dog
Posts: 43

Rep: Reputation: 15
I'm not sure, I *think* this means it cant find your /etc/grub.conf

Use the rescue mode I described above and see what your /etc/grub.conf looks like?

Actually installing windows might have changed the label given to the partition that has /boot on it.

In the rescue mode try fdisk -l and check that whatever boot was (/dev/hda1 for instance) is still the case, otherwise update the /etc/grub.conf to reflect the change.

Let us know if I'm wrong or not here
 
Old 04-04-2002, 12:51 AM   #6
Alinuxnoob
Member
 
Registered: Feb 2002
Location: Van city
Distribution: Ubuntu
Posts: 204

Original Poster
Rep: Reputation: 30
OK I check the GRUB file and all the stuff that was listed before is still there? But what I did was I re install the grub on my kernel 2.4.17 cause none of the grub files was listed but is listed on my redhat kernel 2.4.9-39 so I never tried reinstall Windows YET......

HELP PLz what should I do now?
 
Old 04-04-2002, 05:35 AM   #7
linuxcool
LQ Addict
 
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
You might be able to get linux to boot up by passing some information to grub. It needs to know where its files are and where the kernel is located and the name of the kernel.

I'll use my system as an example. I don't have a separate /boot partition, so I'll tell grub where my root ' / ' partition is. If you have a separate /boot partition, tell grub what that partition is. My root partition is hda6. Grub calls that hd0,5. My kernel name is ' vmlinuz '. With this information, I can tell grub what it needs to boot linux.

I would run the following commands at the grub prompt:

root=(hd0,5)
kernel=/boot/vmlinuz root=/dev/hda6
boot


This worked for me when I tried it.
 
Old 04-06-2002, 12:00 PM   #8
Alinuxnoob
Member
 
Registered: Feb 2002
Location: Van city
Distribution: Ubuntu
Posts: 204

Original Poster
Rep: Reputation: 30
OK that worked but HOW do I get the grub screen to come on NOW? I mean I dont want to keep on typing this in each time I reboot my PC
 
Old 04-06-2002, 12:19 PM   #9
Alinuxnoob
Member
 
Registered: Feb 2002
Location: Van city
Distribution: Ubuntu
Posts: 204

Original Poster
Rep: Reputation: 30
I also found something in my etc/grub.conf file there is nothing inside it and also it is highlighted red and flashing what does this mean?
 
Old 04-06-2002, 07:44 PM   #10
linuxcool
LQ Addict
 
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
Great!!! Now let's see if we can get it to boot up completely.

To answer your last post, grub.conf is a symbolic link and the red flashing letters indicate that the link is broken.

First, you need to look into the /boot/grub folder and see if you see a file named menu.lst or grub.conf. The file will hold the configuration information that grub needs to boot. Once you find it, fix the broken link by first running rm /etc/grub.conf
and then running either
ln -s /boot/grub/menu.lst /etc/grub.conf
or
ln -s /boot/grub/grub.conf /etc/grub.conf

Now run grub in a terminal. Run the same root command that you used to boot into linux.
Ex.
root=(hd0,5)
Then run
setup (hd0)

The (hd0) part will install grub in your mbr. After running setup, it will print out some information. You'll need to copy from the line that looks something like this:
Run "install /boot/grub/stage1 d (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2"

The part you want is between the " ". ( install /boot/grub/stage1 d (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 ). Copy this to the command line and to the end of it add this: (hd?,?)/etc/grub.conf. It'll look like this:
install /boot/grub/stage1 d (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 (hd?,?)/etc/grub.conf

The question marks in the line are to be replaced by the same numbers you used in the root line that you used to boot linux. Then hit Enter to run the install command. Now, run quit and you're done installing grub. You'll want to check the contents of your menu.lst or grub.conf files to make sure the information is correct. If it is, then reboot.

Last edited by linuxcool; 04-06-2002 at 11:05 PM.
 
Old 04-06-2002, 09:56 PM   #11
Alinuxnoob
Member
 
Registered: Feb 2002
Location: Van city
Distribution: Ubuntu
Posts: 204

Original Poster
Rep: Reputation: 30
Ok I dont have a folder in etc/boot?
then i went and did part 1
rm /etc/grub.conf I remove my old grub.conf file
did part 2
ln -s /etc/boot/grub/menu.lst /etc/grub.conf
Part 3 didnt work
Then tells me Running "install /grub/stage1 d (hd0) (hd0)1+22 p (hd1,0) /grub/stage2 grub/grub.conf" "error 15 file not found"

This is from my grub.conf file when I use my rescue disk to look inside it

[B]root (hd1,0)[B]
kernel/vmlinuz-2.4.17 ro root=dev/hdb2 hdc=ide-scsi

What am I doing wrong?
 
Old 04-07-2002, 12:34 AM   #12
linuxcool
LQ Addict
 
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
OK. I noticed that I had made a mistake in my post. You were supposed to look in the /boot/grub folder. Look in there to see if the menu.lst or grub.conf file is in there.

From the information in your grub.conf file, is this how your system is set up? You have linux installed on the primary slave ( hdb ). Your root ' / ' partition is hdb2 and you have a separate /boot partition hdb1. Is this correct?

I need some information. What do the root and kernel lines look like that you type in to boot into linux? When you run ls /boot do you see a folder named grub? What is the complete path to your grub.conf file that you looked inside for the two lines listed in your last post? Does your grub.conf have only those two lines in it?

Last edited by linuxcool; 04-07-2002 at 12:37 AM.
 
Old 04-07-2002, 05:25 PM   #13
Alinuxnoob
Member
 
Registered: Feb 2002
Location: Van city
Distribution: Ubuntu
Posts: 204

Original Poster
Rep: Reputation: 30
Ok I get my grub to come up now. And I always could see the grub folder in boot but not if I boot into my kernel2.4.17 the red fashing grub.conf file was in the etc folder but I guess that worked cause I can get it to come up now. Thx

But for a reference how do you reinstall grub?

Last edited by Alinuxnoob; 04-07-2002 at 05:27 PM.
 
Old 04-07-2002, 06:44 PM   #14
linuxcool
LQ Addict
 
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
When you say that you got grub to come up, do you mean you got the splash screen to show up? Are you able to boot into windows?

The grub folder should be in the /boot folder. When you do an ls /boot/grub, you should see the grub files like stage1, stage2, and grub.conf. If grub.conf is there, you can fix the symbolic in the /etc folder. Do ls -l /etc/grub.conf. If it lists the file grub.conf, then run rm /etc/grub.conf and then run
ln -s /boot/grub/grub.conf /etc. That should fix the broken link.

To reinstall, boot up linux and then run:

grub
root=(hd?,?)
setup (hd?)
quit



The root= line needs to have the partition where grub's files are located. In my case, mine are on the root ' / ' partition. So, I would use hd0,5. Yours is on the separate /boot partition. So, you would use hd1,0. The setup line is where you tell it to install grub's boot loader. If you use hd0, that would put into the mbr of the primary master drive hda.

I don't know why when you boot using your kernel 2.4.17 you can't see the grub folder in the /boot folder.
 
  


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
mbr/grub reinstall walding Linux - Newbie 3 09-18-2005 10:00 AM
mbr reinstall, boot command darkangel29 Linux - Newbie 1 05-31-2005 12:02 AM
GRUB MBR overwritten by WIN98 MBR TOuseef Linux - General 7 11-14-2004 05:25 PM
reinstall GRUB to MBR w/o reinstalling Linux?? timsch75 Linux - Software 3 06-24-2004 07:36 PM
reinstall grub/lilo on MBR without cdrom boot lay_Z Linux - Newbie 5 03-12-2004 06:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:00 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration