In this guide, we will walk through the steps to set up Fedora Server on your Raspberry Pi 4. This guide assumes that you have some knowledge of using Linux, and have access to the necessary hardware and software components. Note that this guide has been created based on multiple sources and has been modified to reflect the specific requirements for a successful installation on the author’s device.
Hardware Requirements
- Raspberry Pi 4 Model B
- A microSD card with a capacity of at least 8GB
- A power supply for Raspberry Pi 4
- A microSD card reader
Software Requirements
- arm-image-installer
- A terminal emulator
- qemu-user-static
- qemu-user-static-binfmt
Step 1: Download Fedora Server Image
Download current raw image for aarch64 from https://getfedora.org/en/server/download/.
Step 2: Download UEFI Firmware
Next, download the current UEFI firmware for Raspberry Pi 4 from the following link: https://github.com/pftf/RPi4/releases. Unzip the file in a temporary location, such as the Downloads folder.
Step 3: Preparing The Raw Image
In this step, we will decompress the raw image and prepare it for use.
Decompress the image:
This will delete the original xz file after decompression and you will be left with Fedora-Server-37-1.7.aarch64.raw
. You can add --keep
to keep the compressed version.
Next, list the partitions in the raw image with fdisk:
The raw image has three partitions: .raw1
is the bootloader partition, .raw2
is the Linux boot partition (id 83), and .raw3
is the partition we want, a Linux LVM partition (id 8e) where Fedora is installed.
To mount the image at the right place, we need to calculate the mount offset as follows:
However, if we mount the image with this offset, it will fail:
To solve this issue, we need to use a tool like kpartx
. This utility creates a virtual device in /dev/mapper
that we can manipulate as a real device. Run the following command to add a device verbosely:
Then verify the new partitions in /dev/mapper
:
Finally, create a directory and mount the LVM partition to the new directory:
Step 4: Working Directly Within The Image
It’s time to start making changes to the image. To do this, we’ll use chroot
to change the working root of our session to the root from the image, or alternatively systemd-nspawn
. To support emulation between architectures, we’ll need to install qemu-user-static
, qemu-user-static-binfmt
and restart systemd-binfmt.service
.
Chroot to the mounted disk image and start a shell:
Ensure that the architecture is aarch64
and not x86_64
(use uname -a
).
Next, we’ll create a local user that we’ll use to connect via SSH later. The following commands create a group and user named pi
. The user will have a UID of 1000 and be assigned to the pi
and wheel
groups:
Create the .ssh
directory, the authorized_keys
file, and set proper permissions:
Add your public key (~/.ssh/id_rsa.pub
) to the authorized_keys
file.
Since our new user belongs to the wheel group, allow this group to use sudo without password:
Also, Fedora prompts you to finish the setup on the first boot. To avoid that, disable the initial setup:
Change the current directory to the EFI partition. Rename config.txt
to config.txt.save
.
And then you can ssh. Congratulations! You successfully connected to your new Fedora Server on your Raspberry Pi!
In the EFI partition, copy the updated firmware files that were downloaded in Step 2. This will replace several files and add a new config.txt
file:
In the EFI partition edit config.txt. It should have the following contents:
Change the contents to look like the contents below. The two changes are an addition of the kernel line a the top and comment out the armstub line. Be sure to comment out or delete the start_x=1 line if it exists. Save and exit the file:
That’s all we need to change. Exit the chroot and unmount the disk image:
Deactivate the logical volume inside the volume group fedora:
Then delete the virtual device:
Step 5: Installing the modified image
Two time-consuming tasks remain: compressing the image and installing it on a microSD card.
Compress the raw disk image to a .xz
file, but this time keep the .raw
file:
xz --compress Fedora-Server-37-1.7.aarch64.raw --keep
I recommend you keep the raw file if you want to make incremental changes in the future. Otherwise, remove the --keep
parameter.
This command will take a while.
Finally, copy the modified disk image to a microSD card:
This command will take some time as well.
Step 6: Validation
Power on the RPi4. Observe the behavior of the red and green LED lights and the network lights during the boot process, which may take several minutes. The red and green led lights on one end will variously blink, or stay steady, or go out. The network leds will stay steady for several minutes and go out at least twice. At the end, the red and green leds will go out and the network lights will start to blink, indicating that Fedora is now booted and requesting an IP address from your network’s DHCP service.
Subsequent boots are much faster.
Find the dynamic IP address assigned to your Raspberry Pi using nmap
or a similar tool on a Fedora machine or any other computer connected to your home network. Replace the CIDR range as necessary:
Connect to your new Fedora Server on the Raspberry Pi using ssh
. Congratulations! You have successfully connected to your new Fedora Server on your Raspberry Pi!