KVM Setup For Win7 Pro On CentOS 5.x

Home » CentOS » KVM Setup For Win7 Pro On CentOS 5.x
CentOS 14 Comments

Can somebody point me to a HowTO or other documentation describing the tools available under the CentOS 5 KVM package to create and manage a Windows 7 Pro VM? All my VM experience to date has been the old free VMware Server.

I need to:
+ Create the VM instance allowing for about 50GB total disk space which
will be either a single image partitioned into two Windows ‘Drives’
for the OS and applications/data, or two images.

+ Install Windows 7 from an OEM System Builder Pack, either using the
CD/DVD drive on the Linux server or from an image created with ‘dd’
from the Win7 media.

+ Set up network bridging on the private LAN so that the Windows system
is accessible via OpenVPN connections from the outside world and by
users on the LAN to run a client/server accounting application.

Thanks

Bill

14 thoughts on - KVM Setup For Win7 Pro On CentOS 5.x

  • Assuming you have hardware acceleration and 64 bit version installed, look for the virt-manager package.

    The interface is very similar to virtual box.

    The default location for the hard disk image file is under /var/lib path. This can be changed to point to a different location if you are planning many such large installation. An alternate method could be to define a file or a LVM and then tell virt-manager the location of this file/LVM volume.

    Any x86 OS can be installed. Choose a NIC like Realtek or Intel Pro, drivers for which should be recognizable by the Windows installer.

    I have done KVM VLANs but I am not sure if it can be done from the virt-manager. Experiment and see how far you can go.

    Best,

  • Thanks. I found that after doing some poking around. I’ll be in my normal ‘learn by destroying’ mode this afternoon (apologies to Jeff Lieberman of learnbydestroying.com :-).

    I’ve never used that, only VMware so far.

    Thanks for that info. It looks like everything is under
    /var/lib/libvrt.

    I assume that I can replace /var/lib/libvirt/images with a symlink to another file system with adequate space.

    Would it be safe to symlink the entire /var/lib/libvrt directory to another file system? I just tried ‘lsof /var/lib/libvirt’ on the system with no VMs and the libvrtd service running, and it doesn’t show anything using it at idle.

    I will be digging into this later today. So far I’ve found the file /var/lib/libvirt/network/default.xml and see a vibr0
    interface defined.

    The documentation I found yesterday described setting up briding, but hopefully virt-manager has a nicer way to do it.

    Bill

  • Yes, as long as SeLinux is not enforced. But why not simply mount a dedicated partition here? The actual path is stored in de VM definition. So existing machines need to be changed
    (virsh edit ). I think the default path is only used as e default location. I have moved the images of several machines to a NFS path to make live migration work. Do remember that /var/lib/libvirt/qemu/save is used to save system state when rebooting. Still needs several GB of space for that. This I find the most difficult part. I have done it a couple of time and made myself a HOWTO. You need to fill in some IP figures of course. I
    assume a fixed IP address, but DHCP should work as well. The setup creates a bridge and adds and existing interface (ifcfg-ethx) to that bridge. After that you can use the bridge for the VMs:

    KVM
    ==yum install kvm virt-manager qemu bridge-utils
    #create bridge for virt-machine cat > /etc/sysconfig/network-scripts/ifcfg-br0 < < _END_ DEVICE=br0 TYPE=Bridge IPADDR2.168.48.X NETMASK%5.255.255.0 GATEWAY2.168.48.1 BOOTPROTO=none ONBOOT=yes DELAY=0 NOZEROCONF=true NM_CONTROLLED=no _END_ Edit /etc/sysconfig/network-scripts/ifcfg-ethx : ONBOOT=yes BRIDGE=br0 NM_CONTROLLED=no service network restart

  • I got things installed yesterday, adding a routed network section using virt-manager linked to the private interface, eth1. I left the default NAT interface as-is.

    After rebooting the machine, two bridge devices, virbr0 and virbr1 appear in ‘ifconfig’ output with the appropriate IP
    addresses (192.168.122.1 and 192.168.100.1 respectively).

    The ‘route -n’ command shows reasonable routes for the VMs.

    I am thoroughly confused by the documentation I’ve found so far, much of which seems to be out of date.

    When the Windows VM is active with the network virbr1 defined with virt-manager and all other things default, a ‘vmnet0’ device appears in ‘ifconfig’ output. I can ping the IPs on the private lan (192.168.101.0/24 in this case), but cannot get to the outside world, nor can hosts on the LAN ping the VM’s assigned IP
    address 192.168.100.114.

    If I shut down the VM, manually run ‘brctl addif virbr1 eth1’, then start the VM things change:

    + The IP address assigned to the VM is in the 192.168.101.0/24 block
    instead of 192.168.100.0/24 defined in virt-manager.

    + I can ping the outside world from the VM.

    + I can ping other hosts in 192.168.101.0/24, but *NOT* the Linux boxes
    IP address.

    + I cannot ping anything in 192.168.101.0/24 from the command line on
    the Linux host (logged in with SSH on the public interface).

    + The command ‘brctl show’ displays vmnet0 and eth1 vir virbr1.

    I’m more than a bit confused at this point.

    My main goal is to get LAN and OpenVPN access to the Windows VM. I really don’t care about Internet access from the Windows VM, although Microsoft really wants it to get updates and such.

  • Just for information, there is a “CentOS-virt” ML.

    My VM configuration dumps are here:
    https://code.google.com/p/rktmb-samples/source/browse/trunk/xml-vmconfig you’ll find some comparison point to what you get. My VMs are all routed+NATed (for those). I dont have bridged Windows.

    This is my sample invocation when installing a Windows:

    sudo virt-install –connect qemu:///system –name win-7-01 \
    –ram 1024 –keymap=fr \
    –cdrom=/media/500G/ISO/Windows7Ultimate64bit.iso \
    –os-type=windows \
    –os-variant=win7 –network=network:default –vnc –accelerate \
    –force –disk path=/mnt/big/mihamina/Virtual/win-7-01,size

  • As has been pointed out, SELinux may prevent that from working with a simple symlink. You have two options that will work:

    1: Create a symlink and set the context of the link destination to the same context used for /var/lib/libvirt/images. Use semanage to make the changes permanent, or else a restorecon might break the system:
    http://docs.fedoraproject.org/en-US/Fedora/13/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-SELinux_Contexts_Labeling_Files-Persistent_Changes_semanage_fcontext.html

    2: Use a “bind” mount instead of a symlink. Enter a line in /etc/fstab like this one:
    /bigger/fs /var/lib/libvirt/images none bind 0 0
    Then, mount /var/lib/libvirt/images and “restorecon -r -v
    /var/lib/libvirt/images”

  • That seems far more complicated than the vendor’s documentation. Is there a reason that you use that method?

  • Thanks for that hint. I subscribed a couple of days ago, but so far haven’t seen any traffic. A google search of the archives did turn up some interesting posts.

    I have things working now after cleaning up some of the cruft left around after my original attempts to follow the docs.
    :17: warning [p 1, 1.7i]: can’t break line

    1. Create a bridge, ‘br0’ following the writeup on this page (and
    several others):

    https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/5/html-single/Virtualization/index.html#sect-Virtualization-Network_Configuration-Bridged_networking_with_libvirt

    This link also has some interesting hints.

    http://itscblog.tamu.edu/startup-guide-for-kvm-on-CentOS-6/

    2. Delete the routed network definition I had made prior to creating the
    bridge. Things didn’t work properly with the old definition even
    though it was point to my private interface, ‘eth1’. I also deleted
    the ‘default’ NAT interface as we will never use that.

    3. Check for other software that references the new bridge, changing the
    old ‘eth1’ interface to ‘br0’. Samba shares were not appearing until
    I updated ‘interfaces’ in the ‘smb.conf’ file. This may have been
    caused when I turned sharing on in the Win7 VM which I didn’t need.

    Bill

LEAVE A COMMENT