2 March 2009

Install Windows after GNU/Linux on the same hard disk

There can be various issues when attempting to install Windows on which is installed a GNU/Linux distribution.
One of the more subtle is hardware detection problem which can occur after the first second while Windows installation CD is booting (See this interesting post which gives some explanations in specific cases).

It can be the case if there is a dedicated boot partition for GNU/Linux.
The solution is to temporarily delete the partition, perform the Windows installation, restore the partition, and finally restore the MBR.

Those are some instructions to help you solving this issue.
The variables of this example are:
- /dev/sda the main hard disk,
- /dev/sdaN the boot partition (ext3) before deletion (corresponds to hd0,N-1 for bootloader)
- CF and CL the first and last cylinders of the /dev/sdaN partition (given by fdisk -l)
- /dev/sdaM the boot partition after restore (corresponds to hd0,M-1 for bootloader)
- grub as bootloader

Instructions:
- backup your /boot/grub/grub.conf
- backup your boot partition into a file
dd if=/dev/sdaN of=/tmp/boot.bin
- temporarily delete the partition
fdisk /dev/sda
d (to delete partition)
select the partition number (N in this instance)
- perform the Windows installation
- boot with a GNU/Linux Rescue or Live CD of your choice
- restore the partition
fdisk /dev/sda
n (to add new partition)
specify CF and CL as first and last cylinders

- use fdisk -l to identify the new partition number, in case it has changed (M in our case)
- format it
mkfs.ext3 -L boot /dev/sdaM
- restore your boot partition
dd if=/tmp/boot.bin of=/dev/sdaM
- remove/rename the /boot folder of the launched GNU/Linux Rescue or Live CD instance
- mount your boot partition
mkdir /boot
mount -t ext3 /dev/sdaM /boot
- edit the /boot/grub/grub.conf file to replace hd0,N-1 by hd0,M-1
- restore the MBR

No comments:

Post a Comment

Thank you for your visit, let's share your point of view: