Hetzner systems are often described as “headless” and installing Windows or rescuing a Windows installation on such a system can be extremely difficult.
You have to use Linux rescue system.
After you start qemu, you have to access your server with vnc.
After you install windows os, you have to start RDP to aceess your server.
Requirements The server needs to have at least 16GB of RAM and a processor that supports VT (Example: Intel i5).
[update6]updated due to experience with Win7 installation on core i5-3570[/update6]
[update5]Thanks Peter Littmann, updated as suggested in Post 23[/update5]
Here my two cents for installing windows and other operating systems with qemu-kvm
Booting the rescue systems gives you a complete linux system that is running on your server without using your hard disk.
[First get the network data of your server: ifconfig and save network data like IP, gateway, mac, etc.]
Not needed. Kimsufi/OVH has DHCP, so your server will work right away. But you will need to turn of "monitoring" in your control panel, since Windows normally does not respond to ping!
#to see if Raid devices are present and stop them
mdadm --stop /dev/md0
mdadm --stop /dev/md1
#Second step is to get rid of the network drives, because they are read-only
mount -t tmpfs -o size=12000m tmpfs /mnt # use 12GB of memory as temp - reduce as needed
rsync -a /var/cache/ /mnt/var/cache/
rsync -a /var/lib/ /mnt/var/lib/
rsync -a /var/run/ /mnt/var/run/
rsync -a /usr/ /mnt/usr/
rsync -a /lib/ /mnt/lib/
mount -B /mnt/var/cache /var/cache
mount -B /mnt/var/lib /var/lib
mount -B /mnt/var/run /var/run
mount -B /mnt/usr /usr
#Now our linux system is running of our RAM.
#download windows iso into /mnt
wget http://domain.tld/yourwindows.iso #adjust as necessary
#Get qemu, you can also install virtualbox or vmware player and do the installation with that, but mounting physical harddisk is a little bit more complicated.
apt-get install qemu # take over 200MB
apt-get install kvm # You need that, since qemu does not work without virtualization with windows 7 or server 2k8
#Wipe hard disks, so that Windows DVD start installation
dd if=/dev/zero of=/dev/sda bs=1M count=1
dd if=/dev/zero of=/dev/sdb bs=1M count=1
#with the following command you can reread the partition. that is needed if you want to mount a partition in linux later on, to copy data from the rescue system to windows or back.
#NOT RECOMMENDED!! If you need direct network, setup ethernet bridge in your host system before and TAP device, to grant access to internet for Qemu through new TAP device.
#apt-get install bridge-utils
#apt-get install systemtap
#ip link set eth0 up promisc on
#brctl addbr br0
#brctl addif br0 eth0 #you will need to make a script with this, because activating this line will cut the ssh connection and you will not be able to reconnect.
#Now use qemu. "qemu" is 32-bit, "qemu-system-x86_64" is 64 bit
#I guess Window XP would work without kvm, but Windows 7, Windows 2k8 and so on don't, due to a bug in qemu, that is there for years. [update2] N.B. There seems to be a problem with qemu and windows Qemu in rescue system, e.g. Windows installation - Page 2 You may need to switch to kvm.[/update2]
qemu-system-x86_64 -net nic -net user,hostfwd=tcp::3389-:3389 -m 1.5G -alt-grab -localtime -enable-kvm -cpu kvm64,+nx -usbdevice tablet -k en-us -cdrom /mnt/yourwindows.iso -hda /dev/sda -hdb /dev/sdb -vnc :0
-cpu (CPU Type) # host for use host type CPU - good when using kvm
-enable-kvm # if kvm installed, use kvm
-smp # number of processors
-vnc :0 # means use vncdisplay 0 -> ":0"=5900 port, ":1"=5901 port, etc)
-m # amount of memory, 2048 can cause problems
-usbdevice # useful with VNC
-k # keyboard format needs to be used, if you use keyboard other than en-us
-cdrom # image file
-hda # first hdd -> using physical HDD
-hdb # second hdd -> using physical HDD
-boot # if you need to boot from another drive e.g. /cdrom
-boot once=d # boot once from different drive.
This should get Windows installation up and running. While installing choose custom partition for first hdd and leave the second hdd empty. Finish installation. Setup a user name with password. Activate remote desktop for that user and update windows. You should be having internet behind nat. We are forwarding port 3389, so you can try if remote desktop is working. It should. If everything is as you want, you can go on to the tricky part, which you can read about in the second post.
On your client machine you can use the following command to tunnel vnc through ssh to safely access your headless qemu session
vncviewer -via root@yourip localhost:0
-via (login to your server through ssh, using user root and standard ssh port)
-localhost:0 (ssh makes remote server be localhost for you, :0 means connecting to port 5900 on remote server, :1 would mean connecting through port 5901, etc)
Okay, once your system is up and running in qemu-kvm and you did all the updates, you will come into problems, when you reboot the system outside qemu-kvm. The reason for that is the ethernet card that is different and the hard disk controller that don't match. You could for sure do something manually about it, but in the internet they recommend to use the MS tool sysprep, which was installed with my Windows 7 Pro installation.
The idea is so to speak, to make the necessary adjustments, so that Windows has no problem booting in a new environment. Sysprep puts Windows into the state that it will recheck the hardware and reconfigure basic settings, like timezone, keyboard language, etc. The problem is only, that you are not sitting in front of the PC to answer those questions. That is why you have to create an "unattend.xml" file. To create that file you need to download Windows AIK from here Download The Windows® Automated Installation Kit (AIK) for Windows® 7 from Official Microsoft Download Center (this is the version for Windows 7 and Server 2k8 and maybe other versions too). Install it to any Windows system you like.
You will need the file CDROM:\sources\install_(windows version you used).clg from your Windows DVD.
I used this legal Windows 7 Pro english http://msft.digitalrivercontent.net/win/X17-24281.iso DVD to create this unattend.xml file, you can get on pastebin unattend.xml - Pastebin.com .
When you start the program "Windows System Image Manager" you can use that unattend.xml to get you started. You will need to mount the "install_xxxx.clg" file with a right mouse click under "Select a Windows image or catalog file".
Then follow the tutorials in the links above and google to see, which values to select for your unattend.xml file.
Once you have an unattend.xml file that corresponds to your Windows installation you are ready to restart. Copy the unattend.xml file to c:\windows\panther and c:\windows\system32\sysprep and change dir to c:\windows\system32\sysprep and execute
Sysprep /generalize /oobe /shutdown /unattend:unattend.xml
The computer will shut down then. In Kimsufi Manager switch to boot from harddisk and restart.
Your server should reboot and you should be able to use remote desktop to log into your server.
Under Linux you can use
rdesktop 220.127.116.11 # to connect to your server
See result of successful installation
Image Upper.com - Free Image Hosting - View Image
Image Upper.com - Free Image Hosting - View Image
Some further comments:
Since sysprep puts windows in a state to recheck the available hardware, you can easily make a backup/clone of the partitions to another hard disk / server. I guess, that is what other people do, when they offer their services. They have an image, they only need to copy onto the new server and when it boots, Windows autoconfigures itself and ready you are.
There are backup programs that do V2P or restore to dissimilar hardware. Those programs can easily be used to restore a Windows or Windows Server through a Linux rescue. You can run those programs in qemu-kvm.
I would recommend for Windows versions the freeware ToDo Backup 3.5. It is not the latest version, but it is free.
One last thing is still missing, setting up Raid 1.
When you connect to the "diskmgmt.msc" disk management program you can select with right click on disk0 and disk1 and choose convert to dynamic disk. Once both disks are dynamic disks, you can first choose "system reserve" and with right click choose add mirror. Repeat the same for all other partitions. This way you get Soft-Raid 1 on Windows.