User Tools

Site Tools


Sidebar

software:fedora:fedora32_on_raspi4

Installing Fedora 32 on Raspberry Pi 4

Overall, you have these options:

Some pieces are borrowed from the Nintendo Switch Fed32 setup. The generic raspi4 notes are here.

Outline:

  • Step 1: write the image
  • Step 2: Fedora setup
  • Step 3: boot Fedora, finalize setup

Step 1: Writing image

These steps can be done on an x86_64 Fedora system with a micro-sdcard reader/writer.

# We will use the Minimal-spin.  XFCE works too.
URL="https://kojipkgs.fedoraproject.org/compose/rawhide/latest-Fedora-Rawhide/compose/Spins/aarch64/images/"
# - server spin in that directory does not boot
# - Xfce and Minimal spins work

# Our directory for storing images etc.
WORKDIR="/home/chris/Downloads/raspi"
# Our microsd-card device
OUTDEV="/dev/mmcblk0"

dnf install -y arm-image-installer lftp

cd $WORKDIR
# fetch latest Minimal image
lftp $URL -e 'mget Fedora-Minimal-Rawhide*'

# write the just fetched image
fedora-arm-image-installer \
  --image Fedora-Minimal-Rawhide-* \
  --target=rpi4 --media $OUTDEV --resizefs

Step 2: Fedora setup

### Mount the card
mkdir -p $WORKDIR/mnt
mount ${OUTDEV}p3 $WORKDIR/mnt
mount ${OUTDEV}p2 $WORKDIR/mnt/boot
mount ${OUTDEV}p1 $WORKDIR/mnt/boot/efi

cd $WORKDIR/mnt

# set your root-password to 'fedora'
sed -ie 's,^root.*,root:$6$g1sdJY/CulQKzQmS$heAUJV60eTr1HQtTTR188WlA/vOTj6LPuKA7JB1wKEgPiW1qX2gPJHU8lLhSL8KeKgx.hGgUvQ4uzW6JQ68u40:18388:0:99999:7:::,' etc/shadow
# As an alternative, execute 'vi etc/shadow' and manually
# change the password hash to something else.
echo 'PermitRootLogin yes' >>etc/ssh/sshd_config

echo pi4.local >etc/hostname
echo '127.0.0.1   pi4.local pi4' >>etc/hosts

### Let's set a static IP
cat >etc/sysconfig/network-scripts/ifcfg-eth0<<EOT
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
IPADDR=192.168.0.4
PREFIX=24
GATEWAY=192.168.0.1
DNS1=8.8.8.8
NAME=eth0
DEVICE=eth0
ONBOOT=yes
AUTOCONNECT_PRIORITY=-999
EOT

# Disable the initial-setup and other unneeded services
rm -f etc/systemd/system/multi-user.target.wants/initial-setup.service
rm -f etc/systemd/system/multi-user.target.wants/abrtd.service
rm -f etc/systemd/system/multi-user.target.wants/abrt-journal-core.service
rm -f etc/systemd/system/multi-user.target.wants/abrt-oops.service
rm -f etc/systemd/system/multi-user.target.wants/abrt-vmcore.service
rm -f etc/systemd/system/multi-user.target.wants/abrt-xorg.service
rm -f etc/systemd/system/multi-user.target.wants/cups.service
rm -f etc/systemd/system/multi-user.target.wants/nfs-client.service
rm -f etc/systemd/system/multi-user.target.wants/vboxservice.service
rm -f etc/systemd/system/multi-user.target.wants/vmtoolsd.service
rm -f etc/systemd/system/multi-user.target.wants/ModemManager.service
rm -f etc/systemd/system/multi-user.target.wants/rngd.service
rm -f etc/systemd/system/multi-user.target.wants/avahi-daemon.service
rm -f etc/systemd/system/multi-user.target.wants/auditd.service
rm -f etc/systemd/system/multi-user.target.wants/smartd.service
rm -f etc/systemd/system/multi-user.target.wants/libvirtd.service
rm -f etc/systemd/system/multi-user.target.wants/remote-fs.service

rm -f etc/systemd/system/sysinit.target.wants/multipathd.service
rm -f etc/systemd/system/sockets.target.wants/multipathd.socket
cd ..

### prepare boot partition
# cma=256M@704M might be needed on Fed32 images, but not
# required any more on Fed33 rawhide
mnt/boot/efi/EFI/fedora/grubenv:kernelopts=root=UUID=[..] ro cma=256M@704M
mnt/boot/efi/EFI/fedora/grub.cfg:  set kernelopts="root=UUID=[..] ro cma=256M@704M "

# changes might be required in mnt/boot/efi/config.txt
# for dynamically adding/removing screen.
# textmode/framebuffer output works also without adding these.
hdmi_force_hotplug=1
hdmi_drive=2
###

umount $WORKDIR/mnt/boot/efi
umount $WORKDIR/mnt/boot
umount $WORKDIR/mnt

You should now be able to boot the Pi4 with the sdcard into Fedora, it takes some time. Login via ssh should then be possible.

Step 3: First steps on the Fedora installation

cat >>~/.bashrc<<EOT
# extend prompt to have temperature
export PS1='[\u@\h \$(cut -b 1,2 /sys/devices/virtual/thermal/thermal_zone0/temp)°C \W]\$ '
# colored iostat output
export S_COLORS=always
EOT

### tuning
cat >/etc/rc.local<<EOT
#!/usr/bin/bash
# VM writeback timeout
echo '1500' > '/proc/sys/vm/dirty_writeback_centisecs'
# power saving for wlan and usb chips
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/power/control'
echo 'auto' > '/sys/bus/pci/devices/0000:00:00.0/power/control'
EOT
chmod +x /etc/rc.local
/etc/rc.local
ln -s /etc/rc.local /etc/rc.d/rc.local

# To get further ideas about services we do not need
systemd-analyze plot >file.svg

# For my use cases:
systemctl disable lmsensors firewalld

# I like gkrellm
dnf -y install gkrellm-daemon sysstat htop
echo 'allow-host 192.168.0.2' >>/etc/gkrellmd.conf 
systemctl enable --now gkrellmd

# update
dnf -y update
software/fedora/fedora32_on_raspi4.txt · Last modified: 2020/07/13 14:02 by chris