Check if loopback automatically gets mounted by OS and umount it

Closes #254
This commit is contained in:
Drew Bonasera 2023-02-14 03:59:58 -05:00
parent 87e1ff064e
commit 48d175607e
1 changed files with 8 additions and 2 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
version="v0.1.2" version="v0.1.3"
CURRENT_DIR="$(pwd)" CURRENT_DIR="$(pwd)"
SCRIPTNAME="${0##*/}" SCRIPTNAME="${0##*/}"
@ -70,7 +70,13 @@ function set_autoexpand() {
#Make pi expand rootfs on next boot #Make pi expand rootfs on next boot
mountdir=$(mktemp -d) mountdir=$(mktemp -d)
partprobe "$loopback" 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 if [ ! -d "$mountdir/etc" ]; then
info "/etc not found, autoexpand will not be enabled" info "/etc not found, autoexpand will not be enabled"