From 96f67e72ac5f5166df75e8fcd9d590831c0e2851 Mon Sep 17 00:00:00 2001 From: Paul Guyot Date: Mon, 13 May 2024 14:32:15 +0200 Subject: [PATCH] Make cleanup_image unmount code more robust --- cleanup_image.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cleanup_image.sh b/cleanup_image.sh index cd91612..0a271a0 100644 --- a/cleanup_image.sh +++ b/cleanup_image.sh @@ -26,12 +26,12 @@ if [[ -d "${mount}" ]]; then (cat /dev/zero >"${mount}/zero.fill" 2>/dev/null || true); sync; rm -f "${mount}/zero.fill" fi - umount "${mount}/dev/pts" || fuser -ckv "${mount}/dev/pts" || umount --force --lazy "${mount}/dev/pts" || true - umount "${mount}/dev" || fuser -ckv "${mount}/dev" || umount --force --lazy "${mount}/dev" || true - umount "${mount}/proc" || fuser -ckv "${mount}/proc" || umount --force --lazy "${mount}/proc" || true - umount "${mount}/sys" || fuser -ckv "${mount}/sys" || umount --force --lazy "${mount}/sys" || true - umount "${mount}/boot" || fuser -ckv "${mount}/boot" || umount --force --lazy "${mount}/boot" || true - umount "${mount}" || fuser -ckv "${mount}" || umount --force --lazy "${mount}" || true + for mp in "${mount}/dev/pts" "${mount}/dev" "${mount}/proc" "${mount}/sys" "${mount}/boot" "${mount}" ; do + umount "${mp}" || \ + (fuser -ckv "${mp}" && umount "${mp}") || \ + umount --force --lazy "${mp}" || \ + echo "Could not unmount ${mp}" + done if [[ "${optimize}x" == "x" || "${optimize}x" == "yesx" ]]; then rootfs_partnum=${rootpartition}