Use Alpine Linux as a Hypervisor (with KVM, QEMU and libvirt) on AMD64 and ARM64
Table of Contents
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 guest. Due to its small size, it’s able to run on everything from MicroServers to Threadripper PRO -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 already have Alpine Linux installed and running on a node.
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 py3-libvirt py3-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 "http://ftp.acc.umu.se/mirror/alpinelinux.org/v3.10/community" >> /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 further. 🖥️😊
Revision #
2024-03-04 Updated libvirt
to use Python 3 packages, thanks to
spiffyfrodo
2023-08-31 Revised language