LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices

Reply
 
Search this Thread
Old 12-26-2007, 10:23 PM   #1
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Rep: Reputation: 31
Help on potential loss of the MBR by an OS re-install!!


Hi to all,

I have Win XP, FC5 with default kernel, and FC5 with a kernel of 2.6.20.4 my machine in my grub menu. The MBR is installed on the Win XP partition.

I'm having problems to boot in my Win XP but I can boot in my 2 Linux options. I will have to reinstall WinXP on the WinXP partiton and this will surely overwrite the current MBR. Then after I boot the PC, I will no longer find the Linux partitions.

How can I prevent this from happening? Do I have to backup the MBR before re-installing WinXP? how do we do the backup? Or do I overwrite the MBR and then use Linux rescure mode to retrieve the Linux partitions?

Can s.o please detail a procedure which I can follow to get this done?

Warm regards,
Visham
 
Old 12-26-2007, 11:57 PM   #2
xode
Member
 
Registered: Aug 2003
Distribution: Mandrake 9.0; FC4; FC8; SUSE 10.3; SUSE 12.1
Posts: 551
Blog Entries: 1

Rep: Reputation: 45
My understanding is that the MBR is the very first sector on the hard drive (i.e. track 0, head 0, sector 1). The typical method that I use to retrieve and save that sector is using debug on a bootable MSDOS floppy disk. However, what I sense that you want to backup is a whole lot more than just the MBR.
 
Old 12-27-2007, 12:30 AM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Unless you deleted the partition that had XP on it, you don't need to reinstall.
Code:
title openSUSE 10.3 - 2.6.22.13-0.3
    root (hd0,5)
    kernel /boot/vmlinuz-2.6.22.13-0.3-default root=/dev/disk/by-id/scsi-SATA_FUJITSU_MHU2100_NQ07T4825B7P-part6 vga=0x317 nolapic resume=/dev/sda2 splash=silent showopts
    initrd /boot/initrd-2.6.22.13-0.3-default

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 10.3 - 2.6.22.13-0.3
    root (hd0,5)
    kernel /boot/vmlinuz-2.6.22.13-0.3-default root=/dev/disk/by-id/scsi-SATA_FUJITSU_MHU2100_NQ07T4825B7P-part6 vga=normal showopts ide=nodma apm=off acpi=off noresume edd=off 3
    initrd /boot/initrd-2.6.22.13-0.3-default

###Don't change this comment - YaST2 identifier: Original name: windows###
title Windows
    rootnoverify (hd0,5)
    chainloader (hd0,0)+1
Here is an example of my laptop's /boot/grub/menu.lst file. The last stanza is for booting windows. The device after "rootnoverify" may be different in your case. Look at the root (hdX,X) entry in your Linux stanza and use the same value for the Windows stanza. You can also enter these lines in the grub shell when you boot to test if it will work.
 
Old 12-27-2007, 10:58 PM   #4
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
Hi to all,

My grub.conf looks like this:
Quote:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,2)
# kernel /boot/vmlinuz-version ro root=/dev/hda3
# initrd /boot/initrd-version.img
#boot=/dev/hda
default=2
timeout=5
splashimage=(hd0,2)/boot/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.20.4)
root (hd0,2)
kernel /boot/vmlinuz-2.6.20.4 ro root=LABEL=/1 rhgb quiet
initrd /boot/initrd-2.6.20.4.img
title Fedora Core (2.6.15-1.2054_FC5smp)
root (hd0,2)
kernel /boot/vmlinuz-2.6.15-1.2054_FC5smp ro root=LABEL=/1 rhgb quiet
initrd /boot/initrd-2.6.15-1.2054_FC5smp.img
title Other
rootnoverify (hd0,0)
chainloader +1
I dont want to lose the grub menu that I get upon booting, nor my Linux partitions.

If I re-install Win XP on my primary partition, I will lose the grub menu, and hence I wont be able to see and boot into my Linux partitions. How can I prevent that from happening?

Warm regards,
Visham
 
Old 12-27-2007, 11:17 PM   #5
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 114Reputation: 114
You can't.

WinXP WILL rewrite the MBR on the hard drive.

If you are making no changes to partition structure on the drive, and no changes to your Linux installation, then the quickest and easiest thing to do is to make a copy of your MBR using the dd command.

Then after reinstalling Windows (why do you want to do that anyway? It is seldom necessary) you write the saved copy of the MBR back to the master boot record of the disk using dd. You will have to run a Linux Live CD or a Linux repair disk to do this, of course.

To copy the MBR, assuming your drive is sda, do this:

dd if=/dev/sda of=mybootimg.img bs=512 count=1

Then, to restore the mbr after reinstalling windows, do this:

dd if=mybootimg.img of=/dev/sda bs=512 count=1

And Bob's your uncle!
 
Old 12-28-2007, 11:21 AM   #6
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
Quote:
WinXP WILL rewrite the MBR on the hard drive.
Exactly..that's wat I fear will happen.

Quote:
Then after reinstalling Windows (why do you want to do that anyway? It is seldom necessary)
Well in my case, I'm unable to boot in Windows..Each time I try the machine restarts
(maybe some corrupt files). I'm unable to repair or overwrite it as well.

Quote:
To copy the MBR, assuming your drive is sda, do this:

dd if=/dev/sda of=mybootimg.img bs=512 count=1
So if we look at my grub.conf, it'll be hda instead of sda..


Thx for the suggestion..i'll try it staright away n come back to report wat happens.

Warm regards,
Visham
 
Old 12-29-2007, 11:41 AM   #7
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
Hi to all,

I no longer get the grub menu from which we can choose the we want to boot in. So I booted from my FC5 installation disk (disk 1) and then pressed F5 (rescue mode). Then I types "linux rescue" at the prompt.

I choose the options for language and keyboard, and didnt install networking.

At the prompt, I issue
Code:
chroot /mnt/sysimage
I get the following error:
Quote:
chroot: cannot change root directory to /mnt/sysimage: No such file or directory
How do I solve this?

Warm regards,
Visham
 
Old 12-30-2007, 10:48 AM   #8
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 114Reputation: 114
your rescue disk needs to be told to mount your drives and partitions. Otherwise it won't do it, and configures itself with a RAM-only installation. Alternatively, you mount your own drive using the mount command.

After you get your drives mounted, if you have more than one drive you will have to poke around a bit to make sure you know which drive is which in the rescue system. If you only have one drive, this point is moot.
 
Old 12-30-2007, 12:09 PM   #9
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
Hi to all,

jiml8's suggestion about mounting my drive worked..

many thx to all for their contribution..

I seize this opportunity to wish all of you a Happy New Year 2008 in advance.

Warm regards & best wishes,
Visham
 
Old 12-30-2007, 12:17 PM   #10
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 114Reputation: 114
so that means you have both restored your XP system and your MBR so that Linux boots properly?
 
  


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
Data loss(?) during re-install iscand Linux - Hardware 3 06-15-2007 04:19 AM
mbr after xp install jaymoney Ubuntu 5 09-13-2006 11:26 AM
Install and MBR Kanon Red Hat 8 03-05-2006 12:28 PM
how to install MBR? mrgrieves Linux - Software 4 05-17-2004 12:11 AM
alsa-utils lsubsequent loss of sound after install gjmwalsh Mandriva 1 08-24-2003 06:10 PM


All times are GMT -5. The time now is 06:54 PM.

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