From 48d175607e8c9da7d35420c34b3d49250995ee7e Mon Sep 17 00:00:00 2001 From: Drew Bonasera Date: Tue, 14 Feb 2023 03:59:58 -0500 Subject: [PATCH] Check if loopback automatically gets mounted by OS and umount it Closes #254 --- pishrink.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pishrink.sh b/pishrink.sh index e5435ec..ba291f0 100755 --- a/pishrink.sh +++ b/pishrink.sh @@ -1,6 +1,6 @@ #!/bin/bash -version="v0.1.2" +version="v0.1.3" CURRENT_DIR="$(pwd)" SCRIPTNAME="${0##*/}" @@ -70,7 +70,13 @@ function set_autoexpand() { #Make pi expand rootfs on next boot mountdir=$(mktemp -d) partprobe "$loopback" - mount "$loopback" "$mountdir" + sleep 3 + umount "$loopback" > /dev/null 2>&1 + mount "$loopback" "$mountdir" -o rw + if (( $? != 0 )); then + info "Unable to mount loopback, autoexpand will not be enabled" + return + fi if [ ! -d "$mountdir/etc" ]; then info "/etc not found, autoexpand will not be enabled"