(Created page with "This page describes the steps necessary to get Fedora for RISC-V running on emulated hardware. = Quickstart = This section assumes that you have already set up libvirt/QEMU on your machine and you're familiar with them: if that's not the case, check out the Host setup section below. It also assumes that you're running Fedora 41 as the host. First of all, you need to download a disk image from https://dl.fedoraproject.org/pub/alt/risc-v/testing/f41/clou...") |
(→Host setup: storage driver is apparently needed too) |
||
Line 79: | Line 79: | ||
$ sudo dnf install \ | $ sudo dnf install \ | ||
libvirt-daemon-driver-qemu \ | libvirt-daemon-driver-qemu \ | ||
libvirt-daemon-driver-storage-core \ | |||
libvirt-daemon-driver-network \ | libvirt-daemon-driver-network \ | ||
libvirt-daemon-config-network \ | libvirt-daemon-config-network \ |
Latest revision as of 16:41, 14 December 2024
This page describes the steps necessary to get Fedora for RISC-V running on emulated hardware.
Quickstart
This section assumes that you have already set up libvirt/QEMU on your machine and you're familiar with them: if that's not the case, check out the Host setup section below. It also assumes that you're running Fedora 41 as the host.
First of all, you need to download a disk image from https://dl.fedoraproject.org/pub/alt/risc-v/testing/f41/cloud/
As of this writing, the most recent image is Fedora.riscv64-41.qcow2
so I will be using that throughout the section. If you're using a different image, you will need to adjust things accordingly.
Once you have downloaded the image, move it to a directory that libvirt has access to and give it a more appropriate name in the process:
$ sudo mv \ Fedora.riscv64-41.qcow2 \ /var/lib/libvirt/images/fedora-riscv.qcow2
You could boot the image right away, but it would come up completely unconfigured and you wouldn't have a way to even log into it. To take care of that, you need to create a couple additional files.
The first file is meta-data.json
and should contain something like this:
{ "local-hostname": "fedora-riscv" }
The second one is user-data.yaml
and should look like this instead:
#cloud-config password: riscv chpasswd: expire: false runcmd: - touch /etc/cloud/cloud-init.disabled
The password chosen in this file will be set for the default user, fedora
.
At this point, everything is ready and you can create the libvirt VM:
$ virt-install \ --import \ --name fedora-riscv \ --osinfo fedora-rawhide \ --arch riscv64 \ --cpu mode=maximum \ --vcpus 4 \ --ram 4096 \ --boot uefi \ --disk path=/var/lib/libvirt/images/fedora-riscv.qcow2 \ --network default \ --tpm none \ --graphics none \ --controller scsi,model=virtio-scsi \ --cloud-init meta-data=meta-data.json,user-data=user-data.yaml
You should see a bunch of output coming from edk2 (the UEFI implementation we're using), followed by the usual kernel boot messages and, eventually, a login prompt. Please be patient, as the use of emulation makes everything significantly slower. Additionally, cloud-init
has to set up a few things during the first boot, which slows things down further; subsequent boots will be a bit faster.
To shut down the VM, run poweroff
inside the guest OS. To boot it up again, use
$ virsh start fedora-riscv --console
Host setup
The steps outlined above assume that your machine is already set up for running RISC-V VMs. If that's not the case, read on.
At the very least, the following package will need to be installed:
$ sudo dnf install \ libvirt-daemon-driver-qemu \ libvirt-daemon-driver-storage-core \ libvirt-daemon-driver-network \ libvirt-daemon-config-network \ libvirt-client \ virt-install \ qemu-system-riscv-core \ edk2-riscv64
This will result in a fairly minimal install, suitable for running headless VMs. If you'd rather have a fully-featured install, add libvirt-daemon-qemu
and libvirt-daemon-config-nwfilter
to the list. Be warned though: doing so will result in significantly more packages being dragged in, some of which you might not care about (e.g. support for several additional architectures).
In order to grant your user access to libvirt and allow it to manage VMs, it needs to be made a member of the corresponding group:
$ sudo usermod -a -G libvirt $(whoami)
Finally, the default libvirt URI needs to be configured:
$ mkdir -p ~/.config/libvirt && \ echo 'uri_default = "qemu:///system"' >~/.config/libvirt/libvirt.conf
Now reboot the host. This is necessary because the changes to group membership won't be effective until the next login, and because the libvirt services are not automatically started during package installation.
After rebooting and logging back in, virsh
should work and the default network should be up:
$ virsh uri qemu:///system $ virsh net-list Name State Autostart Persistent -------------------------------------------- default active yes yes
All done! You can now start creating RISC-V VMs.