Help on potential loss of the MBR by an OS re-install!!
FedoraThis forum is for the discussion of the Fedora Project.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
# 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?
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:
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.
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.