How to reinstall windows after installing linux

windows linux

No one here needs to be reminded how virus prone windows environment is, and in case if you face a situation where you have corrupted your C: partition, then first solution that comes to mind is format active partition and reinstalling the windows.

But if you had already installed Linux after installing windows. and wish to reinstall XP then you are in a hang, as windows XP installation CD will not boot up properly with Linux installed on same system.

I have faced this situation many times; the XP installation will just hang after displaying
Detecting your hardware configuration”…

A work around to this problem dose exists.

Now I will just jot out the materials and steps required to reinstall XP in a hard disk with a Linux already installed.

Problem

  1. First you installed windows XP.
  2. Then installed Linux flavor like Fedora or Ubuntu.
  3. XP corrupted due to virus or any other reason.
  4. Now you have problem reinstalling XP, yet you don’t want to format your any of the Linux partition.

Material required

  1. Smartdrv.exe (you can find this in the windows 98 installation CD or download it from internet). This is a driver that will enable fast copying of data in 16 bit mode.
  2. Windows XP installation CD (which you want to install).
  3. Windows 98 bootable CD (needed to boot the computer).

Procedure to follow

  1. Backup all your data, [ NOTE : this is the most important step].
  2. Backup your boot loader configuration, ex: “menu.lst” in case of GRUB.
  3. Find out how to recover a boot loader for your flavor of Linux, this example considers Fedora & Ubuntu installed along with a corrupt XP [NOTE: step 2 & 3 are second most important steps].
  4. Boot your Linux, you can also use Ubuntu live CD’s (last time I used Ubuntu 8.10).
  5. Format the corrupted/virus effected partition with fat32 file system. You can do this easily using Parted or Gparted which is a GUI front end to Parted.
  6. Insert the windows XP installation CD into the computer, and copy the “I386” folder to your newly formatted partition.
  7. Copy the smartdrv.exe to the same partition.
  8. Now insert the windows 98 installation CD and reboot the PC with this CD.
  9. Go to the newly formatted partition and run the “smartdrv.exe” on the command line.
  10. Change directory to “I386” directory.
  11. Now run the “winnt.exe” from command line.
  12. An installation of windows XP will begin in 16 bit mode.
  13. You will be asked to choose some settings, most of which are already in correct form.
  14. Start the installation.
  15. After the installation is over in 16 bit mode (which is essentially copying of files), you will be asked to reboot the computer again.
  16. Reboot the pc this time without the windows 98 CD.
  17. Windows XP installation in 32 bit mode will begin (as normal way that we experience when installing from CD).
  18. Reboot your PC to a fresh installed XP.
  19. Now to get your GRUB boot loader back you can use the Ubuntu live CD or Fedora installation DVD to upgrade the currently installed fedora (which ever your Linux version be, there is usually some method to recover a boot loader in the installation media).

Voila…



5 Comments

  • Gaurav 30 January, 2009, 10:54

    Wow… amazing post.. Really.

    We would have never done that much R&D to install XP..!! Really appreciate your effort in writing the post.

  • vimal 1 February, 2009, 1:18

    NOTE: during installation please don’t format the whole drive, choose option that says “leave the file system intact”

  • Preetam 10 August, 2009, 14:47

    WOW! Thanks a lot for this useful info.
    After searching all kinds of phrases in Google, I finally landed on ur blog. I was having the same problem, and now i have a solution — Thanks to you.
    I have just 1 question? Will this method work if i have an ntfs partition on C: ? Will the win98 bootable cd recognize my ntfs C drive?

  • Hodge 27 March, 2010, 18:45

    I installed XP on a second harddisk with a NTFS partition. First I made a backup of the MBR from the bootdisk with dd if=/dev/hda of=/boot/boot.MBR bs=512 count=1
    I copied the boot.MBR to the second disk as a backup. Then I Installed xp with a xp install cd because I installed xp on the second drive which was not the bootdrive xp insisted a system partition on the bootdrive so I temporarely deleted the swap partition and created a 8 MB system partition for XP. After XP installation I booted with a Gparted live cd. Reinstalled the MBR on the bootdrive. Through mounting of the ntfs partion on the second drive with XP and the backup of the MBR I also could have mounted my linux partition or put the MBR on a floppy or usb stick. dd if=/home/disk/boot.MBR of=/dev/hda bs=512 count=1. and I recreated my swap partition. I use lilo so I added to lilo
    Other=/dev/sda1
    Label=windows
    table=/dev/sda
    and then rerun lilo et voila linux on disk 1 and xp on disk 2

  • Hodge 28 March, 2010, 19:32

    There is a error in the message above. When you recreate the swap partition you can’t boot windows anymore. A workaround. After xp installation copy ntldr ,boot.ini and ntdetect.com from the system partition on the boot disk to the partition with xp. edit boot.ini and change rdisk(1) to rdisk(0) in both lines. Add to lilo
    Other=/dev/sda1
    Label=windows
    boot-as=0x80
    recreate your swap partition and rerun lilo now it should work.

Leave a Reply

Your email address will not be published. Required fields are marked *

Note

To post source code in comment, use [code language] [/code] tag, for example:

  • [code java] Java source code here [/code]
  • [code html] HTML here [/code]

Current ye@r *