Handle partition labels; replace multiple tr with awk
This commit is contained in:
parent
ad078656b6
commit
dd2066bc5d
|
@ -37,12 +37,14 @@ 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("))
|
||||
partuuid=$(blkid | grep "mapper/loop0p3" | head -1 | awk '{print $NF}' | tr -d '"' | tr '[:lower:]' '[:upper:]')
|
||||
# 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:
|
||||
# Mount the /boot partition (swap the 3rd partition for the first):
|
||||
umount /mnt/tmp
|
||||
mount /dev/mapper/loop0p1 /mnt/tmp
|
||||
mount /dev/mapper/${looppart/3/1} /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
|
||||
|
|
Loading…
Reference in New Issue