Fedora - Raspberry Pi Setup

Fedora Jun 22, 2021

Fedora Linux is a modern Linux distribution, which can be used on your workstation, server and everything between. It is not very well known, but you can deploy Fedora Linux on your Raspberry Pi, too. Let's see what you get when opting for Fedora.

Raspberry Pi

The Raspberry Pi is the most popular consumer System on a Chip (SoC) in the market. You can get your hands on a Raspberry Pi 4 for just $35. You will get a chip-card sized and fanless little computer, which can be used for all kinds of tinkering and small projects.

The Raspberry Pi 4 comes with Gigabit Ethernet, USB3, configurable 2/4/8 GB of RAM and an ARM v8 64-bit CPU with 1,5 GHz. You can find the full specifications and details over here.

The little board provides everything you need to run some small applications and integrate it in your home/lab environment. You can run a Nextcloud instance, deploy some containers or use the GPIO ports to connect your own circuits to it.

Fedora Linux

Fedora Linux is a modern, Open Source Linux distribution, that provides everything you need for development. You will find support for multiple architectures, including aarch64, which is perfect for a setup on the Raspberry Pi 4.

For this guide, I will focus on some features, that are different to the well known Raspberry distribution alternatives. Fedora comes per default with SELinux and Firewalld, which adds lots of security. You are also getting Podman as the pre-installed container engine. For GPIO support, you are getting libgpiod in the repositories.

Let's see what we can do with Fedora Linux on the Raspberry Pi 4.

Installation

The installation of Fedora to a SD Card is pretty easy and straight forward. For the first installation, it is recommended to have a Keyboard and Monitor connected to the Raspberry Pi, but it is not needed.

Hint
The guide is tested with Fedora 34 on a Raspberry Pi 3/4.

Download

First, you need to download Fedora Linux for aarch64. For this tutorial, I am using the Fedora Server 34 raw image for aarch64, which can be found here.

You can also use other raw images like the Workstation variant or Fedora IoT. I have written some articles about both in the past, if you want to inform yourself.

For the Fedora Workstation image, you need to be aware, that performance may be significantly slower than you can expect on a notebook, but it is somewhat OK. For Fedora IoT some commands are slightly different, and I will provide them, if needed.

Prepare SD Card

After the successful download of your desired image, you need to put it on a SD card.

Arm image installer

If you are running on Fedora already, you can use the ARM image installer to prepare new SD cards.

The below commands should be sufficient for most cases and prepare the SD card for the Raspberry Pi 4. In addition, the image will consume the entire SD card.

# Install arm image installer
$ sudo dnf install arm-image-installer

# Write image to SD card
$ sudo arm-image-installer --image PATH/TO/IMAGE.raw.xz \
  --addkey PATH/TO/KEY.pub \
  --resizefs \
  --target rpi4 \
  --media /PATH/TO/SDCARD

# Write image to SD card (example)
sudo arm-image-installer --image Fedora-Server-34-1.2.aarch64.raw.xz \
  --addkey ~/.ssh/id_ed25519.pub \
  --resizefs \
  --target rpi4 \
  --media /dev/mmcblk0

There are way more options to add a console output or updating uboot or removing the root password entirely.

dd (for Linux and macOS)

If you don't use Fedora, but you have access to the "dd" command, you can write images, too. First, you need to copy the image to the SD card with the below command.

 # Write image to SD card
 $ xzcat /PATH/TO/IMAGE | sudo dd status=progress bs=4M of=/PATH/TO/SDCARD
 
 # Write image to SD card (example)
 $ xzcat Fedora-Server-34-1.2.aarch64.raw.xz | sudo dd status=progress bs=4M of=/dev/mmcblk0
 

Afterwards, you need to resize the image, so it uses the entire SD card. This can be done before booting with a partitioning tool like gparted.

$ gparted /PATH/TO/SDCARD

You can also boot the Raspberry Pi with a keyboard and display attached and resize the disk after the "First boot". This will be explained in the next section.

