How to remove linux from a computer without touching Windows data

by Aurelien Botman, February 2006
Published on www.botmanfamily.net/~aurelien/articles.

The problem

My Windows partition on my laptop was running out of disk space. I knew I had plenty of unused disk space on my linux partitions. This article describes how I removed linux without touching the Windows data.
Warning: Never try this without making a backup of your data. There is a high probability of complete data loss.

Removing linux

The easy bit. Boot up a Knoppix CD version 4.02+ [1], and use QTParted to (a) delete the linux partitions (b) resize the Windows (NTFS) partition. Reboot.

Making your computer bootable again

Don't panic - grub/lilo was installed on the MBR but its stage1.5 was pointing to a now disappeared linux partition - hence your computer will not boot up. Just boot up your Knoppix CD again. Go to the root-user command line and type:

fdisk -H 255 /dev/hda

At the prompt, type in u then p. Write down the sector numbers of the NTFS partition. Somewhere safe. Then:
dd if=/dev/zero of=zero.img bs=512 count=1
dd if=zero.img of=/dev/hda

This will have the effect of completely zapping your MBR. Your computer will not even recognise your hard disk any more. Don't panic just yet - your data is still there...
Now we need to rebuild that MBR:
fdisk -H 255 /dev/hda

At the prompt, type in o (lower-case letter) then n, followed by p, 1 (the number one), and either the sector numbers you wrote down earlier or return twice for default values. Next, t then 1 (the number one) then 07 (zero-seven, the code for NTFS, hit L for a list of codes). Conclude with p to verify, w to write, and q to quit.
Having rebuilt the partition table, the final step is to make the NTFS bootable:
parted -i /dev/hda set 1 boot on

That's all. Reboot, and Windows should boot up with your data. It worked for me, but your mileage may vary.

References

[1] http://www.knoppix.org/

Printable version | Copyright Aurelien Botman 2007.