# Restore Windows XP MBR...



## helpneeded!

OK, I know that you can boot from XP and use fix mbr to restore the orignal boot record.

But say, for example, you have:

1 XP, 3 Linux OS's
and you want to remove the 2nd Linux one; if you use fix mbr - that will only recognise the windows partition... so u lost the other 2 Linux distros you wanted to keep!

so how do you go about removing 1 Linux distro from the MBR whilst mainting integrity of it!?


I think you have to do it from Linux distro before u delete it by:

lilo -u
grub -u

?


Advice is apprecaited

Thanks


----------



## Squashman

Is your bootloader Grub or Lilo. Just edit the appropriate Conf file for either one of them.


----------



## helpneeded!

grub - 

cool - so if I edit the .conf file I can choose what OS's to show at the boot!?

Is this the normal method of doing it in Linux (noooooooob  )


----------



## saikee

Edit /boot/grub/menu.lst of the Linux you have selected to take over the MBR.

Just put "#" in front of the relevant lines for the Linux you don't want to see.

A cooler method is to install a new distro on the unwanted partition.

My last link of the signature documents the restoration of Windows MBR, Lilo or Grub.


----------



## lotuseclat79

Hi saikee,

I have saved the MBRs of my dual-boot Linux and WinXP Pro SP2 (each on separate disks) with the use of the dd command on my Linux machine as follows:

dd if=/dev/sdb of=sdbmbr bs=512 count=1 # to save the Linux disk MBR
dd if=/dev/sda of=sdambr bs=512 count=1 # to save the WinXP Pro SP2 MBR

Since the grub boot loader is contained in the WinXP Pro SP2 disk (hd0), when I attempt a WinXP Pro SP2 Repair Install from the orginal OEM CD and then reinstall the Windows updates applied since the initial installation - will the Linux MBR or grub boot loader be lost? How can I insure that it will not be touched?

If either the Linux MBR or grub boot loader were lost because of the WinXP Repair install, if I write the saved original MBR files to a CD-RW disc from Linux before attempting the Repair Install - and only the WinXP Pro SP2 were bootable after the Repair Install is there a way to write back the original MBRs to both disks from WinXP Pro SP2 to correct the situation? Would that correct the situation as posed or would it not work?

Case 1: If grub boot loader is lost (on the WinXP Pro SP2 disk) as a consequence of the XP Repair Install, how do I get it back without mucking up the XP Repair Install, or insure that it is not mucked up by the XP Repair Install?

Case 2: If the grub boot loader is not lost, but the Linux MBR boot information (hd1) is munged for some reason, how do I repair it from WinXP Pro SP2?

Note: I only have a 56k dial-up so download of a 700MB Live CD from Knoppix or Ubuntu is not practical. I have seen the Ubuntu will send you a Live CD for free, but it takes 4-6 weeks which is longer than I really want to wait. Also, my WinXP Pro SP2 is NTFS formatted, and I will not be changing it so I don't lose any data otherwise during the Repair Install.

Tia,

-- Tom


----------



## saikee

lotuseclat79,

Linux is a lot easier to be rescued and so its boot loader too, be it a Grub or a Lilo.

For both Case 1 & 2 you can boot up any Live CD, say one you pick up from a Linux magazine, make a temporary directory in its /mnt, mount the Linux you want to rescue and change root into it. Thereafter you will be inside that Linux.

To restore its boot loader back into the MBR just issue at the root terminal the command


Code:


grub-install /dev/sda

Let say the Linux in sdb1 has been lost after you restore Windows MBR and yopu want it back. The step in root terminal (type su first to become the superuser or root first as you need root privilege for altering the system files) after booting to a Live Cd are


Code:


mkdir /mnt/temp
mount /dev/sdb1 /mnt/temp
chroot /mnt/temp
grub-install /dev/sda
exit
reboot

In place of the grub-install command you can also achieve the same result by activating a Grub shell by


Code:


grub
root (hd1,0)
setup (hd0)

The idea being you tell Grub what is the "root" of the Linux first and instruct Grub to install that boot loader into the first bootable disk, which is sda in Linux term or (hd0) in Grub term.

The Grub shell is more robust and seldom fails whereas the "grub-install" Linux command can be temperamental in some situations.

If you have not restore the Windows MBR yet and still have the Linux working then you can also save the boot loader into a floppy by 


Code:


grub-install /dev/fd0

Equally in a Grub shell you do the setup with device fd0


Code:


setup (fd0)

This floppy provide a full HD-version of the boot loader and has more than just the first 512 bytes of the MBR you have saved in your post #5


----------

