This tutorial will show you how to install a virtualization stack consisting of KVM, QEMU and libvirt on Alpine Linux, with support for both AMD64 and ARM64 based computers.

Alpine Linux is “an independent, non-commercial, general purpose Linux distribution designed for power users who appreciate security, simplicity and resource efficiency”. It’s incredibly lightweight and is useful for both containers and virtual machines, as both host and as guest. Due to it’s small size, it’s able to run on everything from MicroServers to Threadripper based workstations. Alpine Linux also provides specialized images for the Raspberry Pi and a generic ARM image for other ARM based computers.

This article assumes you have Alpine Linux installed and running on a node already.

Install KVM and QEMU

To install KVM and QEMU on AMD64 (x86_64), run the following:

$ sudo apk add qemu-img qemu-system-x86_64

If you’re running an ARM64 (aarch64) based system, run this instead:

$ sudo apk add qemu-img qemu-system-aarch64

Install libvirt

Next, install libvirt:

$ sudo apk add libvirt-daemon py-libvirt py-libxml2

Enable and start the libvirtd service:

$ sudo rc-update add libvirtd
$ sudo rc-service libvirtd start

Install virt-install (Optional)

If you want a simple command line interface to install virtual machines, follow these instructions to install virt-install (see the virt-install documentation for usage).

First we’ll need to add the community repository to apk (make sure v3.10 below is the correct version for your setup):

$ sudo echo "" >> /etc/apk/repositories

Then update the apk cache and install virt-install:

$ sudo apk update
$ sudo apk add virt-install

Last Words

Now your virtualization stack should be up and running! Please see the KVM, QEMU and libvirt documentation on how to proceed. 🖥️😊