[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Fix for the XP dual boot problem

Like other people on this list I was affected by the bug which makes the
XP partition in a dual boot configuration inaccessible after installing
Fedora. Below are the steps I used to restore the partition table to its
original configuration.

Some people mentioned a fix that involved setting the hard disk
configuration to LBA in the BIOS, but that may not work in some cases (I
have an old IBM Thinkpad which does not allow it).

By looking at the partition information as printed by fdisk after the
partition is corrupted, it seems that the bug affects only the C/H/S
values, the LBA are still correct. Even the fdisk manual specifies that
"DOS uses C/H/S only, Windows uses both [C/H/S and LBA], Linux never uses
C/H/S". This means that the correct information is still there but just
one copy is correct, the LBA one (most people affected said they could
access the Windows partition from Linux just fine). The procedure below
attempts to regenerate the MBR from scratch using the LBA values. In most
cases the original disk geometry had 255 (or 240) as number of heads
initially and was changed to 16 after the partition was corrupted by FC2.

More info about the bug can be found here:

This did work for me. I don't guarantee it will work for everyone, use it
at your own risk...

You need a bootable Linux CD (e.g. Knoppix) and a DOS system disk with
fdisk on it.
Here are the steps I followed:

1. boot from Knoppix or other bootable Linux CD (using the Fedora rescue
CD or booting in the newly installed system in single mode, ro mounted
may work too, but I haven't tried)

2. save the content of the MBR (and possibly all the boot sectors from
the partitions). This is important in case something goes wrong and you
want to restore later:
 $ dd if=/dev/hda of=mbr.img bs=512 count=1

3. run fdisk, go into expert mode and write down (or save into a file)
the starting sector (NOT block), end sector and type for each partition
(example below):
 $ fdisk /dev/hda
 Command: u (change units to sectors)
 Command: p (print)
 Example output:

   Device Boot      Start         End      Blocks   Id  System
 /dev/hda1   *          63    33732719    16866328+   7  HPFS/NTFS
 /dev/hda2        74692800    78140159     1723680   1c  Hidden W95 FAT32
 /dev/hda3        35834400    74692799    19429200   83  Linux
 /dev/hda4        33732720    35834399     1050840   82  Linux swap

4. completely erase the MBR by writing zeros to it (you may skip this
step, I am not sure if it is really needed, but this way it worked for
 $ dd if=/dev/zero of=zero.img bs=512 count=1
 $ dd if=zero.img of=/dev/hda

5. force the original number of heads. In my case (20Gb in a Thinkpad)
this was 240, but in most other cases it would be 255. See this post for
more info:


Using fdisk this will also create a new DOS partition table and restore
the original partitions:

 $ fdisk -H 255 /dev/hda               # or 240 for some configurations
 Command: o (create new partition table)

6. by now you have a newly generaed partition table, with the original
disk geometry. Recreate the partitions as they were before:

 Command: n (new partition)
 Primary partition (p)
 Partition number: 1
 First cylinder: 63                      # beginning of first partition
 Last cylinder or +size[...]: 33732719   # end of first partition

 Command: t (change type)
 Partition number: 1
 Hex code: 07                            # they type of the partition

Repeat for all 4 partitions. Verify at the end that the start/end/id are

 Command: p (print)

If everything is correct, write the partition table to the disk and exit:

 Command: w (write)
 Command: q (quit)

7. in my case, I had to run an extra "fdisk /mbr" using the DOS bootdisk
(may work with a XP installation CD too, but I haven't tried). After
that, everything worked fine, the partition table was back to the
original configuration.

If you have the GRUB in the MBR, the "fdisk /mbr" will overwrite it so
you may want to restore it later (but use the Knoppix CD, not FC2,
otherwise you may end up where you started if the bug is in grub). On my
machine GRUB was installed in the Linux partition so it wasn't affected.

You can return to the original MBR at any time by writing the saved image
to the disk (in case this fix does not work for you) as long as you only
make changes to the MBR:

 $ fdisk if=mbr.img of=/dev/hda

This is it, I hope it works for others, if it does please let me know.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]