Skip to content

Commit

Permalink
Merge pull request Drewsif#129 from kmpm/fix/parted
Browse files Browse the repository at this point in the history
Fail with error message on parted error
  • Loading branch information
Drewsif authored Apr 19, 2020
2 parents 6969b93 + 18c86f5 commit 24c6f57
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pishrink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ trap cleanup ERR EXIT
#Gather info
info "Gathering data"
beforesize="$(ls -lh "$img" | cut -d ' ' -f 5)"
parted_output="$(parted -ms "$img" unit B print | tail -n 1)"
if ! parted_output=$(parted -ms "$img" unit B print); then
rc=$?
error $LINENO "parted failed with rc $rc"
info "Possibly invalid image. Run 'parted $img unit B print' manually to investigate"
exit -6
fi
partnum="$(echo "$parted_output" | cut -d ':' -f 1)"
partstart="$(echo "$parted_output" | cut -d ':' -f 2 | tr -d 'B')"
loopback="$(losetup -f --show -o "$partstart" "$img")"
Expand All @@ -187,6 +192,7 @@ currentsize="$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -
blocksize="$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)"

logVariables $LINENO beforesize parted_output partnum partstart tune2fs_output currentsize blocksize

#Check if we should make pi expand rootfs on next boot
if [ "$should_skip_autoexpand" = false ]; then
#Make pi expand rootfs on next boot
Expand Down

0 comments on commit 24c6f57

Please sign in to comment.