Install windows 7 into a ubuntu server

Backgrounds

As a windows client is needed for my testbed, I have to install windows system into a server which is runing a ubuntu os already.
This post is mainly a remainder for the encountered problems while I was installing win7.

Problems


[win7]Unrecognized NIC


The unrecognized NICs are mainly caused by missed drivers.
So this problem can easily fixed via installations of missed drivers.
If you needs to find out the info for the NICs, the following commands are what you are looking for.

$ethtool eth0
$lspci |grep -i ether
$dmesg |grep -i eth

Network connection


As four NICs are used in my server, some for internets and some for inter-connections, DNS and IPs need to be configured manually.
The related info can be found in the following files:

$vim /etc/resolv.conf   //DNS server
$vim /etc/sysconfig/network-scripts/ifcfg-eth0  //CentOS
$vim /etc/network/interfaces //Ubuntu

Cygwin and ssh


In my testbed, all the tasks supposed to be executed automaticly. Therefore a command-line workspace is required in win7 and I choose Cygwin in here.
Here are some excellent tutorials which helps me a lot.

LVM


When trying to restore grub after the win7 installed,
There are several methods mentioned in this document from ubuntu community. But I still cann’t restore the grub until I find this post. The main reason is that my ubuntu is install inside a LVM) partition.
Here are some relative commands.

$lvdisplay  // show logical volumes
$vgdisplay  // show volume groups
$pvdisplay  // show physical volumes

Restore grub2


Here is my steps to restore grub2:

1. Boot the ubuntu LiveCD, select "Try it", and open a terminal  
2. Use fdisk to help determine the partition on which ubuntu is installed  
    #fdisk -l
3. Install LVM
    $apt-get install lvm2
    $vgdisplay                // find name of volume group
    $vgchange -ay name-of-vg  // make volume group available
4. Mount root and boot file systems
    $mount /dev/name-of-vg/name-of-root-lv /mnt
    $mount /dev/name-of-boot-partition /mnt/boot
5. Install grub2
    $grub-install --boot-directory=/mnt/boot /dev/name-of-root-device
6. Reboot and update-grub
    $reboot
    $update-grub

Until now the grub for ubuntu is restore.

Grub setup


Q: How to boot into into win7 from ubuntu for only once ?
A: grub-reboot is the tool you are looking for. This post is a related question in askubuntu.com. Here are the configuration steps:

$vim /etc/default/grub
    modify GRUB_DEFAULT=0 to GRUB_DEFAULT=saved
$update-grub
$grub-reboot X
    X is the menuentry position of the OS you want to boot into for the next time and the next time only.
$reboot

There is a little bug in my grub that the timeout isn’t working properly.
My solution is modify the grub.cfg file according to this-post and this-post.

Until now, the server has become a perfect double-boot server. Cheers! :)