Virtual Machines on RaspberryPi 5

RaspberryPi computers are now moving into the realm of being powerful enough to replace the traditional desktop PC. My most recent purchase, a RaspberryPi 500+ is proof of this as it has been my daily desktop PC since it’s arrival.

One of the things I use heavily are virtual machines. They’re great for developing, prototyping and running new services. With the ability to snapshot, rollback and backup in an instant, virtualisation helps to reduce the development and test time for many of the programs and services that I’m playing with.

With RaspberryPi computers now supporting 16GB of RAM and M.2 SSD drives there is no reason for not taking advantage of virtualisation.

To this end I decided to test running some virtualised loads on my new 500+ with the plan to deploy to 16GB Pi5’s with SSD drives in place of more expensive Intel based computers.

On my Intel based machines I use QEMU, KVM and Virt-Manager to manage the multitude of virtual machines (VMs) I have running here. Since this is a solid, high performance platform for running VMs I decided to take the same route on the 500+

Installing the necessary packages is extremely simple, just one simple apt command:

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

Note: If you’re using Debian 13 (Trixie) then the apt command to use is:

sudo apt install qemu-system-arm libvirt-daemon-system libvirt-clients virt-manager bridge-utils

The qemu-kvm package doesn’t exist in Debian 13 and so you have to replace it with the qemu-system-arm package.

To be able to create and run VMs you need to add yourself to the libvirt and libvirt-qemu groups.

sudo usermod -a -G libvirt your_username
sudo usermod -a -G libvirt-qemu your_username

Of course you can do it the old-fashioned way by editing the /etc/group file and adding your username to each group.

You’ll need to create a bridged ethernet device for the VMs to use to access the ethernet interface on your RaspberryPi.

If like me you don’t use NetworkManager the easiest way to create a bridge is to define it in your /etc/network/interfaces file.

For this example I am using an IP Address of 192.168.0.100, gateway on 192.168.0.1 with a netmask of 255.255.255.0 and DNS nameserver on 192.168.0.5.

The normal entry in the interfaces file would look like this:

# Main ethernet
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.5
dns-domain lan.local
dns-search lan.local
#
#

To create a bridge this entry needs to change to:

# Main ethernet
# Setup Bridge called br1 on eth0
allow-hotplug eth0
iface eth0 inet manual
auto br1
iface br1 inet static
address 192.168.0.100
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1
dns-nameservers 192.168.0.5
bridge_ports eth0
bridge_stp off
#
#

Once this is done reboot your RaspberryPi and check you have access to your local LAN and of course the internet. You will now also inherit the two new groups that you added yourself to above.

Note: If you are using NetworkManager open the network settings app and create a bridge on eth0. You can also use the nmtui copmmandline app if you prefer.

At this point you’re ready to create your first virtual machine.

It’s important to have an arm64 version of Linux in ISO format that you can use to install into your VM. My preferred distro is Debian and so I downloaded the Debian 13 Arm64 netinst ISO from the debian.org website.

From the main menu start “Virtual machine Manager” or on the commandline type:

virt-manager
QEMU Virtual Machine Manager
QEMU Virtual Machine Manager

Click the Create new VM button and then navigate to where you saved your ISO file and select it as the installation media.

Virtual Machine Manager - Local install media
Virtual Machine Manager – Local install media
Virtual Machine Manager - Select ISO file
Virtual Machine Manager – Select ISO file

Once you’ve chosen your ISO you’ll need to configure the actual VM. Start by setting the amount of RAM and number of virtual CPUs you want the VM to have.

Virtual Machine Manager - Configure RAM and CPU
Virtual Machine Manager – Configure RAM and CPU

Next set the size of the virtual disk that the VM will use.

Virtual Machine Manager - Create virtual disk
Virtual Machine Manager – Create virtual disk

Finally, give the VM a name and set its network device to br0 as created above. Click finish and your VM will boot.

Virtual Machine Manager - Name VM and select bridge interface
Virtual Machine Manager – Name VM and select bridge interface

Now it’s just a case of going through the standard Debian install process to build your Debian VM.

Virtual Machine Manager - Boot ISO
Virtual Machine Manager – Boot ISO
Virtual machine Manager - Running standard Debian install
Virtual machine Manager – Running standard Debian install

Once the installation is complete and the VM has rebooted you will have a functional Debian computer ready to use for whatever you like, just like a physical PC but, in virtual form. You’ll find that the VM runs as fast as the actual physical machine thanks to the kernel based virtualisation.

Virtual Machine Manager - Running VM
Virtual Machine Manager – Running VM

For more information on Virtual Machine Manager take a look at the Ubuntu Server documentation.

More soon …

Power surge kills UPS/RAID Array and more

Ever since we moved into the village of Eyke we’ve suffered with power cuts and power surges. It’s been that bad that we have a number of uninterruptible power supplies (UPS) dotted around the house to keep important things running when the power goes out.

Of late it’s been getting worse, not just the power cuts but, the power bouncing on and off very quickly for period of 10-15secs when the power comes back on. Unfortunately we had a particularly bad power bounce when the power came back on and it killed the main UPS for the IT equipment rack and also took out my RAID storage array that I use for backups.

On top of this the main server computer also took a hit and its solid state (SSD) drives started to fail. This left me in a position where I had no backups to recover from and had to get all the data off the running virtual machines (VMs) before the SSDs failed.

My old server that I decommissioned some months ago was now my radio shack PC and so had a desktop operating system on it and lots of HAM radio software installed and configured but, I needed to press it back into service as a server again, very quickly!

So after backing up the desktop data I rebuilt the computer as a server again and began the tedious job of building new VMs and migrating the configuration and data over from the old VMs.

You’re probably wondering why I didn’t just transfer the VMs over hole to the replacement server?
To do this I’d need to shut them down to get a clean snapshot however, when I tried it with a small, unimportant VM it became corrupt during the shutdown process and could no longer be transferred to the replacement server.

Not wanting to take the risk with any of the other VMs due to having lost all the backups, I decided to replicate all the VMs manually. Needless to say this isn’t a 5min job!

So, after a rather long week rebuilding everything I now have all the services up and running on the replacement server and the damaged server ready to be stripped down to an empty case and rebuilt from scratch.

This has meant that at times my M0AWS Blog, The Matrix server and other online services have been offline for short periods but, sadly there was nothing I could do about it. Unfortunately the national grid/power companies take no responsibility for such events and say they only guarantee the frequency of the mains power (50Hz) not the voltage!

The last entry in the old UPS log was an over voltage alert showing 1000v!

With a new UPS in place and online, we’ve already had a number of power cuts and it’s handled them well, lets hope we don’t get another big one!

Backups are now running again on external drives that are disconnected when not in use to protect them from power surges and all the services successfully migrated over to the replacement server.

More soon ….