kvm on Raspberry Pi 3

I got two virtual machines with native virtualization support running on a Raspberry Pi 3 using openSUSE Leap. A Raspberry Pi is still an amazing piece of hardware - an inexpensive pocket computer with a solid 4-core ARM Cortex-A53 core, which is powerful and capable. This modern CPU allow for hardware virtualization - Yes, your Raspberry Pi has build-in hardware virtualization (neat!)

Most Raspberry Pi flavors don't compile kvm into their kernels - at least not the last time I tried to get libvirt and kvm running there. openSUSE does, and it's super easy to get your virtual machine hypervisor running.

The steps on the Raspberry Pi are done in a terminal. Don't worry - after the initial steps we will use virt-manager from your laptop to connect to the Raspberry Pi via ssh, while having the comfort of a GUI at hand.

Installing openSUSE

Installing openSUSE is easy going, if you have already flashed Raspbian or any other Linux distribution to a sd-card. Get the corresponding images from here, and copy the raw images to your sd-card. There are many tutorials on how to do this your operating system - Google is your guide 🙂

From the repository, select the disk image you want to have. I used the JeOS image (Just enough OS - a very minimal image with barely enough to boot the system) openSUSE-Leap-15.1-ARM-JeOS-raspberrypi3.aarch64-2019.05.17-Snapshot1.105.raw.xz because we want to have as much RAM as possible for the guests. With only 1GB on the Raspberry Pi 3, a desktop system might consume a bit too much memory per se. Download the image, copy it to the SD card and boot into the system. Don't use anything below 16GB, as the system+iso+disk images will need some space.

Boot into the system and ensure, you have ssh root access to your raspberry. I'm naming this one raspberry3 in this tutorial.

Installing libvirt on the Raspberry Pi

Once the system is up, we only need to install libvirt and enable the daemon. For that open a ssh session to your Raspberry Pi and type in the following commands

libvirtd is up and running

That's it, libvirt is now up and running. If not, try a reboot before you go on. Ignore those error messages about CPU model cannot be detected for now.

Installing virtual machines

I use virt-manager from my Laptop to connect to the Raspberry Pi. Add a connection to your Raspberry Pi (In my case it's 192.168.0.135, consult your router or do a quick arp-scan to find out the IP address) and connect as root (or as your user, assuming you are member of the libvirt group)

Now select the new connection and click on "Create a new virtual machine".

Before proceeding, download the install iso. For this tutorial I suggest you use alpine or Debian, because they require minimal memory. I tried the procedure with openSUSE Leap, Ubuntu and CentOS and failed in all three causes, because the installed needs more than the provided 768MB RAM I could spare. alpine and debian both work just fine with 256 MB (!!) RAM

Once completed, you can go on in virt-manager with installing the virtual machine from an ISO. I used 256MB ram and 2 cores and a disk image of 4 GB for both distributions.

The procedure is self-explaining and straight-forward (normally). I didn't encountered any peculiarities or difficulties for both distributions. In the end I had them both up and running. Both work like charm, are super slim and feel fast and responsive. Time to be very happy about your achievement 🙂

virt-manager, the raspberry pi and two ssh sessions to the virtual machines open

Neat 🙂

Outlook

The Raspberry Pi 3 is already quiet powerful, if you use the right software - with openSUSE you have a mainstream distributions that has build-in kvm support for the used Cortex-A53 CPU - allowing for hardware virtualization. While the CPU per se could be enough for some small projects, the amount of memory is a bit deflating for virtualization usage. The newer Raspberry Pi 4 has up to 4 GB 8 GB of RAM and this might become a very interesting small hypervisor platform for me, once openSUSE Leap becomes available/stable there 🙂

However, the procedure to setup and run a virtual machine on a Raspberry Pi 3 running openSUSE is IMHO straight-forward, painless and fun 🙂

Update 09.60.2020

Updated the RAM of the Raspberry Pi 4 to include the new 8 GB variant. Thanks to Linda de Mol for pointing this out!

5 thoughts on “kvm on Raspberry Pi 3”

    1. Hey! I don't know about RISC (or more specifically probably RISC-V) but the Raspberry Pi is ARM architecture (aarch64).

      Best,
      Felix 🙂

    1. Hey Linda! Thanks for the info, you are absolutely right for the Raspberry Pi 4. I've updated the article accordingly.
      At the time of writing it was not yet known and shows, how fast sometimes things are moving on ...

Leave a Reply

Your email address will not be published.