From Fedora Project Wiki
(Reboot page. Just a quickstart section for now, I'll expand it later.)
(Update for 20250224 image)
 
(21 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This page describes the steps necessary to get Fedora for RISC-V running, either on emulated or real hardware.
This page explains how to get Fedora running on either physical or virtual RISC-V hardware.  


= Quickstart =
= Disclaimer =


This section assumes that you have already set up libvirt/QEMU on your machine and you're familiar with them, so it only highlights the details that are specific to RISC-V. It also assumes that you're running Fedora 40 as the host.
riscv64 is currently '''not''' an officially supported Fedora architecture.


First of all, you need to download a disk image from http://fedora.riscv.rocks/koji/tasks?state=closed&view=flat&method=createAppliance&order=-id
Most packages are built from unmodified Fedora sources, but in several cases architecture-specific patches are necessary. There is an ongoing effort to reduce (and eventually eliminate) this delta. Check out the [https://abologna.gitlab.io/fedora-riscv-tracker/ tracker] to see the current status.


As of this writing, the most recent image is <code>Fedora-Minimal-40-20240502.n.0-sda.raw.xz</code> so I will be using that throughout the section. If you're using a different image, you will need to adjust things accordingly.
Hardware support is limited to what mainline Linux provides, and that usually doesn't include the SoC's integrated GPU. Fedora RISC-V is primarily intended to be used as a headless build host / server environment for now.


Once you've downloaded the image, start by uncompressing it:
= Generic instructions =
 
The following installation steps are applicable to most hardware.
 
If your machine is listed in the [[#Machine-specific instructions|machine-specific instructions]] section below, make sure you check out the corresponding page first, as it might contain important information that (partially or completely) supersedes what's written here.
 
== Requirements ==
 
=== Serial console access ===
 
While <code>ssh</code> is likely going to be the primary way you'll interact with the machine, it's useful to have serial console access as a fallback. Moreover, it is '''required''' for the initial setup.
 
The process of connecting the USB to serial adapter is machine-specific and can't be documented in a generic fashion.
 
First of all, make sure your user is in the <code>dialout</code> group:


<pre>
<pre>
$ unxz Fedora-Minimal-40-20240502.n.0-sda.raw.xz
$ sudo usermod -a -G dialout $(whoami)
</pre>
</pre>


You need to figure out the root filesystem's UUID so that you can later pass this information to the kernel. The <code>virt-filesystems</code> utility, part of the <code>guestfs-tools</code> package, takes care of that:
This is necessary to access the serial console. Log out and back in for the change to take effect.
 
Now plug the USB to serial adapter into your computer. If you only have one such adapters connected, it should show up as <code>/dev/ttyUSB0</code>.
 
Create a configuration file for <code>minicom</code>, with the name you like, for example <code>~/.minirc.RISCV</code>. The contents should look like this:
 
<pre>
pu port            /dev/ttyUSB0
pu baudrate        115200
pu bits            8
pu parity          N
pu stopbits        1
pu rtscts          No
</pre>
 
You will now be able to connect to the serial console by running:
 
<pre>
$ minicom RISCV
</pre>
 
For added reliability, you can use a stable device name in the configuration file. For example:
 
<pre>
$ ls -l /dev/serial/by-id/*
/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0 -> ../../ttyUSB0
</pre>
 
This output indicates that you should replace <code>/dev/ttyUSB0</code> with <code>/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0</code> in the configuration file.
 
== Media preparation ==
 
=== Downloading the disk image ===
 
Disk images can be obtained from:
 
* https://dl.fedoraproject.org/pub/alt/risc-v/release/41/Server/riscv64/images/
 
As of this writing, the most recent disk image is:
 
* [https://dl.fedoraproject.org/pub/alt/risc-v/release/41/Server/riscv64/images/Fedora-Server-Host-Generic-41.20250224-1026a2d0e311.riscv64.raw.xz <code>Fedora-Server-Host-Generic-41.20250224-1026a2d0e311.riscv64.raw.xz</code>]
 
The file you've just downloaded will be referred to as <code>IMAGE.raw.xz</code> below.
 
A matching <code>IMAGE.raw.xz.sha256</code> file is also provided: this allows you to validate the integrity of your download.
 
=== Writing the disk image to the target media ===
 
The disk image is intended to work regardless of the type of media it's written to: SD cards, USB sticks, NVMe and SATA drives are all known to work. NVMe is preferred, if available on your machine, because it performs the best, but you can choose whatever is more suitable to you. SD cards, for example, are great when you want to test a disk image without affecting your existing installation.
 
The disk image comes compressed, so the first step after downloading it is to uncompress it:


<pre>
<pre>
$ virt-filesystems \
$ unxz IMAGE.raw.xz
    -a Fedora-Minimal-40-20240502.n.0-sda.raw \
    --long \
    --uuid \
  | grep ^btrfsvol: \
  | awk '{print $7}' \
  | sort -u
ae525e47-51d5-4c98-8442-351d530612c3
</pre>
</pre>


Additionally, you need to extract the kernel and initrd from the disk image. The <code>virt-get-kernel</code> tool automates this step:
The compressed <code>IMAGE.raw.xz</code> file will be replaced by the uncompressed <code>IMAGE.raw</code> file. The latter is the one that can be written to the target media.
 
There are several tools that can be used for writing the disk image. <code>dd</code> is perhaps the most common option:


<pre>
<pre>
$ virt-get-kernel \
$ sudo dd iflag=fullblock oflag=direct status=progress bs=4M if=IMAGE.raw of=/dev/TARGET
    -a Fedora-Minimal-40-20240502.n.0-sda.raw
download: /boot/vmlinuz-6.8.7-300.4.riscv64.fc40.riscv64 -> ./vmlinuz-6.8.7-300.4.riscv64.fc40.riscv64
download: /boot/initramfs-6.8.7-300.4.riscv64.fc40.riscv64.img -> ./initramfs-6.8.7-300.4.riscv64.fc40.riscv64.img
</pre>
</pre>


Now move all the files to a directory that libvirt has access to:
Replace `/dev/TARGET` with the name of the actual target device. Please be '''extremely careful''' and ensure that you're using the correct name here: if you get it wrong, you risk '''destroying''' your current OS.
 
[https://etcher.balena.io/ balenaEtcher] is another popular option. It's a user-friendly GUI that should make it a lot harder to mess things up.
 
== First boot ==
 
Once the disk image has been written to the target media, you can pop that into your machine and power it on.
 
The process of getting the firmware to boot from the media is machine-specific and can't be documented in a generic fashion. It usually helps if only one media is connected to the machine at any given time.
 
Assuming everything is fine, after a few seconds you should see the usual Linux boot messages scroll by on the serial console.
 
After a short while, you will be presented with a login prompt. You can use login `fedora` and password `linux` to gain access.
 
== Post-installation tasks ==
 
=== Enable the performance CPU governor ===
 
The default CPU governor is `schedutils`, which scales the CPU frequency dynamically. If you want to squeeze every last bit of performance out of your machine, you might want to switch to the `performance` CPU governor. To do so, simply run:


<pre>
<pre>
$ sudo mv
$ sudo grubby --update-kernel=ALL --args=cpufreq.default_governor=performance
    Fedora-Minimal-40-20240502.n.0-sda.raw \
    vmlinuz-6.8.7-300.4.riscv64.fc40.riscv64 \
    initramfs-6.8.7-300.4.riscv64.fc40.riscv64.img \
    /var/lib/libvirt/images/
</pre>
</pre>


At this point, everything is ready and you can create the libvirt VM:
A reboot is necessary for the change to take effect.
 
=== Disable use of tmpfs for /tmp ===
 
Fedora uses `tmpfs` for `/tmp` by default, but that might cause issues if your machine doesn't have much RAM. If you run into OOMs or other related issues, you can revert to disk-backed `/tmp` by running:


<pre>
<pre>
$ virt-install \
$ sudo systemctl mask tmp.mount
    --import \
    --name fedora-riscv \
    --osinfo fedora40 \
    --arch riscv64 \
    --vcpus 4 \
    --ram 4096 \
    --boot uefi,kernel=/var/lib/libvirt/images/vmlinuz-6.8.7-300.4.riscv64.fc40.riscv64,initrd=/var/lib/libvirt/images/initramfs-6.8.7-300.4.riscv64.fc40.riscv64.img,cmdline='root=UUID=ae525e47-51d5-4c98-8442-351d530612c3 ro rootflags=subvol=root rhgb LANG=en_US.UTF-8 console=ttyS0 earlycon=sbi' \
    --disk path=/var/lib/libvirt/images/Fedora-Minimal-40-20240502.n.0-sda.raw \
    --network default \
    --graphics none
</pre>
</pre>


Note how the UUID discovered earlier is included in the kernel command line. Quoting is also very important to get right.
A reboot is necessary for the change to take effect.


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, a SELinux relabel followed by a reboot will be performed as part of the import process, which slows things down further. Subsequent boots will be a lot faster.
=== Enable haveged ===


To shut down the VM, run <code>poweroff</code> inside the guest OS. To boot it up again, use
If your machine doesn't have a hardware RNG, it might take a long time to boot or accept ssh logins. A possible workaround is to configure a software RNG like so:


<pre>
<pre>
$ virsh start fedora-riscv --console
$ sudo dnf install -y haveged
$ sudo systemctl enable --now haveged.service
</pre>
</pre>
= Machine-specific instructions =
While the information above is generally applicable, some machines require additional or even completely different steps.
== Physical hardware ==
* [[Architectures/RISC-V/StarFive/VisionFive2|StarFive VisionFive 2]]
* [[Architectures/RISC-V/SiFive/HiFiveUnmatched|SiFive HiFive Unmatched]]
* [[Architectures/RISC-V/SiFive/HiFivePremierP550|SiFive HiFive Premier P550]]
== Virtual hardware ==
* [[Architectures/RISC-V/QEMU|QEMU]]

Latest revision as of 10:55, 26 February 2025

This page explains how to get Fedora running on either physical or virtual RISC-V hardware.

Disclaimer

riscv64 is currently not an officially supported Fedora architecture.

Most packages are built from unmodified Fedora sources, but in several cases architecture-specific patches are necessary. There is an ongoing effort to reduce (and eventually eliminate) this delta. Check out the tracker to see the current status.

Hardware support is limited to what mainline Linux provides, and that usually doesn't include the SoC's integrated GPU. Fedora RISC-V is primarily intended to be used as a headless build host / server environment for now.

Generic instructions

The following installation steps are applicable to most hardware.

If your machine is listed in the machine-specific instructions section below, make sure you check out the corresponding page first, as it might contain important information that (partially or completely) supersedes what's written here.

Requirements

Serial console access

While ssh is likely going to be the primary way you'll interact with the machine, it's useful to have serial console access as a fallback. Moreover, it is required for the initial setup.

The process of connecting the USB to serial adapter is machine-specific and can't be documented in a generic fashion.

First of all, make sure your user is in the dialout group:

$ sudo usermod -a -G dialout $(whoami)

This is necessary to access the serial console. Log out and back in for the change to take effect.

Now plug the USB to serial adapter into your computer. If you only have one such adapters connected, it should show up as /dev/ttyUSB0.

Create a configuration file for minicom, with the name you like, for example ~/.minirc.RISCV. The contents should look like this:

pu port             /dev/ttyUSB0
pu baudrate         115200
pu bits             8
pu parity           N
pu stopbits         1
pu rtscts           No

You will now be able to connect to the serial console by running:

$ minicom RISCV

For added reliability, you can use a stable device name in the configuration file. For example:

$ ls -l /dev/serial/by-id/*
/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0 -> ../../ttyUSB0

This output indicates that you should replace /dev/ttyUSB0 with /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0 in the configuration file.

Media preparation

Downloading the disk image

Disk images can be obtained from:

As of this writing, the most recent disk image is:

The file you've just downloaded will be referred to as IMAGE.raw.xz below.

A matching IMAGE.raw.xz.sha256 file is also provided: this allows you to validate the integrity of your download.

Writing the disk image to the target media

The disk image is intended to work regardless of the type of media it's written to: SD cards, USB sticks, NVMe and SATA drives are all known to work. NVMe is preferred, if available on your machine, because it performs the best, but you can choose whatever is more suitable to you. SD cards, for example, are great when you want to test a disk image without affecting your existing installation.

The disk image comes compressed, so the first step after downloading it is to uncompress it:

$ unxz IMAGE.raw.xz

The compressed IMAGE.raw.xz file will be replaced by the uncompressed IMAGE.raw file. The latter is the one that can be written to the target media.

There are several tools that can be used for writing the disk image. dd is perhaps the most common option:

$ sudo dd iflag=fullblock oflag=direct status=progress bs=4M if=IMAGE.raw of=/dev/TARGET

Replace /dev/TARGET with the name of the actual target device. Please be extremely careful and ensure that you're using the correct name here: if you get it wrong, you risk destroying your current OS.

balenaEtcher is another popular option. It's a user-friendly GUI that should make it a lot harder to mess things up.

First boot

Once the disk image has been written to the target media, you can pop that into your machine and power it on.

The process of getting the firmware to boot from the media is machine-specific and can't be documented in a generic fashion. It usually helps if only one media is connected to the machine at any given time.

Assuming everything is fine, after a few seconds you should see the usual Linux boot messages scroll by on the serial console.

After a short while, you will be presented with a login prompt. You can use login fedora and password linux to gain access.

Post-installation tasks

Enable the performance CPU governor

The default CPU governor is schedutils, which scales the CPU frequency dynamically. If you want to squeeze every last bit of performance out of your machine, you might want to switch to the performance CPU governor. To do so, simply run:

$ sudo grubby --update-kernel=ALL --args=cpufreq.default_governor=performance

A reboot is necessary for the change to take effect.

Disable use of tmpfs for /tmp

Fedora uses tmpfs for /tmp by default, but that might cause issues if your machine doesn't have much RAM. If you run into OOMs or other related issues, you can revert to disk-backed /tmp by running:

$ sudo systemctl mask tmp.mount

A reboot is necessary for the change to take effect.

Enable haveged

If your machine doesn't have a hardware RNG, it might take a long time to boot or accept ssh logins. A possible workaround is to configure a software RNG like so:

$ sudo dnf install -y haveged
$ sudo systemctl enable --now haveged.service

Machine-specific instructions

While the information above is generally applicable, some machines require additional or even completely different steps.

Physical hardware

Virtual hardware