Initial support for extended partition images :D

This commit is contained in:
Drew Bonasera 2020-06-13 17:10:19 -04:00
parent 574fab3e52
commit 53a59cf9a0
1 changed files with 11 additions and 4 deletions

View File

@ -276,6 +276,11 @@ if (( $rc )); then
fi fi
partnum="$(echo "$parted_output" | tail -n 1 | cut -d ':' -f 1)" partnum="$(echo "$parted_output" | tail -n 1 | cut -d ':' -f 1)"
partstart="$(echo "$parted_output" | tail -n 1 | cut -d ':' -f 2 | tr -d 'B')" partstart="$(echo "$parted_output" | tail -n 1 | cut -d ':' -f 2 | tr -d 'B')"
if [ -z "$(parted -s "$img" unit B print | grep "$partstart" | grep logical)" ]; then
parttype="primary"
else
parttype="logical"
fi
loopback="$(losetup -f --show -o "$partstart" "$img")" loopback="$(losetup -f --show -o "$partstart" "$img")"
tune2fs_output="$(tune2fs -l "$loopback")" tune2fs_output="$(tune2fs -l "$loopback")"
rc=$? rc=$?
@ -288,10 +293,12 @@ fi
currentsize="$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -d ':' -f 2)" currentsize="$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -d ':' -f 2)"
blocksize="$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)" blocksize="$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)"
logVariables $LINENO beforesize parted_output partnum partstart tune2fs_output currentsize blocksize logVariables $LINENO beforesize parted_output partnum partstart parttype tune2fs_output currentsize blocksize
#Check if we should make pi expand rootfs on next boot #Check if we should make pi expand rootfs on next boot
if [ "$should_skip_autoexpand" = false ]; then if [ "$parttype" == "logical" ]; then
echo "WARNING: PiShrink does not yet support autoexpanding of this type of image"
elif [ "$should_skip_autoexpand" = false ]; then
set_autoexpand set_autoexpand
else else
echo "Skipping autoexpanding process..." echo "Skipping autoexpanding process..."
@ -357,7 +364,7 @@ if (( $rc )); then
exit -13 exit -13
fi fi
parted -s "$img" unit B mkpart primary "$partstart" "$newpartend" parted -s "$img" unit B mkpart "$parttype" "$partstart" "$newpartend"
rc=$? rc=$?
if (( $rc )); then if (( $rc )); then
error $LINENO "parted failed with rc $rc" error $LINENO "parted failed with rc $rc"