mirror of
https://github.com/RPi-Distro/pi-gen.git
synced 2025-08-05 18:36:27 +00:00
use a single partitioned loop device (#641)
This commit is contained in:
@ -57,19 +57,15 @@ export -f unmount
|
||||
unmount_image(){
|
||||
sync
|
||||
sleep 1
|
||||
local LOOP_DEVICES
|
||||
LOOP_DEVICES=$(losetup --list | grep "$(basename "${1}")" | cut -f1 -d' ')
|
||||
for LOOP_DEV in ${LOOP_DEVICES}; do
|
||||
if [ -n "${LOOP_DEV}" ]; then
|
||||
local MOUNTED_DIR
|
||||
MOUNTED_DIR=$(mount | grep "$(basename "${LOOP_DEV}")" | head -n 1 | cut -f 3 -d ' ')
|
||||
if [ -n "${MOUNTED_DIR}" ] && [ "${MOUNTED_DIR}" != "/" ]; then
|
||||
unmount "$(dirname "${MOUNTED_DIR}")"
|
||||
LOOP_DEVICE=$(losetup --list | grep "$1" | cut -f1 -d' ')
|
||||
if [ -n "$LOOP_DEVICE" ]; then
|
||||
for part in "$LOOP_DEVICE"p*; do
|
||||
if DIR=$(findmnt -n -o target -S "$part"); then
|
||||
unmount "$DIR"
|
||||
fi
|
||||
sleep 1
|
||||
losetup -d "${LOOP_DEV}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
losetup -d "$LOOP_DEVICE"
|
||||
fi
|
||||
}
|
||||
export -f unmount_image
|
||||
|
||||
|
Reference in New Issue
Block a user