bgsmith
Posts: 4
Joined: Mon Nov 23, 2020 4:28 pm

Headless (mostly) Fedora CoreOS on RPi4 - A Brief How To (updated 9 Oct)

Tue Feb 16, 2021 9:45 pm

Update - 9 Oct 2021

The steps below are still viable with the following updates. Fedora is close to officially supporting FCOS on aarch64. Builds are (at this time) available at: https://builds.coreos.fedoraproject.org ... ch=aarch64.

My workstation is now Fedora 34 and I installed Fedora CoreOS 34 on an RPi4. I used v 1.31 of the RPI4-UEFI firmware.

After the coreos-installer completed, along with the tune2fs update to partition 3, I found that I needed to reformat the EFI-SYSTEM partition (partition 2) as FAT32. At this time, coreos-installer uses FAT16 for the EFI partition, and the RPI4 will not read FAT16. Copy the files off of the partition, format to fat32 (e.g. sudo mkfs.vfat -F 32 /dev/sdh2 where the USD disk is mounted at /dev/sdh) and replace the files.

Please note that at this time, FCOS does not appear to be aware of the device tree blob for RPi4 - either the upstream kernel blob nor the downstream Raspberry Pi version. I am still exploring this topic. My personal interest in device trees revolves around the upstream kernel module for the Raspberry POE Hat fan which is new in 5.13 and later kernels. This works really well with Fedora minimal on an RPi4 and helps keep headless RPi4 boards cool in a kubernetes cluster.

Update - 17 Feb 2021. Corrected description of EFI-SYSTEM partition.

Inspired by Robert Grimm and his post at https://fwmotion.com/blog/operating-sys ... on-raspi4/, I followed his process and installed Fedora CoreOS (FCOS) on a Raspberry Pi 4. His process basically creates a build environment for CoreOS.

If you do not need a CoreOS build environment or are just looking to do a quick test drive of CoreOS on an RPi4 then the steps outlined below are much less time consuming, although you do need to implicitly trust the builds posted at a fedorapeople,org.

Please note that these steps work as of February 2021 and are based on FCOS builds posted at https://fedorapeople.org/groups/fcos-images/builds/ as Fedora does not yet provide official aarch64 FOCS builds. If/when official builds are provided, I will amend this post.

Assumptions
  1. This is done on a home network.
  2. DHCP is available on the network.
  3. A network cable and a port on your router/switch is available for the PI4. I have not tested this process with the wireless network capabilities of the PI4.
References
https://www.spinics.net/linux/fedora/fe ... 13404.html
https://github.com/coreos/fedora-coreos ... -703183547

I am using a Fedora 33 workstation to do this work. The RPi4 is an 8 GB model. I install FCOS to a Kingston 120 GB SSD which is attached to the RPi with a StarTech USB 3 SATA cable.

Required software and capabilities on your workstation:
  1. Fedora CoreOS transpiler - fcct - this is available from the Fedora repo. If using another OS, then please see online instructions on how to run fcct in a container.
  2. CoreOS Installer - coreos-installer - this is available from the Fedora repo. If using another OS, then please see online instructions on how to run coreos-installer in a container.
  3. e2fsck - ext file system checker
  4. tune2fs - ext file system tuner
  5. Ability to sudo.
