Compare commits

...

9 Commits
r8 ... r9

Author SHA1 Message Date
Skip Grube
1590495b45 Minor readme fix
-Skip
2023-06-09 13:32:02 -04:00
6a2581f7fc Merge pull request 'Pi 3 B WiFi Fix' (#3) from codedude/RockyRpi:r9 into r9
Reviewed-on: #3

Looks good, will produce new image tonight.
2023-02-25 21:03:39 +00:00
2671712335
Pi 3 B WiFi Fix 2023-01-15 23:36:56 -05:00
Skip Grube
a801771e25
Fixed CRB typo
-Skip G.
2022-11-27 22:29:24 -05:00
Skip Grube
ac19c4190b
Updated for Rocky 9.1
- Re-arranged some things to help transition to livemedia-creator later
- Added cpupower fix for "slow CPU" issue - set to ondemand by default

-Skip G.
2022-11-27 21:50:11 -05:00
Skip Grube
2a401e1b22
Added official SIG repo endpoints
Also removed firmware gz workaround, newer kernel means it's not needed.

-Skip G.
2022-08-02 00:51:06 -04:00
Skip Grube
eee2febc3d Updated kickstart, added tech issues synopsis
- Re-added selinux in kickstart (building on EL9 now)
- Changed bootstrap rpi9 package location
- Added a document explaining technical hurdles to building the 9 image

-Skip G.
2022-07-06 15:59:06 +00:00
Skip Grube
1bfa5a621a Cleanup for Rpi9
- Fixed locale issue in image
- Added the rocky9-rpi release package back (used from a bootstrap for now)
- Added notes about building a 9 image only on 9

-Skip G.
2022-07-05 20:55:47 +00:00
Skip Grube
1a15f993de Started R9 branch based (roughly) on R8 branch
-Skip G.
2022-07-04 20:42:47 +00:00
6 changed files with 158 additions and 76 deletions

View File

@ -2,7 +2,7 @@
Scripts and kickstarts for building Rocky Linux for Raspberry Pi Scripts and kickstarts for building Rocky Linux for Raspberry Pi
## Purpose of this Repo ## Purpose of this Repo
This repository contains kickstart scripts and commands for producing your own Rocky Linux 8 image for the Raspberry Pi. It's intended mostly for developers or other technical users. If you are simply interested in using Rocky on your Pi, it's much easier to grab the latest image from (currently): https://dl.rockylinux.org/pub/rocky/8/rockyrpi/aarch64/images/ This repository contains kickstart scripts and commands for producing your own Rocky Linux 9 image for the Raspberry Pi. It's intended mostly for developers or other technical users. If you are simply interested in using Rocky on your Pi, it's much easier to grab the latest image from (currently): https://dl.rockylinux.org/pub/rocky/9/rockyrpi/aarch64/images/
The readme.image.txt file has information and instructions for those interested in downloading and using the ready-made image. The readme.image.txt file has information and instructions for those interested in downloading and using the ready-made image.
@ -12,12 +12,13 @@ The readme.image.txt file has information and instructions for those interested
Producing the Rpi Image requires: Producing the Rpi Image requires:
* A Fedora or EL-based distribution (Rocky/CentOS/RHEL/etc.) **running on aarch64 hardware** * Fedora 34 or higher, OR an EL9-based distribution **running on aarch64 hardware**
* NOTE: It MUST be EL9, or you will have RPMDB+SELinux issues! We do not support building this image on EL8 or lower
* Packages * Packages
* git * git
* epel-release (if using an EL distro)
* appliance-tools (contains the appliance-creator program that makes the image)
* EPEL repo enabled (extra packages for enterprise linux)
* The appliance-creator program from appliance-tools package ( ```sudo dnf install appliance-tools``` )
## Making an Image ## Making an Image
@ -25,7 +26,7 @@ The included script to create the image is quite simple. Simply run it (with su
For example: For example:
`sudo ./createRocky8_Image.sh /home/myhomefolder/Rocky8_image/` `sudo ./createRocky9_Image.sh /home/myhomefolder/Rocky9_image/`
The kickstart/image build process takes approximately 10 minutes on a Raspberry Pi 4 with a decently fast internet connection. Alternatively, you should be able to use any aarch64 hardware that meets the above requirements(Amazon EC2, etc) The kickstart/image build process takes approximately 10 minutes on a Raspberry Pi 4 with a decently fast internet connection. Alternatively, you should be able to use any aarch64 hardware that meets the above requirements(Amazon EC2, etc)
@ -33,7 +34,7 @@ The kickstart/image build process takes approximately 10 minutes on a Raspberry
## Customizing the Kickstart ## Customizing the Kickstart
All the setup logic for the image is contained within the kickstart file (Rocky8_Rpi.ks). It is intended to be readable and well documented, and you can of course change it anyway you please to produce custom images yourself. All the setup logic for the image is contained within the kickstart file (Rocky9_Rpi.ks). It is intended to be readable and well documented, and you can of course change it anyway you please to produce custom images yourself.
# Contributing # Contributing

View File

@ -1,29 +1,23 @@
# Kickstart to build Rocky 8 image for Raspberry Pi 4 hardware (aarch64) # Kickstart to build Rocky 8 image for Raspberry Pi 4 hardware (aarch64)
# #
# (pull from pgreco: https://github.com/psgreco/sig-core-AltArch/tree/master/image_build
# Disk setup # Disk setup
clearpart --initlabel --all clearpart --initlabel --all
part /boot --asprimary --fstype=vfat --size=300 --label=boot part /boot --asprimary --fstype=vfat --size=300 --label=boot
part swap --asprimary --fstype=swap --size=512 --label=swap part swap --asprimary --fstype=swap --size=512 --label=swap
part / --asprimary --fstype=ext4 --size=2800 --label=RPIROOT part / --asprimary --fstype=ext4 --size=2800 --label=RPIROOT
# Repos setup: # Repos setup:
repo --name="BaseOS" --baseurl=http://download.rockylinux.org/pub/rocky/8/BaseOS/aarch64/os/ --cost=100 url --url http://download.rockylinux.org/pub/rocky/9/BaseOS/aarch64/os/
repo --name="AppStream" --baseurl=http://download.rockylinux.org/pub/rocky/8/AppStream/aarch64/os/ --cost=200 --install repo --name="BaseOS" --baseurl=http://download.rockylinux.org/pub/rocky/9/BaseOS/aarch64/os/ --cost=100
repo --name="PowerTools" --baseurl=http://download.rockylinux.org/pub/rocky/8/BaseOS/aarch64/os/ --cost=300 --install repo --name="AppStream" --baseurl=http://download.rockylinux.org/pub/rocky/9/AppStream/aarch64/os/ --cost=200 --install
repo --name="CRB" --baseurl=http://download.rockylinux.org/pub/rocky/9/CRB/aarch64/os/ --cost=300 --install
# Rocky Rpi kernel repo, we need a more permanent place for this: # Rocky Rpi kernel repo, we need a more permanent place for this:
repo --name="rockyrpi" --baseurl=https://download.rockylinux.org/pub/rocky/8/rockyrpi/aarch64/os/ --cost=20 repo --name="rockyrpi" --baseurl=https://download.rockylinux.org/pub/sig/9/altarch/aarch64/altarch-rockyrpi/ --cost=20
repo --name="rockyextras" --baseurl=https://download.rockylinux.org/pub/rocky/8/extras/aarch64/os/ --cost=20 repo --name="rockyextras" --baseurl=https://download.rockylinux.org/pub/rocky/9/extras/aarch64/os/ --cost=20
# Install process:
#text
# Install proces:
install
keyboard us --xlayouts=us --vckeymap=us keyboard us --xlayouts=us --vckeymap=us
rootpw --lock rootpw --lock
# FIXME user creation here does not work ? # FIXME user creation here does not work ?
@ -32,16 +26,19 @@ timezone --isUtc --nontp UTC
selinux --enforcing selinux --enforcing
firewall --enabled --port=22:tcp firewall --enabled --port=22:tcp
network --bootproto=dhcp --device=link --activate --onboot=on network --bootproto=dhcp --device=link --activate --onboot=on
services --enabled=sshd,NetworkManager,chronyd services --enabled=sshd,NetworkManager,chronyd,cpupower
shutdown shutdown
bootloader --location=none bootloader --location=none
lang en_US.UTF-8 lang en_US.UTF-8
skipx
# Package selection: # Package selection:
%packages %packages
@core @core
#-grub2-tools-minimal
#-grub2-tools
#-grubby
#-grub2-common
chrony chrony
cloud-utils-growpart cloud-utils-growpart
net-tools net-tools
@ -49,28 +46,27 @@ NetworkManager-wifi
vim vim
bash-completion bash-completion
nano nano
kernel-tools
# Need these for setting default locale of en-US:
langpacks-en
glibc-all-langpacks
# will enable rocky-release-rpi after full 9 release (and we have it in the -extras repo)
rocky-release-rpi rocky-release-rpi
raspberrypi2-firmware raspberrypi2-firmware
raspberrypi2-kernel4 raspberrypi2-kernel4
%end %end
# Post install scripts: # Post install scripts:
%post %post
# Write initial boot line to cmdline.txt (we will update the root partuuid further down) # Write initial boot line to cmdline.txt (we will update the root partuuid further down)
cat > /boot/cmdline.txt << EOF cat > /boot/cmdline.txt << EOF
console=ttyAMA0,115200 console=tty1 root= rootfstype=ext4 elevator=deadline rootwait console=ttyAMA0,115200 console=tty1 root= rootfstype=ext4 elevator=deadline rootwait
EOF EOF
# Run this once to fix the wifi:
sed -i 's/boardflags3=0x48200100/boardflags3=0x44200100/g' /lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,4-model-b.txt
# Apparently kickstart user was not working, attempt to do it here? # Apparently kickstart user was not working, attempt to do it here?
/sbin/useradd -c "Rocky Linux default user" -G wheel -m -U rocky /sbin/useradd -c "Rocky Linux default user" -G wheel -m -U rocky
echo "rockylinux" | passwd --stdin rocky echo "rockylinux" | passwd --stdin rocky
@ -79,27 +75,23 @@ echo "rockylinux" | passwd --stdin rocky
# First, the all-important README : # First, the all-important README :
cat >/home/rocky/README << EOF cat >/home/rocky/README << EOF
== Rocky 8 Raspberry Pi Image == == Rocky 9 Raspberry Pi Image ==
This is a Rocky 8 install intended for Raspberry Pi 3b and 4 devices (architecture is aarch64). This is a Rocky 9 install intended for Raspberry Pi 3b and 4 devices (architecture is aarch64).
This image WILL NOT WORK on a Raspberry Pi 1 or 2 (1.1 or earlier), we are 64-bit only, and have no support for 32-bit ARM processors. Sorry :-/. This image WILL NOT WORK on a Raspberry Pi 1 or 2 (1.1 or earlier), we are 64-bit only, and have no support for 32-bit ARM processors. Sorry :-/.
The newer Pi Zero devices should be supported, as well as the Raspberry Pi 2 v. 1.2 boards, which are 64-bit The newer Pi Zero devices should be supported, as well as the Raspberry Pi 2 version 1.2 boards, which are 64-bit
IMAGE NOTES / DIFFERENCES FROM STOCK ROCKY 8: IMAGE NOTES / DIFFERENCES FROM STOCK ROCKY 8:
- Based on Rocky Linux 8.5, points to production Rocky 8 aarch64 repositories - 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 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. - 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 - 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 - Partitions are 300 MB /boot , 512 MB swap, 2800 MB rootfs. Requires a 4 GB or larger storage device to serve as your disk
GROW YOUR PARTITION: GROW YOUR PARTITION:
If you want to automatically resize your root (/ ) partition, just type the following (as root user): If you want to automatically resize your root (/ ) partition, just type the following (as root user):
@ -107,31 +99,15 @@ sudo rootfs-expand
It should fill your main rootfs partition to the end of the disk. It should fill your main rootfs partition to the end of the disk.
Thanks for your interest on Rocky-on-Rpi, feel free to share your experience or contribute in our chat channel at: https://chat.rockylinux.org/rocky-linux/channels/altarch ! Thanks for your interest on Rocky-on-Rpi, feel free to share your experience or contribute in our chat channel at: https://chat.rockylinux.org/rocky-linux/channels/altarch !
-The Rocky Linux Team -The Rocky Linux Team
EOF EOF
# Run the fix-wifi script (extracts the .xz firmware) - should be installed via the rocky-release-rpi package
# Next, script to fix the wifi firmware setting: # (shouldn't be needed anymore - fixed in newer rpi kernel builds)
cat >/home/rocky/fix-wifi-rpi4.sh << 'EOF' #fix-wifi-rpi.sh
#!/bin/bash
# Simple hacky fix to correct wifi settings on the Rpi4 so it loads properly:
sed -i 's/boardflags3=0x48200100/boardflags3=0x44200100/g' /lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,4-model-b.txt
echo "Patched /lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,4-model-b.txt . You can reboot and wifi should work, or do: rmmod brcmfmac; modprobe brcmfmac; "
EOF
chmod 755 /home/rocky/fix-wifi-rpi4.sh
chown -R rocky:rocky /home/rocky
# Cleanup before shipping an image # Cleanup before shipping an image
@ -143,15 +119,25 @@ rm -f /etc/machine-id
touch /etc/machine-id touch /etc/machine-id
# Ensure no ssh keys are present # Ensure no ssh keys are present
rm -f /etc/ssh/*_key* rm -f "/etc/ssh/*_key*"
# Clean yum cache # Clean yum cache
yum clean all yum clean all
# Fix weird sssd bug, where it gets its folder owned by the unbound user:
chown -R sssd:sssd /var/lib/sss/{db,pipes,mc,pubconf,gpo_cache}
# Setting tuned profile to powersave by default -> sets the CPU governor to "ondemand". This prevents overheating issues
cat > /etc/sysconfig/cpupower << EOF
# See 'cpupower help' and cpupower(1) for more info
CPUPOWER_START_OPTS="frequency-set -g ondemand"
CPUPOWER_STOP_OPTS="frequency-set -g ondemand"
EOF
%end %end
# Add the PARTUUID of the rootfs partition to the kernel command line # Add the PARTUUID of the rootfs partition to the kernel command line
# We must do this *outside* of the chroot, by grabbing the UUID of the loopmounted rootfs
%post --nochroot %post --nochroot
# Extract the UUID of the rootfs partition from /etc/fstab # Extract the UUID of the rootfs partition from /etc/fstab
@ -167,7 +153,6 @@ PART_UUID_ROOTFS="$(/sbin/blkid "$(/sbin/blkid --uuid $UUID_ROOTFS)" | \
echo "cmdline.txt looks like this, please review:" echo "cmdline.txt looks like this, please review:"
/bin/cat $INSTALL_ROOT/boot/cmdline.txt /bin/cat $INSTALL_ROOT/boot/cmdline.txt
# Extract UUID of swap partition: # Extract UUID of swap partition:
UUID_SWAP=$(/bin/grep 'swap' $INSTALL_ROOT/etc/fstab | awk '{print $1}' | awk -F '=' '{print $2}') UUID_SWAP=$(/bin/grep 'swap' $INSTALL_ROOT/etc/fstab | awk '{print $1}' | awk -F '=' '{print $2}')
@ -175,3 +160,9 @@ UUID_SWAP=$(/bin/grep 'swap' $INSTALL_ROOT/etc/fstab | awk '{print $1}' | awk
/usr/sbin/mkswap -L "_swap" -p 4096 -U "${UUID_SWAP}" /dev/disk/by-uuid/${UUID_SWAP} /usr/sbin/mkswap -L "_swap" -p 4096 -U "${UUID_SWAP}" /dev/disk/by-uuid/${UUID_SWAP}
%end %end
%post
# WiFi fix on Pi 3 Model B(image wont boot on Pi 3B w/o this fix)
cd /lib/firmware/brcm
xz -d -k brcmfmac43430-sdio.raspberrypi,3-model-b.txt.xz
%end

84
TECH_ISSUES Normal file
View File

@ -0,0 +1,84 @@
List of technical issues encountered in building the Rocky 9 Raspberry Pi image, and how they were overcome:
###
1)
SELinux file label issues during image create:
When SELinux is enforcing in the image, it attempts to label files as the kickstart is running.
Unfortunately, if building an EL9 image on an EL8 kernel + host system, there will be incompatibilities with the labels on the SELinux implementations, which causes the errors.
SOLUTION: Build the image on an EL9 or equivalent Fedora host, or disable SELinux in the kickstart (it can be turned on later in the image, but there is a relabel process to go through)
###
2)
RPMDB + libdnf issues:
When trying to install new packages, you get repeated warnings from DNF saying "warning: Found bdb Packages database while attempting sqlite backend: using bdb backend."
It also prevents the import of RPM GPG keys, which effectively means no package installs.
Similar to this:
https://bugzilla.redhat.com/show_bug.cgi?id=1836108
SOLUTION: Build the image on an EL9 host, OR run "rpmdb --rebuilddb" at the end of %post in kickstart, or on the Raspberry Pi itself.
###
3)
RPi Broadcom Wifi Issue
Since Fedora 34(?), the linux-firmware package has all of its artifacts xz-compressed in order to save space.
This breaks the Raspberry Pi wifi driver, as the firmware file locations are hard-coded, and will not use the .xz files.
SOLUTION:
As a workaround, a script is included in the rocky-rpi-release package which copies the firmware .xz files, extracts them, and puts them back in the proper directory (alongside the original .xz files).
The script (fix-wifi-rpi.sh) is run during the kickstart to fix wireless, and can be run by root at any time.
The files in question live in /lib/firmware/brcm/.
A better, non-workaround solution will require more research - likely a rpi-kernel patch.
###
4)
DNF/Appliance Creator Unmount issues:
When finishing image creation, the host machine's DNF can "hang" on to open files, causing the various unmounts at the end of the process to fail, and thus the whole image process.
The errors vary in their locations, but look like this:
umount: /var/tmp/imgcreate-e84ozsji/install_root/sys/fs/selinux/load: not mounted.
Traceback (most recent call last):
File "/usr/bin/livecd-creator", line 265, in
sys.exit(main())
Livecd-Tools Bug Report and discussion: https://github.com/livecd-tools/livecd-tools/issues/232
Related RH Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2087734
LibDNF patch: https://github.com/rpm-software-management/dnf/commit/5ce5ed1ea08ad6e198c1c1642c4d9ea2db6eab86
SOLUTION:
A simple patch needs to be applied to the HOST system's libdnf base.py (ex: /usr/lib/python3.9/site-packages/dnf/base.py )
The patch is here: https://github.com/rpm-software-management/dnf/commit/5ce5ed1ea08ad6e198c1c1642c4d9ea2db6eab86
Basically: "import gc" (at the top)
and at the bottom of the reset() method:
if sack and goal:
gc.collect()
This fixes the hanging file handle/unmount issue

View File

@ -1,13 +1,17 @@
#!/bin/bash #!/bin/bash
# Simple script that runs a Rocky Raspberry pi creation (via appliance-creator), then inserts a UUID to the kernel boot line of the image # Simple script that runs a Rocky Raspberry pi creation (via appliance-creator), then inserts a UUID to the kernel boot line of the image
# after-the-fact # after-the-fact
# #
# Usage: ./Rocky8_Rpi4_mkimage.sh /path/to/outputfolder/ # Usage: ./createRocky9_Image.sh /path/to/outputfolder/
#
# #
# Needs to be run in the same directory as the rocky rpi kickstart, as it relies on it! # Needs to be run in the same directory as the rocky rpi kickstart, as it relies on it!
# #
# Exit with error if we don't have an output directory: # Exit with error if we don't have an output directory:
OUTDIR=$1
OUTDIR=$1 OUTDIR=$1
LOGDIR="logs" LOGDIR="logs"
@ -26,16 +30,24 @@ else
touch $LOGDIR/$LOGFILE touch $LOGDIR/$LOGFILE
fi fi
if [[ -d ${OUTDIR} ]]; then if [[ -d ${OUTDIR} ]]; then
echo "$OUTDIR exists..." echo "$OUTDIR exists..."
else else
mkdir -p "${OUTDIR}" mkdir -p "${OUTDIR}"
fi fi
mkdir -p "${OUTDIR}"
# Actually create the image. Our kickstart data should be in the same git repo as this script: # Actually create the image. Our kickstart data should be in the same git repo as this script:
# (This takes a while, especially building on an rpi. Patience!) # (This takes a while, especially building on an rpi. Patience!)
appliance-creator -v -c ./Rocky8_Rpi4.ks -n RockyRpi \ appliance-creator -v -c ./Rocky9_Rpi.ks -n RockyRpi \
--version=`date +"%Y%m%d"` --release=1 \ --version=`date +"%Y%m%d"` --release=1 \
-d --logfile $LOGDIR/LOGFILE \ -d --logfile $LOGDIR/LOGFILE \
--vmem=2048 --vcpu=2 --no-compress -o "${OUTDIR}" --vmem=2048 --vcpu=2 --no-compress -o "${OUTDIR}"
#chown -R $SUDO_USER. "${OUTDIR}" #chown -R $SUDO_USER. "${OUTDIR}"

View File

@ -1,6 +1,6 @@
(This file comes from the kickstart/appliance-creator repo: https://git.resf.org/sig_altarch/RockyRpi ) (This file comes from the kickstart/appliance-creator repo: https://git.resf.org/sig_altarch/RockyRpi )
Rocky 8 Raspberry Pi Images Rocky 9 Raspberry Pi Image version 9.2
They have been tested on Raspberry Pi 3 and 4. They have been tested on Raspberry Pi 3 and 4.

View File

@ -1,13 +1,7 @@
#- Disable root pw, disable root ssh, add rocky login w/ default pw - Build fixes for wifi on 9
- Detect PARTUUID and automatically swap /boot/cmdline.txt - Finalize and release rpi Rocky 9 image
#- script to fix wifi txt file, in /root/, and also run it at the end - re-sync kernel RPM from pgreco upstream
#- install extra packages: nano,vim,bash-completion - port builds and imports to Peridot
#- Add rpi-kernel repo file
- Add README , with notes and how-to's for writing sd card, fixing wifi, and expanding partition
- Adjust swap/rootfs sizes(?)