Setup KVM Virtualization 4

Posted by JD 11/03/2013 at 18:00

Update 4/2015
For Ubuntu 14.04 and later, FreeNX use has stopped. We switched over to x2go and have been using it daily from local and intercontinental remote locations to access 14.04 remote desktops. It has been performing better than FreeNX did with only a minor issue – only 1 remote desktop can be displayed concurrently on a client machine. That isn’t a big issue for us, but it could be for others.

In short s/freenx/x2go-server/g and s/nxclient/x2go-client/g for the remainder of this article. Hope that is clear.

Original Article

Below is a sample way to setup and use KVM with virt-manager as the VM management client for your consideration. It is not a How-To, rather it shows how the peices fit between local and remote and the hostOS vs clientOSes running inside virtual machines. I hope this diagram helps.

Overview

Virt-manager will use VNC to provide console access. This is extremely painful, so I suggest setting up a FreeNX server on either the Linux hostOS or clientOS running under KVM on the same subnet to make management more pleasant. NX is very efficient for non-media use, so as long as you do not need video or audio, NX is fantastic.

The Diagram


click for a larger image.

FreeNX and nxclient are Optional

If you do not intend to have any GUIs running in the remote VMs, then FreeNX is not needed. Running virt-manager on your local Linux desktop is secure and probably good enough for those few times when pure-SSH is not sufficient.

KVM Virtualization Settings

Before you setup any VM,
read this to avoid making poor choices on the settings that will make Windows VM slow. Highlights are:

  • do not use sparse HDD allocations – use RAW storage, fully preallocated storage (not qcow2, not VMDK, not VDI).
  • As with a smart Windows install – use 2 partitions
    • for OS/Apps and
    • for data
  • use the SATA driver (or virtio for Linux)
  • disable disk caching for the VM – the hostOS will do that. (Advanced settings)
  • use ICH-based chipsets wherever possible – not P4iii (Does KVM care about this?)
  • use the Intel Pro/1000 ethernet driver (or virtio for Linux)
  • enable both ACPI and APIC
  • use vmvga video – there are issues with all the others unless you really know what you are doing. This is just for console access anyway, which we will hardly ever use. Update: VGA is working now. Some people report issues with cirrus.
  • Allocate the amount of CPU and RAM needed for the clientOS workload, not more. For Linux desktops, that is usually 1G of RAM and 1 vCPU. For Windows media center, 1.5G of RAM and 1 or 2 vCPUs dependent on the concurrent number of recordings. These settings (RAM & vCPUs) can easily be modified for Linux clientOSes. Windows installs different libraries for 1 vCPU vs 2+ vCPUs, so if the workload under Windows will grow to need more than 1 vCPU, install with 2 configured.

Be certain to read that link above for more details which apply generically to hypervisors. It also has an attachment with screenshots and notes for setting up a VM.

For more detailed instructions on bridge networking under Ubuntu.

Comments? Questions?

  1. Miguel 11/07/2013 at 02:46

    I started using Vmware ESXI, then migrated to Proxmox and now I’m thinking of going this route, use a debian install for the kvm host server and then build up from there.
    The thing that makes hold on to Proxmox for now is my dependency on the webgui to do stuff that I can’t do on the cli… and also because I think that a solution like proxmox won’t need as much configuring and finetuning.
    Anyway, thanks for the above tips!

  2. JD 01/13/2014 at 17:10

    Be cautious reading outdated how-to guides on the internet. Even the Ubuntu Guides are out of date on KVM.

    Also, since we run 12.04 LTS releases here, some of the newer Ubuntu releases 12.10, 13.04, 13.10 will have different defaults and guidelines. Be careful about following those related to video setups. Test before you accept any of those settings while taking careful notes of any changes so falling back to an older setup is possible.

    I intend to create step-by-step how-to when 14.04 is released, but it may take some time.

  3. JD 03/23/2014 at 00:56

    Miguel: I haven’t needed to use any CLI with KVM in years. virt-manager is a GUI that can be run local or remote to create, start, stop, modify and connect to a console over ssh. virt-manager works over ssh, so it can be run from any system anywhere in the world that has access to the hostOS.

  4. JD 08/27/2014 at 13:40

    With Ubuntu 14.04, FreeNX has been replaced by x2go here. Be certain to use x2go clients from August 2014 or later to avoid some bad CPU spike issues on the server-side.

    I also disable client-side file sharing (which is through ssh), since it will really only work when on the same LAN. Over the internet, the local (client-side) firewall will need to be opened, ssh forwarded, and that just isn’t going to happen at a hotel or coffee shop anywhere in the world. Forget about it at a corporate location – so it just isn’t worth it – IMHO.

    Need to stress that virtio should be selected for Linux HDD and Network devices.

    Also – be certain to leave at least 512MB of RAM for the hostOS – I try to leave 1G myself. The hostOS needs CPU and RAM to manage the VMs, storage, networking, etc. after all.

    With 1404 and later, the VGA video driver seems to work fine. No need to force cirrus anymore. Again, this is just for console access and we won’t be using that very often at all.