Merged directives into 1 kickstart file

Also fixed issues with image.  Now boots with PARTUUID properly and rocky initial user.

-Skip G.
This commit is contained in:
Skip Grube 2021-06-26 16:46:22 -04:00
parent b8d602b0c6
commit 5d7ed93b45
6 changed files with 102 additions and 132 deletions

View File

@ -5,9 +5,25 @@
# Basic setup information
%include "Rocky8_Rpi4/010_repos_aarch64.ksi"
%include "Rocky8_Rpi4/020_common.ksi"
%include "Rocky8_Rpi4/040_packages.ksi"
#%include "Rocky8_Rpi4/020_common.ksi"
#%include "Rocky8_Rpi4/040_packages.ksi"
# Package selection:
%packages
@core
chrony
cloud-utils-growpart
net-tools
NetworkManager-wifi
vim
bash-completion
nano
raspberrypi2-firmware
raspberrypi2-kernel4
%end
@ -19,8 +35,65 @@ 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="Rpi-Kernel" --baseurl=https://rocky.lowend.ninja/RockyRpi/Rpi-Kernel/ --cost=20
# Install proces:
install
keyboard us --xlayouts=us --vckeymap=us
rootpw --lock
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=mbr --extlinux
lang en_US.UTF-8
# Package selection:
%packages
@core
chrony
cloud-utils-growpart
net-tools
NetworkManager-wifi
vim
bash-completion
nano
raspberrypi2-firmware
raspberrypi2-kernel4
%end
# Post install scripts:
%post
# Generating initrd
# Enabling chronyd on boot
systemctl enable chronyd
# 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
# Apparently kickstart user was not working, attempt to do it here?
/sbin/useradd -c "Rocky Linux default user" -u 1000 -G wheel -m -U rocky
echo "rockylinux" | passwd --stdin rocky
# Ensure no ssh keys are present
rm -f /etc/ssh/*_key*

View File

@ -1,6 +0,0 @@
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="Rpi-Kernel" --baseurl=https://rocky.lowend.ninja/RockyRpi/Rpi-Kernel/ --cost=20

View File

@ -1,30 +0,0 @@
install
keyboard us --xlayouts=us --vckeymap=us
rootpw --lock
user --name=rocky --password=rockylinux --gecos="Rocky default user" --groups=wheel --uid=1000 --gid=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=mbr --extlinux
lang en_US.UTF-8
%post
# Enabling chronyd on boot
systemctl enable chronyd
# 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
%end

View File

@ -1,15 +0,0 @@
%packages
@core
chrony
cloud-utils-growpart
net-tools
NetworkManager-wifi
vim
bash-completion
nano
raspberrypi2-firmware
raspberrypi2-kernel4
%end

View File

@ -1,71 +0,0 @@
%post
# 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 (experimental) ==
This is a minimal Rocky 8 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 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
If you want to automatically resize your / partition, just type the following (as root user):
rootfs-expand
EOF
chown rocky /home/rocky/README
# Next, script to fix the wifi firmware setting:
echo >/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
chown rocky /home/rocky/fix-wifi-rpi4.sh
chmod 755 /home/rocky/fix-wifi-rpi4.sh
# Add rpi-kernel repo:
echo >/etc/yum.repos.d/Rocky_Rpi_kernel.repo << EOF
# Raspberry Pi Kernel repository
#
# This is an additional repository that hosts special kernel builds to use for the Raspberry Pi
# Currently in an unsigned, temporary location - should change soon!
#
# Kernel upstream source is pulled from: https://git.centos.org/rpms/raspberrypi2
#
[Rocky_Rpi_Kernel]
name=Rocky Linux 8 Raspberry Pi Kernel
baseurl=https://rocky.lowend.ninja/RockyRpi/Rpi-Kernel/
gpgcheck=0
enabled=1
EOF
%end

View File

@ -1,15 +1,34 @@
#!/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
# after-the-fact
#
# Usage: ./Rocky8_Rpi4_mkimage.sh /path/to/outputfolder/
#
#
# 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:
OUTDIR=$1
if [[ -z "$OUTDIR" ]]; then
echo "Need to run this script with a path to output directory. Like: ${0} /path/to/output/"
exit 1
fi
mkdir -p ${OUTDIR}
appliance-creator -v -c ./Rocky8_Rpi4.ks -n RockyRpi --version=20210626 --release=1 --vmem=1024 --no-compress -o ${OUTDIR}
# 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!)
appliance-creator -v -c ./Rocky8_Rpi4.ks -n RockyRpi --version=20210626 --release=1 --vmem=2048 --vcpu=2 --no-compress -o ${OUTDIR}
# Post appliance-creator sequence to
# Post appliance-creator sequence to add UUID to the cmdline.txt file under /boot :
# (We don't want to rely on a /dev/ device name, what if a user wants to use a non-sdcard boot mechanism?)
mkdir -p /mnt/tmp
@ -19,7 +38,7 @@ echo "Getting UUID and inserting to boot from ${image} ...."
kpartx -av ${image}
# Get the UUID of our root partition (the ext4 one) (UUID=e3984938429 , strip out quotes("))
uuid=`blkid | grep "mapper/loop0p3" | head -1 | awk '{print $3}' | tr -d '"'`
partuuid=`blkid | grep "mapper/loop0p3" | head -1 | awk '{print $NF}' | tr -d '"' | tr '[:lower:]' '[:upper:]'`
# Mount the /boot partition:
mkdir -p /mnt/tmp
@ -27,13 +46,13 @@ umount /mnt/tmp
mount /dev/mapper/loop0p1 /mnt/tmp
# Swap out the "root=" part of cmdline.txt for our "root=UUID=blah"
sed -i "s/root= /root=${uuid} /" /mnt/tmp/cmdline.txt
sed -i "s/root= /root=${partuuid} /" /mnt/tmp/cmdline.txt
# Debug check to make sure it looks right:
echo "cmdline.txt looks like this, please review:"
cat /mnt/tmp/cmdline.txt
# Finished, unmount:
# Finished, unmount and clean loopbacks:
umount /mnt/tmp
kpartx -d ${image}