Virtualisation

Introduction

The best system for handling virtual machines under Ubuntu is a combination of 5 components:

See this superuser topic for more on the relationships of these components.

I originally used virtualbox to create virtual machines, but it was ridiculously slow. There are lots of websites claiming that Qemu is slower than virtualbox, but that is probably when Qemu is doing hardware emulation rather than using KVM. Qemu/KVM is much faster than virtualbox. There are also lots of websites claiming that Qemu/KVM is much harder to use than virtualbox. These claims probably pre-date the intrduction of virt-manager, which I find easier to use than virtualbox.

Installation

There are Ubuntu packages available for the virtual machine system. I followed these instructions and installed the following packages:

apt install qemu qemu-kvm virt-manager virtinst libvirt-clients bridge-utils libvirt-daemon-system

These packages are:

I probably didn't need all these. A lot of installation guides only install 'qemu' and 'virt-manager', and I suspect that they would have been sufficient.

Following the same installation guide, I did:

systemctl enable --now libvirtd
systemctl start libvirtd
systemctl status libvirtd
usermod -aG kvm root
usermod -aG kvm fog
usermod -aG libvirt root
usermod -aG libvirt fog

System details

There is a virtual machine daemon called 'libvirtd', which can be controlled using the usual systemd commands.

Most of the virtual machine files are under '/var/lib/libvirt/'. Images of the virtual machines are in '/var/lib/libvirt/images'.

Creating and managing a virtual machine

Creating a virtual machine

Virtual machines can be created and managed using the command 'virt-manager', which launches a GUI frontend to libvert.

To create a new virtual machine:

This will create the virtual machine and open a window for managing it.

See below for full details of creating a virtual machine running Windows 10.

Managing a virtual machine

Virtual machines can be managed using the command 'virt-manager'. Select the required virtual machine, and then click the appropriate icon to start, stop, pause or open the VM.

To delete a VM, right click on the VM in the virt-manager window and select 'Delete'.

If you click 'Open', a separate window will be opened. This has the following icons (left to right):

The graphical console enables you to interact with the software (e.g. Windows 10) running in the VM.

The 'hardware details' allows you to view and configure hardware aspects of the VM. Some of the more interesting options:

There is an 'Add Hardware' button at the bottom left of the 'hardware details' page. If you click this, it opens a new window with options for accessing devices. In particular, the 'USB Host Device' provides access to USB devices.

Network problem

The Windows 10 VM lost its network connection after working OK for a few months.I dont know what had changed, but after a couple of hours of web searching I found a solution. Apparently the default network set up by QEMU/KVM is configured to bridge to "any physical device". The solution is to set up a new network that bridges to the specific named physical interface.

Windows 10 in a virtual machine

Installation

I used the following web pages for guidance:

The following steps follow the outline above, but include additional steps and details for Windows 10.

Sharing files

I used the following web page for guidance:


Windows 11 in a virtual machine

Installation

I used the following web pages for guidance:

The following steps follow the outline above, but include additional steps and details for Windows 11.