diff --git a/SOURCES/README b/SOURCES/README new file mode 100644 index 0000000000000000000000000000000000000000..3cf1c6f106766cfd7498f521b631a3b7a854334d --- /dev/null +++ b/SOURCES/README @@ -0,0 +1,26 @@ +== Rocky 9 Raspberry Pi Image (experimental) == + +This is a minimal Rocky 9 install intended for Raspberry Pi 4 devices (architecture is aarch64). + +It may work on a Pi 3 , but that has not been tested. We are looking for Rpi 3 owners to test if you'd like to try it. + +This image WILL NOT WORK on a Raspberry Pi 1 or 2, we are 64-bit only, and have no support for 32-bit ARM processors. Sorry :-/. + + +IMAGE NOTES / DIFFERENCES FROM STOCK ROCKY 8: + + - Based on Rocky Linux 9, points to production Rocky 9 aarch64 repositories + - Has an additional repository that contains kernel packages for Raspberry Pi + - Includes script that fixes the wifi. Simple edit of a txt firmware settings file. Will need to be run whenever linux-firmware gets upgraded + - Includes @minimal-install , plus a few quality of life packages like vim, bash-completion, etc. + - Initial User "rocky" (default password: "rockylinux"). Root password disabled, rocky user is a sudoer + - Partitions are 300 MB /boot , 512 MB swap, 2800 MB rootfs. Requires a 4 GB or larger storage device to serve as your disk + + + +If you want to automatically resize your / partition, just type the following (as root user): +sudo rootfs-expand + +It should fill your main rootfs partition to the end of the disk. + + diff --git a/SOURCES/fix-wifi-rpi.sh b/SOURCES/fix-wifi-rpi.sh new file mode 100644 index 0000000000000000000000000000000000000000..4964bf00028040dd030b44da0ff7f0c96a331661 --- /dev/null +++ b/SOURCES/fix-wifi-rpi.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Issue: New firmware as of Fedora 34/RHEL 9 uses xz-compressed firmware files +# Unfortunately, the Rpi loader for wifi (brcm/broadcom) specifies files directly, and doesn't support the .xz files +# This is a simple hacky script to extract xz files in the brcm firmware directory and extract them, so they can be loaded properly + +#echo "blacklist brcmfmac" > /etc/modprobe.d/01-rpi-blacklist.conf + +mkdir -p /tmp/brcm_bak +cp -p /lib/firmware/brcm/*.xz /tmp/brcm_bak/ +xz -d /tmp/brcm_bak/*.xz +mv -f /tmp/brcm_bak/* /lib/firmware/brcm/ +rmdir /tmp/brcm_bak + +modprobe brcmfmac +rm -f /etc/modprobe.d/01-rpi-blacklist.conf diff --git a/SOURCES/fix-wifi.service b/SOURCES/fix-wifi.service new file mode 100644 index 0000000000000000000000000000000000000000..34dc2ddc15600e8e82c436ee82a2be41ddc6851b --- /dev/null +++ b/SOURCES/fix-wifi.service @@ -0,0 +1,17 @@ +[Unit] +Description=Fix wifi on the Raspberry Pi Zero 2W +#ConditionFirstBoot=yes +DefaultDependencies=no +Before=basic.target systemd-modules-load.service NetworkManager.service +Requires=local-fs.target +After=local-fs.target + +[Service] +Type=oneshot +ExecCondition=/bin/bash -c 'grep -q "Raspberry Pi Zero 2 W" /sys/firmware/devicetree/base/model' +ExecStart=/usr/bin/fix-wifi-rpi.sh +ExecStartPost=/bin/sh -c "systemctl disable fix-wifi.service && systemctl mask fix-wifi.service" + +[Install] +WantedBy=sysinit.target + diff --git a/SOURCES/rootfs-expand b/SOURCES/rootfs-expand new file mode 100644 index 0000000000000000000000000000000000000000..3a60ad867a61727d926837bef95e49e4d53c9c7a --- /dev/null +++ b/SOURCES/rootfs-expand @@ -0,0 +1,66 @@ +#!/bin/bash +clear +program=$(basename "$0") +logfile="/var/log/$program.log" + +# Function to log messages +log() { + echo "$(date +'%Y-%m-%d %H:%M:%S') - $1" | tee -a "$logfile" +} + +# Function to log variables for debugging +log_variables() { + echo "--- Debugging Variables ---" >> "$logfile" + echo "program: $program" >> "$logfile" + echo "logfile: $logfile" >> "$logfile" + echo "part: $part" >> "$logfile" + echo "dev: $dev" >> "$logfile" + echo "num: $num" >> "$logfile" + echo "last_part_num: $last_part_num" >> "$logfile" + echo "--------------------------" >> "$logfile" +} + +# Check if the script is run as root +if [[ $(id -u) -ne 0 ]]; then + log "Error: This script must be run as root (UID 0)." + exit 1 +fi +log "Starting $program" + +for cmd in growpart resize2fs; do + if ! command -v $cmd &> /dev/null; then + echo "The command '$cmd' is not installed. Please install the necessary package." + exit 1 + fi +done + +# Detect root filesystem partition +part=$(findmnt / -o source -n) +if [ -z "$part" ]; then + log "Error detecting root filesystem. Exiting." + exit 1 +fi + +dev="/dev/$(lsblk -no pkname "$part")" +num=$(echo "$part" | grep -o "[[:digit:]]*$") + +last_part_num=$(parted "$dev" -ms unit s p | tail -n 1 | cut -f 1 -d:) +if [[ "$last_part_num" -ne "$num" ]]; then + log "Error: $part is not the last partition. Unable to expand." + exit 2 +fi + +# Log all variables for debugging +log_variables + +# Extend partition +log "Extending partition $num on device $dev to maximum size..." +growpart "$dev" "$num" 2>&1 | tee -a "$logfile" || { log "Error: growpart failed."; exit 3; } + +# Resize filesystem +log "Resizing filesystem on $partition..." +resize2fs "$part" 2>&1 | tee -a "$logfile" || { log "Error: resize2fs failed."; exit 4; } + +log "Done." +df -h | grep "$part" | tee -a "$logfile" + diff --git a/SPECS/rocky-sbc-utils.spec b/SPECS/rocky-sbc-utils.spec new file mode 100644 index 0000000000000000000000000000000000000000..9d801168e3732d0a914c9e1937b79cca0286c015 --- /dev/null +++ b/SPECS/rocky-sbc-utils.spec @@ -0,0 +1,37 @@ +Name: rocky-sbc-utils +Version: 1.0 +Release: 7%{?dist} +Summary: Rocky SBC utilities + +License: GPLv3 +BuildArch: noarch +Requires: systemd + +Source0: rootfs-expand +Source1: README +Source2: fix-wifi-rpi.sh + +%description +This package contains a few scripts and utilities including the default Rocky AltArch README as well as a script for expanding the rootfs. It also contains a oneshot service for the Raspberry Pi Zero 2w. + +%install +install -d -m 0755 %{buildroot}/%{_bindir} +install -d -m 0755 %{buildroot}/%{_sysconfdir}/skel +install -p -m 0755 %{SOURCE0} %{buildroot}/%{_bindir}/rootfs-expand +install -p -m 0644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/skel/README +install -p -m 0755 %{SOURCE2} %{buildroot}%{_bindir}/fix-wifi-rpi.sh + +%post +%systemd_post fix-wifi.service + +%preun +%systemd_preun fix-wifi.service + +%postun +%systemd_posttrans fix-wifi.service + +%files +%defattr(-,root,root) +%attr(0755,root,root) %{_bindir}/rootfs-expand +%attr(0644,root,root) %{_sysconfdir}/skel/README +%attr(0755,root,root) %{_bindir}/fix-wifi-rpi.sh