Steps
  1. Ensure that the RPi4 has a current boot eeprom. Online documentation at https://www.raspberrypi.org/documentati ... teeprom.md. I find it useful to keep a microSD card handy with raspian OS that I can use as needed for eeprom updates as this capability is not yet available in Fedora.
  2. Download the build image from https://fedorapeople.org/groups/fcos-images/builds/. I use the 'latest' directory link. The file to down load is https://fedorapeople.org/groups/fcos-im ... arch64.raw.
  3. Download the latest release from the RPI4-UEFI project at https://github.com/pftf/RPi4/releases. I am using v1.22 for this note.
  4. Unzip the RPI4-UEFI zip file in a directory. The result should look similar to this:

    Code: Select all

    bgsmith@pico fcos]$ ls -la ~/Downloads/rpi4/efi-1.22/
    total 4324
    drwxr-xr-x. 3 bgsmith bgsmith    4096 Feb  3 12:12 .
    drwxr-xr-x. 7 bgsmith bgsmith    4096 Feb 12 10:01 ..
    -rw-r--r--. 1 bgsmith bgsmith   48145 Jan  6 12:40 bcm2711-rpi-400.dtb
    -rw-r--r--. 1 bgsmith bgsmith   47972 Jan  6 12:40 bcm2711-rpi-4-b.dtb
    -rw-r--r--. 1 bgsmith bgsmith   48303 Jan  6 12:40 bcm2711-rpi-cm4.dtb
    -rw-r--r--. 1 bgsmith bgsmith     206 Jan  6 12:37 config.txt
    -rw-r--r--. 1 bgsmith bgsmith    5428 Jan  6 12:39 fixup4.dat
    drwxr-xr-x. 2 bgsmith bgsmith    4096 Feb  3 12:12 overlays
    -rw-r--r--. 1 bgsmith bgsmith    5240 Jan  6 12:37 Readme.md
    -rw-r--r--. 1 bgsmith bgsmith 2031616 Jan  6 12:47 RPI_EFI.fd
    -rw-r--r--. 1 bgsmith bgsmith 2213312 Jan  6 12:40 start4.elf
    
  5. Plug the USB drive (SSD or USB Flash or even a microSD card) into your workstation. My F33 workstation usually mounts these at /dev/sdf but you will need to verify which device is assigned by your computer. Please note the install step will erase all content on the USB.
  6. Create an ignition yaml file. Please see the CoreOS documentation at https://docs.fedoraproject.org/en-US/fe ... ucing-ign/ for background and a simple example. The ignition yaml example below adds an ssh key to the default 'core' user, adds a 'pi' user with the same key, adds the pi user to the wheel and sudo groups, assigns a hostname, and disables the docker service. Substitute your own publc ssh key. Also note that an ssh-ed25519 key is preferred as an rsa256 will no longer work by default (this is true across all Fedora 33 releases).

    Code: Select all

    ---
    variant: fcos
    version: 1.2.0
    passwd:
      users:
        - name: core
          groups:
            - wheel
          ssh_authorized_keys:
            - "ssh-ed25519 AAAAC3..."
        - name: pi
          groups:
            - wheel
            - sudo
          ssh_authorized_keys:
            - "ssh-ed25519 AAAAC3...."
    storage:
      files:
        - path: /etc/hostname
          mode: 0644
          contents:
            inline: pi01.lan
    systemd:
      units:
        - name: docker.service
          mask: true
    
  7. Transpile the yaml file to an ignition file. In the example below, the yaml file is fc1.yaml and fcct will generate the fc1.ign ignition file.

    Code: Select all

    fcct -s -o fc1.ign fc1.yaml
  8. Install CoreOS to the USB (/dev/sdf in the example) using the ignition file and the image file downloaded before.

    Code: Select all

    sudo coreos-installer install /dev/sdf -i ./fc1.ign -f fedora-coreos-33.20210127.dev.0-metal.aarch64.raw --offline --insecure
    .
  9. The installer will create 4 gpt partitions on the USB device. Note that on first boot, the root file system partition will be automatically expanded to the maximum size possibly on the USB device.
    1. The protective master boot record partition. Basically a place holder to help GPT-unaware software.
    2. The EFI system partition. This will be empty contain a subdirectory tree named EFI but no files in the top level directory. This is where the UEFI boot files will go.
    3. The Fedora CoreOS boot partition
    4. The Fedora CoreOS root file system.
  10. Mount the EFI system partition. If the device is /dev/sdf on the computer then mount /dev/sdf2. Fedora will mount USB partitions in /run/media/username (e.g. /run/media/bgsmith for me).
  11. Change into the mounted partition.

    Code: Select all

    cd /run/media/bgsmith/EFI-SYSTEM
  12. Copy the RPI4 UEFI files down loaded in step 4 above to the EFI system partition. Note there is an overlay subdirectory that will be copied.

    Code: Select all

    cp -r ~/Downloads/rpi4/efi-1.22/* .
  13. As noted at https://github.com/coreos/fedora-coreos ... -703183547 there is a bug in the FCOS first boot script that will hang the boot process. The workaround is to first manually run tune2fs on the boot partition. The boot partition is partition 3 created by the installer. If the USB is at /dev/sdf then run:

    Code: Select all

    sudo e2fsck -f /dev/sdf3
    sudo tune2fs -U random /dev/sdf3
    
  14. Unmount the USB device from your computer and plug into one of the USB 3 ports of the Pi4.
  15. Plug in a network cable connected to your local home network into the PI4.
  16. Power on the PI4 and note the IP address assigned by your home network to the PI4.
  17. After a few minutes the network lights on the PI4 will start a steady blink. At this point you can ssh into the core or pi user (assuming the ignition file above).
  18. If you have a 4GB or 8GB PI4 you will need to attach a monitor to one of the microHDMI ports on the PI4 and a USB keyboard and reboot. During the boot, escape into the UEFI Boot Manager, select Device Manager, Raspberry, and then turn off (disable) the 3 GB ram limit. Save and exit then reboot again. This will only need to be done once.
  19. Explore your Fedora CoreOS computer!
Last edited by bgsmith on Sun Oct 10, 2021 1:49 pm, edited 3 times in total.

anthr76
Posts: 1
Joined: Wed Mar 03, 2021 1:37 pm

Re: Headless (mostly) Fedora CoreOS on RPi4 - A Brief How To

Wed Mar 03, 2021 1:38 pm

This is amazing! Thank you incredibly for your work

rcmelendez
Posts: 1
Joined: Thu May 27, 2021 9:59 pm
Location: Cambridge, US

Re: Headless (mostly) Fedora CoreOS on RPi4 - A Brief How To

Thu May 27, 2021 10:36 pm

Thanks, @bgsmith, your guide was helpful and motivated me to try installing Fedora on my Raspberry Pi 3 & 4. I followed all your steps but in the end, it didn't work for me with Fedora Server 34.

I wanted to have a completely headless installation. So I did more research and testing and came up with a successful headless procedure. Yesterday I published this step-by-step guide on Medium:

https://medium.com/geekculture/how-to-i ... 2adfb7efc5

It worked for both Raspberry Pi 3 or 4. Also, I think this process can be adapted for other distros. I hope it's helpful for users looking for running an amazing OS on an amazing piece of hardware.

Let me know if you try it out.

Return to “Pidora / Fedora”