diff --git a/Rocky8_Rpi4_mkimage.sh b/Rocky8_Rpi4_mkimage.sh index 426ddfa..56cc59b 100755 --- a/Rocky8_Rpi4_mkimage.sh +++ b/Rocky8_Rpi4_mkimage.sh @@ -39,12 +39,18 @@ kpartx -av "${image}" # Get the loop partition; it might be loop0p3, loop1p3, ... looppart=$(kpartx -l "${image}" | awk '/p3/{print $1}') -# Get the UUID of our root partition (the ext4 one) (UUID=e3984938429 , strip out quotes("), and force upper case) -partuuid=$(blkid | grep "mapper/${looppart}" | head -1 | awk '{gsub(/\"/,"", $NF); print toupper($0)}') -# Mount the /boot partition (swap the 3rd partition for the first): +# Get the UUID of our root partition (the ext4 one) (UUID=e3984938429 , strip out quotes("), and force upper case) +partuuid=$(blkid | grep "mapper/${looppart}" | head -1 | awk '{print $NF}' | tr -d '"' | tr '[:lower:]' '[:upper:]') + + +# Get the boot partition and mount it +# (change 3rd partition for 1st, so loop0p3 becomes loop0p1): +bootloop=$(echo "${looppart}" | sed 's/p3$/p1/') + umount /mnt/tmp -mount /dev/mapper/${looppart/3/1} /mnt/tmp +mount /dev/mapper/${bootloop} /mnt/tmp + # Swap out the "root=" part of cmdline.txt for our "root=UUID=blah" sed -i "s/root= /root=${partuuid} /" /mnt/tmp/cmdline.txt