RockyRpi/Rocky8_Rpi4.ks
2021-10-02 20:07:33 +00:00

166 lines
5.2 KiB
Plaintext

# 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
clearpart --initlabel --all
part /boot --asprimary --fstype=vfat --size=300 --label=boot
part swap --asprimary --fstype=swap --size=512 --label=swap
part / --asprimary --fstype=ext4 --size=2800 --label=RPIROOT
# Repos setup:
repo --name="BaseOS" --baseurl=http://download.rockylinux.org/pub/rocky/8/BaseOS/aarch64/os/ --cost=100
repo --name="AppStream" --baseurl=http://download.rockylinux.org/pub/rocky/8/AppStream/aarch64/os/ --cost=200 --install
repo --name="PowerTools" --baseurl=http://download.rockylinux.org/pub/rocky/8/BaseOS/aarch64/os/ --cost=300 --install
# 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="rockyextras" --baseurl=https://download.rockylinux.org/pub/rocky/8/extras/aarch64/os/ --cost=20
# Install proces:
install
keyboard us --xlayouts=us --vckeymap=us
rootpw --lock
# FIXME user creation here does not work ?
# user --name="rocky" --password="rockylinux" --plaintext --gecos="Rocky default user" --groups=wheel --uid=1000
timezone --isUtc --nontp UTC
selinux --enforcing
firewall --enabled --port=22:tcp
network --bootproto=dhcp --device=link --activate --onboot=on
services --enabled=sshd,NetworkManager,chronyd
shutdown
bootloader --location=none
lang en_US.UTF-8
# Package selection:
%packages
@core
chrony
cloud-utils-growpart
net-tools
NetworkManager-wifi
vim
bash-completion
nano
rocky-release-rpi
raspberrypi2-firmware
raspberrypi2-kernel4
%end
# Post install scripts:
%post
# Write initial boot line to cmdline.txt (we will update the root partuuid further down)
cat > /boot/cmdline.txt << EOF
console=ttyAMA0,115200 console=tty1 root= rootfstype=ext4 elevator=deadline rootwait
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?
/sbin/useradd -c "Rocky Linux default user" -G wheel -m -U rocky
echo "rockylinux" | passwd --stdin rocky
# Need to write several files to help with various things here.
# First, the all-important README :
cat >/home/rocky/README << EOF
== Rocky 8 Raspberry Pi Image ==
This is a Rocky 8 install intended for Raspberry Pi 3b and 4 devices (architecture is aarch64).
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 8.4, points to production Rocky 8 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
GROW YOUR PARTITION:
If you want to automatically resize your root (/ ) partition, just type the following (as root user):
sudo rootfs-expand
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 !
-The Rocky Linux Team
EOF
# Next, script to fix the wifi firmware setting:
cat >/home/rocky/fix-wifi-rpi4.sh << 'EOF'
#!/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
# Remove ifcfg-link on pre generated images
rm -f /etc/sysconfig/network-scripts/ifcfg-link
# Remove machine-id on pre generated images
rm -f /etc/machine-id
touch /etc/machine-id
# Ensure no ssh keys are present
rm -f /etc/ssh/*_key*
# Clean yum cache
yum clean all
%end
# Add the PARTUUID of the rootfs partition to the kernel command line
%post --nochroot
# Extract the UUID of the rootfs partition from /etc/fstab
UUID_ROOTFS="$(/bin/cat $INSTALL_ROOT/etc/fstab | \
/bin/awk -F'[ =]' '/\/ / {print $2}')"
# Get the PARTUUID of the rootfs partition
PART_UUID_ROOTFS="$(/sbin/blkid "$(/sbin/blkid --uuid $UUID_ROOTFS)" | \
/bin/awk '{print $NF}' | /bin/tr -d '"' )"
# Configure the kernel commandline
/bin/sed -i "s/root= /root=${PART_UUID_ROOTFS} /" $INSTALL_ROOT/boot/cmdline.txt
echo "cmdline.txt looks like this, please review:"
/bin/cat $INSTALL_ROOT/boot/cmdline.txt
%end