RockOS KVM Demo
RockOS supports KVM virtualization based on H Extension (RISC-V Hypervisor Extension).
Currently the following are verifed as working:
- Ubuntu 24.04.1 LTS & 24.10
- openEuler 24.03 LTS & 24.09
- FreeBSD 14.1-RELEASE
- Debian testing netinst CD
Environment
- OS Version: RockOS github
- Ubuntu preinstalled image: https://cdimage.ubuntu.com/releases/24.10/release/ubuntu-24.10-preinstalled-server-riscv64.img.xz
- openEuler 24.09 QEMU: https://repo.openeuler.org/openEuler-24.09/virtual_machine_img/riscv64/
- FreeBSD 14.1-RELEASE: https://download.freebsd.org/releases/VM-IMAGES/14.1-RELEASE/riscv64/Latest/
- Debian testing netinst CD: https://cdimage.debian.org/cdimage/weekly-builds/riscv64/iso-cd/debian-testing-riscv64-netinst.iso
- Debian sid cloud image: https://cdimage.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-riscv64-daily.qcow2
qemu-system-riscv64is installed by default- Manually install
wgetorcurlto download the image u-boot-qemuandqemu-efi-riscv64are provided in the repo, manually install them if needed
You can try other mirrors if the official server is too slow for you.
Steps
Currently QEMU does not support loading M Mode firmware via -bios while KVM is enabled. See comments here. So here are some of the options we have now:
- Use
u-boot.elfprovided byu-boot-qemupackage- You can boot Ubuntu and FreeBSD with this method.
- Use other firmwares
- e.g. openEuler RISC-V + EDK II (distributed along side with system image)
- EDK II comes with
qemu-efi-riscv64package
- Use
-initrd-kernel-appendflags- You can boot Ubuntu with this method.
- The BusyBox KVM Demo is also using this method.
- You can also boot FreeBSD this way according to FreeBSD Wiki.
- Not tested & not demonstrated in this article.
By default RockOS does not load KVM module on boot, so before we start, manually load it:
sudo modprobe kvm
Install required packages:
sudo apt update; sudo apt install -y wget u-boot-qemu qemu-efi-riscv64
Method A: Acquire U-Boot from u-boot-qemu package
For this method, we have Ubuntu preinstalled server image, FreeBSD and Debian netinst CD as examples.
Ubuntu
wget https://cdimage.ubuntu.com/releases/24.10/release/ubuntu-24.10-preinstalled-server-riscv64.img.xz
xz -dkv -T0 ubuntu-24.10-preinstalled-server-riscv64.img.xz
sudo qemu-system-riscv64 --enable-kvm -M virt -cpu host -m 2048 -smp 2 -nographic \
-device virtio-net-device,netdev=eth0 -netdev user,id=eth0 \
-device virtio-rng-pci \
-kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
-drive file=ubuntu-24.10-preinstalled-server-riscv64.img,format=raw,if=virtio
The default username and password are both ubuntu.
For Ubuntu preinstalled image, you'll be prompted to change your password on first boot. Follow the steps and you're good to go.
FreeBSD
wget https://download.freebsd.org/releases/VM-IMAGES/14.1-RELEASE/riscv64/Latest/FreeBSD-14.1-RELEASE-riscv-riscv64.qcow2.xz
xz -dkv -T0 FreeBSD-14.1-RELEASE-riscv-riscv64.qcow2.xz
sudo qemu-system-riscv64 --enable-kvm -M virt -cpu host -m 2048 -smp 2 -nographic \
-device virtio-net-device,netdev=eth0 -netdev user,id=eth0 \
-device virtio-rng-pci \
-kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
-drive file=FreeBSD-14.1-RELEASE-riscv-riscv64.qcow2,format=qcow2,if=virtio
Use username root for a passwordless login.
Debian cloud
Debian sid currently provides qcow2 disk images.
wget https://cdimage.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-riscv64-daily.qcow2
sudo qemu-system-riscv64 --enable-kvm -M virt -cpu host -m 2048 -smp 2 -nographic \
-device virtio-net-device,netdev=eth0 -netdev user,id=eth0 \
-device virtio-rng-pci \
-kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
-drive file=debian-sid-nocloud-riscv64-daily.qcow2,format=qcow2,if=virtio