Skip to content
Snippets Groups Projects
Commit 37452559 authored by Rocky Automation's avatar Rocky Automation :tv:
Browse files

import imports/r9/rocky-sbc-utils-1.0-7.el9.altarch

parents
No related merge requests found
== 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.
#!/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
[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
#!/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"
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment