2021-06-25 16:00:39 +00:00
# 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
2021-06-26 13:04:06 +00:00
part / --asprimary --fstype=ext4 --size=2800 --label=RPIROOT
2021-06-25 16:00:39 +00:00
2021-06-25 19:49:11 +00:00
2021-06-25 16:00:39 +00:00
2021-06-26 20:46:22 +00:00
# Repos setup:
2022-07-04 20:42:47 +00:00
repo --name="BaseOS" --baseurl=http://download.rockylinux.org/stg/rocky/9/BaseOS/aarch64/os/ --cost=100
repo --name="AppStream" --baseurl=http://download.rockylinux.org/stg/rocky/9/AppStream/aarch64/os/ --cost=200 --install
repo --name="PowerTools" --baseurl=http://download.rockylinux.org/stg/rocky/9/BaseOS/aarch64/os/ --cost=300 --install
2022-07-05 20:55:47 +00:00
repo --name="rockyrpi" --baseurl=https://bootstrap9.releng.rockylinux.org/RockyRpi_9_Test/rpi_repo/ --cost=50 --install
2022-07-04 20:42:47 +00:00
#--baseurl=https://download.rockylinux.org/pub/rocky/8/rockyrpi/aarch64/os/ --cost=100 --install
2021-06-26 20:46:22 +00:00
# Rocky Rpi kernel repo, we need a more permanent place for this:
2022-07-04 20:42:47 +00:00
#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
2021-06-26 20:46:22 +00:00
# Install proces:
install
keyboard us --xlayouts=us --vckeymap=us
rootpw --lock
2021-06-29 20:10:47 +00:00
# FIXME user creation here does not work ?
# user --name="rocky" --password="rockylinux" --plaintext --gecos="Rocky default user" --groups=wheel --uid=1000
2021-06-26 20:46:22 +00:00
timezone --isUtc --nontp UTC
2022-07-04 20:42:47 +00:00
selinux --disabled
2021-06-26 20:46:22 +00:00
firewall --enabled --port=22:tcp
network --bootproto=dhcp --device=link --activate --onboot=on
services --enabled=sshd,NetworkManager,chronyd
shutdown
2021-06-29 16:25:38 +00:00
bootloader --location=none
2021-06-26 20:46:22 +00:00
lang en_US.UTF-8
# Package selection:
%packages
@core
2022-07-04 20:42:47 +00:00
#-grub2-tools-minimal
#-grub2-tools
#-grubby
#-grub2-common
2021-06-26 20:46:22 +00:00
chrony
cloud-utils-growpart
net-tools
NetworkManager-wifi
vim
bash-completion
nano
2022-07-04 20:42:47 +00:00
2022-07-05 20:55:47 +00:00
# Need these for setting default locale of en-US:
langpacks-en
glibc-all-langpacks
2022-07-04 20:42:47 +00:00
# will enable rocky-release-rpi after full 9 release (and we have it in the -extras repo)
2022-07-05 20:55:47 +00:00
rocky-release-rpi
2021-06-26 20:46:22 +00:00
raspberrypi2-firmware
raspberrypi2-kernel4
2021-10-02 20:07:33 +00:00
2021-06-26 20:46:22 +00:00
2022-07-05 20:55:47 +00:00
2021-06-26 20:46:22 +00:00
%end
# Post install scripts:
2021-06-25 16:00:39 +00:00
%post
2021-06-25 19:49:11 +00:00
2021-07-31 22:24:38 +00:00
# Write initial boot line to cmdline.txt (we will update the root partuuid further down)
2021-06-25 19:49:11 +00:00
cat > /boot/cmdline.txt << EOF
2021-07-15 17:32:41 +00:00
console=ttyAMA0,115200 console=tty1 root= rootfstype=ext4 elevator=deadline rootwait
2021-06-25 19:49:11 +00:00
EOF
2021-06-29 20:05:05 +00:00
2021-06-29 20:10:47 +00:00
2021-06-29 20:05:05 +00:00
# Apparently kickstart user was not working, attempt to do it here?
2021-06-29 20:10:47 +00:00
/sbin/useradd -c "Rocky Linux default user" -G wheel -m -U rocky
2021-06-29 20:05:05 +00:00
echo "rockylinux" | passwd --stdin rocky
2021-06-25 19:49:11 +00:00
2021-06-26 13:04:06 +00:00
# Need to write several files to help with various things here.
# First, the all-important README :
cat >/home/rocky/README << EOF
2022-07-04 20:42:47 +00:00
== Rocky 9 Raspberry Pi Image ==
2021-06-26 13:04:06 +00:00
2022-07-04 20:42:47 +00:00
This is a Rocky 9 install intended for Raspberry Pi 3b and 4 devices (architecture is aarch64).
2021-06-26 13:04:06 +00:00
2021-11-16 22:13:46 +00:00
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
2021-06-26 13:04:06 +00:00
IMAGE NOTES / DIFFERENCES FROM STOCK ROCKY 8:
2022-07-04 20:42:47 +00:00
- Based on Rocky Linux 9, points to production Rocky 9 aarch64 repositories
2021-06-26 13:04:06 +00:00
- 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
2021-10-02 20:07:33 +00:00
GROW YOUR PARTITION:
2021-06-26 13:04:06 +00:00
2021-10-02 20:07:33 +00:00
If you want to automatically resize your root (/ ) partition, just type the following (as root user):
2021-06-29 16:25:38 +00:00
sudo rootfs-expand
2021-06-26 13:04:06 +00:00
2021-06-30 04:01:33 +00:00
It should fill your main rootfs partition to the end of the disk.
2021-10-02 20:07:33 +00:00
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
2021-06-26 13:04:06 +00:00
EOF
2021-07-30 20:58:21 +00:00
2022-07-05 20:55:47 +00:00
# Run the fix-wifi script (extracts the .xz firmware) - should be installed via the rocky-release-rpi package
fix-wifi-rpi.sh
2021-07-30 20:58:21 +00:00
2021-06-25 19:49:11 +00:00
2021-06-26 13:04:06 +00:00
2021-06-29 20:05:05 +00:00
# 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
2022-07-04 20:42:47 +00:00
rm -f "/etc/ssh/*_key*"
2021-06-25 19:49:11 +00:00
2021-10-03 04:46:45 +00:00
2022-07-05 20:55:47 +00:00
2021-06-29 19:53:48 +00:00
# Clean yum cache
yum clean all
2022-07-04 20:42:47 +00:00
# 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}
2022-07-05 20:55:47 +00:00
2021-06-25 16:00:39 +00:00
%end
2021-07-15 17:32:41 +00:00
2022-07-05 20:55:47 +00:00
2021-07-15 17:32:41 +00:00
# Add the PARTUUID of the rootfs partition to the kernel command line
2022-07-05 20:55:47 +00:00
# We must do this *outside* of the chroot, by grabbing the UUID of the loopmounted rootfs
2021-07-15 17:32:41 +00:00
%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)" | \
2021-07-22 08:03:08 +00:00
/bin/awk '{print $NF}' | /bin/tr -d '"' )"
2021-07-15 17:32:41 +00:00
# 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
2021-10-03 04:46:45 +00:00
# Extract UUID of swap partition:
UUID_SWAP=$(/bin/grep 'swap' $INSTALL_ROOT/etc/fstab | awk '{print $1}' | awk -F '=' '{print $2}')
# Fix swap partition: ensure page size is 4096 (differs on the aarch64 AWS build host)
/usr/sbin/mkswap -L "_swap" -p 4096 -U "${UUID_SWAP}" /dev/disk/by-uuid/${UUID_SWAP}
2021-07-15 17:32:41 +00:00
%end