[ltp] how to restore original MBR and partition table

Igor V. Rafienko linux-thinkpad@linux-thinkpad.org
Fri, 11 May 2007 12:08:18 +0200 (CEST)


on May 10, 2007, 17:52, Joe Zien wrote:

[ ... ]

> I installed grub, the linux boot loader, in the MBR.


Why did you do *that*?

There is no reason to change the MBR. Leave it as it is, mark the 
partition with your /boot as the only active partition and install grub 
there. You and your windows installation would be much happier this way.


> I did not get a cd-rom for the Thinkpad with XP, there is a rescue and 
> restore partition on the hard drive that allows you to restore XP to 
> factory condition but that wipes out your whole hard drive including all 
> my linux partitions. I just want to restore the XP partition table and 
> MBR. Is that possible without wiping out the whole drive?


FWIW, on a T43 it looks like this:

* The R&R software (be it from the R&R partition or DVDs) will wipe out
   the first primary partition, the partition table and the MBR.
* If your linux installation is on the first partition, you are out of
   luck. The R&R wants what, at least around 8GB for the windows
   installation, and it will overwrite whatever occupies these 8GB at the
   start of the drive.
* The R&R DVDs will also wipe out the "end" of the drive, where the R&R
   partition should reside.
* Everything in between is *highly likely* not to be touched. Why highly
   likely? Well, because the R&R assumes that the entire drive is available
   for windows installation. If the process needs some scratch files,
   that's too bad for whatever gets overwritten. This did not happen to me
   the 3 times I restored win xp back.
* *BEFORE* doing any restoration, write down your partition table on a
   piece of paper. The partition table with linux/windows/whatever you have
   installed.
* Restore win xp from R&R. Once the process is complete, you'll have the
   laptop's partition table/mbr looking exactly as it did when it'd left
   the factory.
* Reboot from a rescue CD and do this:
   ** shrink the win xp ntfs
   ** re-create the partitions as they were before you started (naturally,
      do not shrink sda1 to less than whatever you've shrunk the ntfs to).
      That's where the piece of paper comes into play.
   ** mark whichever partition has your /boot as active. remove the active
      mark from all other partitions (sda1 will typically be active after
      R&R is done)
   ** install grub to whichever partition contains your /boot
   ** force file system check on all partitions. This is actually quite
      important.
* Reboot


> Using an XP cd-rom that I got for my tower, I tried to use the restore 
> function "fixboot" and "fixmbr" but I got error that it couldn't find 
> the c:\ drive.


There is an IBM-issued bootable image that fixes thinkpad's mbr. Check the 
thinkwiki.


> Now all I can use is linux, no great loss because I use mostly linux
> but I still want to use XP  for some programs that are not available
> for linux.


Indeed. Dual-booting works flawlessly here.


> The main question is can you restore the original partition table and 
> MBR without re-installing XP from the rescue and restore function on the 
> Thinkpad?


The original partition table -- not sure. MBR -- definitely. But I am 
*certain* that you do not want the original partition table, because 
*the original* partition table has 2 primary partitions -- sda1 (occupying 
most of the drive and meant to hold windows) and sda2 (at the very end of 
the drive, containing the 4GB R&R partition).





ivr
--