Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 08-27-2005, 08:51 AM   #1
Registered: Apr 2004
Posts: 120

Rep: Reputation: 15
write grub to the MBR

Hi all,

I had an erratic behavior from my system lately (debian "testing") after upgrading all the packages, I had a kernel panic message at boot and thus was stuck.
After fiddling a bit, I did a new fresh debian install that detected my old system and by some luck was able to boot my old system without the panic message once I added the intird option in the menu.lst of the new system next to the old kernel entry (and then giving the initrd image as parameter of course).
Now, I'd like to reinstall the old system's grub in the MBR (I added the initrd line in it) but have no idea how. Updare-grub does not seem to be doing the job (at least it doesn't say so in the man page).
Can anybody tell me what to do, please?
Old 08-27-2005, 09:54 AM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
If you know what partition the system is on it helps. You can actually use grub to help you find that.
So boot up into Linux and get to the grub tool with the command: grub
At the grub prompt use the following comands....
grub > find /sbin/init
That should get the available Linux partitions. For example, on my box .....
grub> find /sbin/init

Now, you use the partition for whichever distro you want to boot the grub menu from ....
grub> root (hd1,1)
Filesystem type is ext2fs, partition type 0x83

Now, you can tell grub to use the MBR with the command: setup (hd0)

grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
Running "install /boot/grub/stage1 d (hd0) (hd0)1+15 p (hd1,1)/boot/grub/stage2 /boot/
grub/grub.conf"... succeeded

Then exit the grub with this command:
grub> quit


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
GRUB MBR overwritten by WIN98 MBR TOuseef Linux - General 7 11-14-2004 04:25 PM
Lilo don't write on MBR clapton Slackware 7 10-11-2004 07:20 AM
Does LoadLin write to the MBR? jhecht Linux - Software 1 06-25-2004 10:50 AM
Can write GRUB at first sector of MBR invinciblemk Linux - Newbie 2 02-01-2004 08:59 PM
mbr had over write so lilo is gone how to rewrite lilo to mbr mch Linux - Software 4 10-25-2002 02:55 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:44 PM.

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