Skip to content

Commit

Permalink
Make cleanup_image unmount code more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
pguyot committed May 13, 2024
1 parent 83414dc commit 451be18
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions cleanup_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,22 @@ 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 --quiet "${mp}" || {
fuser -ckv "${mp}"
sleep 1
retries=1
while ! umount --quiet --force "${mp}" ; do
retries=$((retries + 1))
if [ "${retries}" -ge 10 ]; then
echo "Could not unmount ${mp} after ${retries} attempts, giving up."
exit 1
fi
fuser -ckv "${mp}"
sleep 1
done
}
done

if [[ "${optimize}x" == "x" || "${optimize}x" == "yesx" ]]; then
rootfs_partnum=${rootpartition}
Expand Down

0 comments on commit 451be18

Please sign in to comment.