Subject: How to boot RISC-V Alpine under QEMU?

From: "L. E. Segovia" <[email-masked]>
Date: Thu, 11 Sep 2025 20:17:19 -0300

Hi all,

I'm running into trouble setting up a QEMU VM for Alpine riscv64. To do
this I'm using the "Generic U-Boot tarball" from
https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/riscv64/alpine-uboot-3.22.1-riscv64.tar.gz.

What I've done so far is to:

- convert the tarball to a qcow2 image: virt-make-fs --partition=gpt
--type=ext4 --label=rootfs --format=qcow2 --size=16G
alpine-uboot-3.22.1-riscv64.tar.gz foo.qcow2

- try to boot it using: qemu-system-riscv64 -M virt -m 4G -smp 2
--kernel
alpine-uboot-3.22.1-riscv64/u-boot/qemu-riscv64_smode/u-boot.bin -drive
file=foo.qcow2 -serial stdio

QEMU can get into OpenSBI, it will recognise the partition and find the
"Linux lts" boot entry, boot it, but I will invariably get dropped into
an initramfs emergency recovery shell. Judging by the contents of the
/dev directory, the virtio-blk drive isn't available at all, and a look
at /lib/modules reveals that as-is the provided initramfs lacks the
kernel modules for QEMU's virtio devices.

I only need a VM with Internet connectivity that can be booted and
setup-alpine'd, not much more, so could anyone point out the way to make
this bootable?

Thanks in advance!

-- 
amyspark 🌸 https://www.amyspark.me