LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to reinstall GRUB to MBR? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-reinstall-grub-to-mbr-17338/)

Alinuxnoob 03-30-2002 01:31 AM

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?

linuxcool 03-30-2002 03:45 AM

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 .

greenhornet 03-30-2002 08:13 AM

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.

Alinuxnoob 04-02-2002 08:36 AM

REran /sbin/grub-install /dev/hda
 
Now when I boot I get the grub prompt... and Now I have no clue what to do.......

greenhornet 04-02-2002 06:39 PM

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 ;)

Alinuxnoob 04-03-2002 11:51 PM

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?

linuxcool 04-04-2002 04:35 AM

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.

Alinuxnoob 04-06-2002 11:00 AM

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

Alinuxnoob 04-06-2002 11:19 AM

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?

linuxcool 04-06-2002 06:44 PM

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.

Alinuxnoob 04-06-2002 08:56 PM

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?

linuxcool 04-06-2002 11:34 PM

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?

Alinuxnoob 04-07-2002 04:25 PM

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?

linuxcool 04-07-2002 05:44 PM

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.


All times are GMT -5. The time now is 08:28 PM.