Kvm

Migrating Pi 5 from microSD to USB3 Samsung 870 EVO SSD, and Pitfalls

Since I use Raspberry Pi 5 as a virtual machine (VM) host for Home Assistant OS (HAOS) in KVM, I want a system that is simple, stable, and reliable.
After repeated microSD drawbacks, I selected the Samsung 870 EVO SSD 500GB via USB3 over my previous Raspberry Pi 128GB microSD U2 for system storage.

Performance Comparison: microSD vs USB3 SSD

To quantify the improvement, I used:

curl https://raw.githubusercontent.com/TheRemote/PiBenchmarks/master/Storage.sh | sudo bash

Results

Test microSD Card Samsung 870 EVO SSD Improvement
HDParm Disk Read 87.11 MB/sec 362.74 MB/sec 4.2x faster
HDParm Cached Disk Read 83.74 MB/sec 352.69 MB/sec 4.2x faster
DD Disk Write 71.0 MB/sec 306 MB/sec 4.3x faster
FIO 4k Random Read 7,322 IOPS 40,156 IOPS 5.5x faster
FIO 4k Random Write 4,070 IOPS 35,679 IOPS 8.8x faster
IOZone 4k Read 22,064 KB/sec 45,015 KB/sec 2x faster
IOZone 4k Write 10,453 KB/sec 44,799 KB/sec 4.3x faster
IOZone 4k Rand Read 22,012 KB/sec 23,832 KB/sec 1.1x faster
IOZone 4k Rand Write 14,664 KB/sec 44,969 KB/sec 3.1x faster
Overall PiBenchmarks Score 4098 14655 +3.6x higher

Summary:
The USB3 SSD is consistently at least 4x faster for sequential reads/writes, and up to 9x faster for random IO operations. This means faster boot times, quicker VM performance, and far more reliability for Home Assistant and other hosted services.

Add Zigbee Dongle to Home Assistant VM (Raspberry Pi 5)

Introduction

This guide shows how to pass through the SONOFF Zigbee 3.0 USB Dongle Plus to a Home Assistant OS (HAOS) virtual machine running on Raspberry Pi 5 using KVM/libvirt. This allows you to use Zigbee devices directly within your virtualized Home Assistant setup.

Why Pass Through USB Devices to Virtual Machines?

When running Home Assistant OS (HAOS) in a virtualized environment on Raspberry Pi 5, smart home automation requires direct hardware access for wireless communication protocols like Zigbee that depend on dedicated USB dongles.

Our technology stack includes the Raspberry Pi 5 hardware layer, Raspberry Pi OS host, QEMU/KVM hypervisor, libvirt management daemon, and HAOS guest OS. By default, the guest VM cannot directly access USB devices connected to the host system due to hypervisor isolation.

USB passthrough solves this by “passing” a physical USB device from the host directly to the virtual machine, essential for Zigbee coordinators like the SONOFF Zigbee 3.0 USB Dongle Plus.

If setting up a new HAOS VM with the dongle already connected, you can include passthrough during virt-install using --hostdev 003.002. However, when adding hardware to an existing setup, you’ll need to modify the running VM configuration using libvirt’s XML system.

Installing Home Assistant OS (HAOS) in KVM on Raspberry Pi 5

Running Home Assistant OS (HAOS) natively on a Raspberry Pi is common, but virtualizing it in KVM unlocks flexibility for home lab setups or multi-purpose Pi 5 systems. This guide shows you, step-by-step, how to set up HAOS in a KVM virtual machine on your Raspberry Pi 5 (64-bit).

Technology Stack Components:

  • Hardware Layer: Raspberry Pi 5 with ARM64 architecture and hardware virtualization extensions
  • Host OS: Raspberry Pi OS (Debian-based) providing the foundation
  • Hypervisor: QEMU/KVM for hardware-accelerated virtualization
  • Management Layer:
    • libvirt daemon for VM lifecycle management and networking
    • Cockpit web UI (with cockpit-machines) for graphical VM administration
  • Guest OS: Home Assistant Operating System running as an isolated virtual machine
  • Network Bridge: Direct ethernet connection allowing VM to appear as a native network device

Prerequisites

  • Raspberry Pi 5 running Raspberry Pi OS 64-bit (Bookworm or newer recommended)
  • Sufficient RAM (at least 4GB, 8GB strongly recommended)
  • Hardware virtualization support enabled (available by default on RPi5)
  • Basic Linux terminal skills