KVM On Ubuntu - KVM Logo

Installing and Running KVM on Ubuntu 14.04 Part 7

In part 6 of this series I looked at setting up a VNC access to the console of a guest machine in this part I’ll be installing a desktop environment.

Installing a Desktop Environment on KVM

Before we get started on the article let me say that I think installing a desktop environment on a (Linux) server machine is wrong. Linux servers can for the most part be administered individually very well from the command line. Where you might want a GUI environment for administration something like Webmin is a better choice. If you must have a desktop though here is how to install one.

If you’ve been following this processed from the start you may remember that I installed my guest machine with just 1GiB of ram which is fine for a simple web server but  won’t be enough for a server running a desktop environment so the first thing to do is start a virsh session, stop the guest and open the configuration file for editing:

virsh # shutdown demo2
Domain demo2 is being shutdown
virsh # edit demo2

Change the memory settings to give the server 2GiB of ram (2097152 KiB) rather than 1GiB (1048576 KiB):

<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>

Strictly speaking you only really need to change the memory setting as the guest will be allowed to balloon up to this value from the value given in the currentMemory setting. In this case since 2GiB is such a small amount anyway I’ll just let it start of at 2GiB. Once you are done restart the guest with:

start demo2

Now shell into the guest machine and install the desktop environment of your choice. The basic command is:

sudo apt-get install --no-install-recommends <type>-desktop

Where type can be replaced with one of:

  • ubuntu
  • kubuntu
  • lubuntu
  • xubuntu

The –no-install-recommends argument strips out all the extra packages that get installed along with the desktop environment giving a much lighter install. I don’t particularly care about this server right now as it’s only a demo so I’m going to go for a full install of Kubuntu to see how it handles the load. This will take a while as it looks like just about the entire Ubuntu repository needs to be downloaded and installed! Once it’s finished restart the guest and then shell back in.

When it comes to accessing the desktop you’ve just installed you’ve got a couple of options. You can either use VNC (see references) or some sort of remote desktop software like X2Go. The main benefit of VNC is that it works across a wide range of guest types so you only need one client to access Linux, Windows and (presumably) Mac guests. The problem I find with VNC is that it’s slow and unresponsive compared to other remote desktop solutions. For this machine I’m going to install and configure X2Go which I’ve always found to be quite fast and more responsive if a little quirky sometimes.

Unfortunately the X2Go server isn’t in the main Ubuntu repository yet so you’ll need to add a repository to Apt in order to get the packages. At a command prompt on the guest run this:

sudo apt-add-repository ppa:x2go/stable

Once that is complete perform an update and then install the X2Go packages. The last line is only necessary if you are installing LDXE / lubuntu:

sudo apt-get update
sudo apt-get install x2goserver x2goserver-xsession
sudo apt-get install x2golxdebindings

Now give the guest a quick reboot and you are ready to make a connection.

To connect to your newly installed desktop download and install the X2Go client from the website and start it up. Select Session > New Session… from the menu and enter values that look like this:


Under the connection tab you might want to bump it up to LAN if you are working over a LAN connection and I find the default starting display size to be a little small. Display size is another advantage of X2Go over VNC though. With X2Go the client window can be resized and the desktop displayed in it resizes to accommodate, you don’t get nasty scroll bars making it difficult to get to the task bar etc. Once you are done with the settings click Ok and you will be left with a display like this (I have another configuration already defined):


Simply click on the settings you want to use and enter your password. After a few seconds you should be presented with the desktop environment on your guest machine.


You may get an SSH key warning when you first try to open the desktop. Assuming you are happy you are connecting to the correct machine you can safely ok that. Don’t forget that you have to log out of the desktop environment when you leave, if you just close the window it’ll leave the desktop running.

Notes on X2Go Client

If you maximize the screen on the X2Go client you can be stuck in the situation where it’s not obvious how you get back to your original desktop. Here are some shortcut keys to help:

  • Ctrl+Alt+M : Minimizes the guest window.
  • Ctrl+Alt+T : Terminates (ends) the guest window.
  • Ctrl+Alt+F : Switches the guest window into fullscreen mode – seems to be a bit temperamental, the guest goes full screen but leaves a weird mash-up of the local desktop and the remote desktop.

If you have simply maximized the guest you should be able to Alt+Tab to other applications on the local desktop as the remote desktop is just another window at this point. Unfortunately I’ve not been able to find a way to restore a session that has been maximized which is most frustrating.


After installing the desktop I was interested to see what sort of affect it had on the server in terms of load. As I mentioned above I upped the memory on the server from 1 GiB to 2 GiB in order to handle the additional load of the desktop but this was just a guess. It turns out that I could probably have got away with not increasing the memory.

Before adding the desktop environment the server was configured with 1 CPU and 1 GiB of memory. The long term load average as reported by htop was about 0.01 and memory usage was <40 MiB after a fresh boot and shelling in. After adding the Kubuntu desktop environment the server was configured with 1 CPU and 2 GiB of memory. The long term load average as reported by htop is about 0.14 and memory usage is around 480 MiB, this is after making a remote desktop connection to the server.

On first glance it looks like adding a desktop environment means increasing the load on the server 14 fold and the memory requirements about ten fold. In reality I think the increase in load and memory would be a much smaller percentage as it’s hardly fair to compare a fresh server install to one with a full desktop environment.

As a final test I decided to see what media playback was like. The 1 CPU and 2 GiB set up was easily able to start up Amarok and play back an MP3 over the remote desktop. Next I tried Youtube, using the HTML5 player built into Firefox I could just about play back a 360p video in the page, if the video was made fullscreen nframes were dropped. I then upped the guest resources to 2 CPU’s and 2 GiB and re-tested. At 360p I could then play the video fullscreen without dropped frames. Bare in mind that this is running on an old server so a modern host machine with a decent processor should be more than capable of running a usable desktop on several guests.


Posted in Linux, Virtualization and tagged , , , .

Leave a Reply

Your email address will not be published. Required fields are marked *