# enlarge the 3rd partition
$ sudo growpart /dev/mmcblk0 3

# resize the physical volume
$ sudo pvresize /dev/mmcblk0p3

# extend the root filesystem
$ sudo lvextend -l +100%FREE /dev/fedora/root

# resize root partition
$ sudo xfs_growfs -d /

Other methods

If the above options are not sufficient for you, please check out the official Raspberry Pi documentation for more possibilities of writing images to a SD card. You can find guides for macOS here and Windows here.

You can also find a very detailed guide over at the Fedora documentation.

First Boot

After the initial boot, you will be greeted by an assistant. The assistant will help you to create a user, configure the network and more. The assistant is only available on a display, connected to the Raspberry Pi and not via SSH.

If you used the ARM image installer, you are already having your public key copied to the root user, and you may ignore the assistant.

Resize SD card

If you haven't used the ARM image installer or gparted to resize your SD card, you can have a look at the below commands. Otherwise, please feel free to skip this part.

# enlarge the 3rd partition
$ sudo growpart /dev/mmcblk0 3

# resize the physical volume
$ sudo pvresize /dev/mmcblk0p3

# extend the root filesystem
$ sudo lvextend -l +100%FREE /dev/fedora/root

# resize root partition
$ sudo xfs_growfs -d /

This should do the trick and your Fedora image can use the available SD card space.

Update the System

I strongly recommend updating the system after the first boot. Please run the below commands, depending on your image choice.

# Update Fedora Workstation/Server
$ sudo dnf update -y
$ sudo reboot

# Update Fedora IoT/Silverblue
$ rpm-ostree upgrade
$ reboot

Adding workloads

Now that you have a Raspberry Pi with Fedora Linux on it, you may want to add some Workloads on it. In this section, I will give a brief overview of what you can do.

Installing packages

Most packages, that are available for x86_64 variants of Fedora Linux, are also available for aarch64. You can simply install Apache httpd, MariaDB or whatever you like. In the below example, I will demonstrate how you can set up the Cockpit web interface.

# Install Cockpit on Fedora Workstation/Server
$ sudo dnf install cockpit cockpit-podman -y

# Install Cockpit on Fedora IoT/Silverblue
$ rpm-ostree install cockpit
$ reboot

# Start and enable the Cockpit Socket
$ sudo systemctl enable --now cockpit.socket

Afterwards, you can log in to your Raspberry Pi via https://IPADDRESS:9090 and administrate it via a Web Ui. You will also be able to start and stop containers via Podman via Cockpit, review the logs or update the system.

Running containers

Running some containers is my preferred way to deploy workload on Fedora. Since Podman is already there, this is very easy. For example, we may want to deploy a Nextcloud instance for testing purposes.

# Deploy nextcloud (test instance)
$ sudo podman run -dt -p 8080:80 docker.io/library/nextcloud:21

After some seconds, you will be able to browse to http://IPADDRESS:8080 and initialize the instance.

If you want to learn more about Podman and container deployments, please have a look here.

Fedora provides lots of documentation for Fedora Linux on ARM and Fedora IoT. In addition, you can also find several related articles on te Fedora Magazine.

Architectures/ARM - Fedora Project Wiki
Welcome :: Fedora Docs
Running Rosetta@home on a Raspberry Pi with Fedora IoT - Fedora Magazine
Contribute to the Rosetta@home distributed computing project with just a Raspberry Pi, whilst learning about Fedora IoT and podman. Fedora Magazine
How to turn on an LED with Fedora IoT - Fedora Magazine
Check out this Fedora Magazine article to learn about Fedora IoT and how to use it as a container to interact with hardware like a GPIO and LED.

Conclusion

At least for me, Fedora is another nice option for my Raspberry Pi. It works like a charm and I don't need to adapt. I just can use most my already known commands and concepts to deploy containers, workloads or interact with the system.

Tags

Daniel Schier

Just a guy doing stuff. Mostly #FLOSS like #Linux, #Ansible, #Podman, #K8s, #Python, #Nextcloud or whatever comes next.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.