date : 21-12-2005
author : Erik Jan Jonkers
howto : reinstall Windows XP with existing linux installation
Intro
Once you had a new disk, you installed windowsXP and then you favorite linux distro.
Now, after a couple of months you have to reinstall XP because it just doesn't
do the things it should anymore. You slide in your XP install cd and wait,
but right after the message "Checking Hardware Configuration Please Wait.."
the screen goes black and nothing happens!
Here is a solution,
(I can't be held responsable when you lose your data.)
The problem is that XP tries to search for windows installations on your ext3/ext2
(linux) partitions. Off course it can't.
So this is what you have to do:
1. backup al your data, email, pictures of your ex-girlfriends
2. backup your master bootsector (the first 512 bytes of your disk)
3. backup your partition table
4. save your bootsector and partitiontable to a floppy or other computer
5. delete all partitions except the one which holds your XP installation
6. run your XP install
7. boot with linux rescue cd
8. restore your bootsector and partitiontable
9. cross your fingers and reboot
In more detail
1) backup your data
Use rsync or anything to copy your files to another host.
2) backup your bootsector
Become root on your linux system and do:
dd if=/dev/xxx of=bootsector bs=512 count=1
xxx = your harddrive, examples: hda or sda
save your bootsector to a floppy or scp to another host.
3) backup your partitiontable
Use sfdisk to get your partitiontable
sfdisk -d /dev/xxx > xxx.pt
save your partitiontable file to a floppy or scp to another host.
4) Oh, we already did this.
5) delete partitions
O.k, your XP installation is probably on the first primary partition,
so delete the rest. Use fdisk to do this.
Example:
This is my partitiontable:
[root@ina ~]# fdisk -lu /dev/sda
Disk /dev/sda: 120.0 GB, 120000000000 bytes
255 heads, 63 sectors/track, 14589 cylinders, total 234375000 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 63 61432559 30716248+ c W95 FAT32 (LBA)
/dev/sda2 61432560 234356219 86461830 f W95 Ext'd (LBA)
/dev/sda5 61432623 163782674 51175026 b W95 FAT32
/dev/sda6 163782738 163991519 104391 83 Linux
/dev/sda7 163991583 184313744 10161081 83 Linux
/dev/sda8 184313808 184522589 104391 83 Linux
/dev/sda9 184522653 232267769 23872558+ 83 Linux
/dev/sda10 232267833 234356219 1044193+ 82 Linux swap / Solaris
As we can see there are two FAT32 partitions, one with 30GB and one with 50GB.
The 50GB is used for shared files between linux and XP. The first one is the XP disk
this one we must keep. The second partition is an extended (look at the sectors
how it starts just after the first partition and ends at the same sector as the last partition.)
This second extended partition holds al other partitions, that was very handy for me
all I had to do was to delete this extended partition. I used fdisk for this.
now I have one primary partition with 30GB.
6) install XP
run your complete XP install, reboot a couple of times XP likes that.
7) boot to linux rescue
Fill your cdrom drive with your linux distro cd and go to rescue mode.
with Redhat or Fedora you type at the start prompt: 'linux rescue'
place your bootsector and partitiontable in your rescue enviroment from
your floppy or again with scp from another host.
8) restore
restore bootsector:
dd if=bootsector of=/dev/xxx bs=512 count=1
and now your partitiontable:
sfdisk /dev/xxx < xxx.pt
9) keep 'm crossed
reboot.
author: Erik Jan Jonkers (21-12-2005) last update 21-12-2005