#!/bin/bash OUTDIR=$1 mkdir -p ${OUTDIR} appliance-creator -v -c ./Rocky8_Rpi4.ks -n RockyRpi --version=20210626 --release=1 --vmem=1024 --no-compress -o ${OUTDIR} # Post appliance-creator sequence to mkdir -p /mnt/tmp # find the image we just made, and make it available on /dev/maper/loop* devices: image=`find ${OUTDIR} -iname *.raw | head -1` 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 '"'` # Mount the /boot partition: mkdir -p /mnt/tmp 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 # Debug check to make sure it looks right: echo "cmdline.txt looks like this, please review:" cat /mnt/tmp/cmdline.txt # Finished, unmount: umount /mnt/tmp