From 6e49dd5495c2fca02feb738fc0a5316d1127261b Mon Sep 17 00:00:00 2001 From: Paul Guyot Date: Mon, 13 May 2024 08:30:16 +0200 Subject: [PATCH] Fix an issue where unmount would fail because of lingering processes Update cleanup_image script to use fuser and umount --lazy --force in last resort. Fixes #105 --- .github/workflows/test-unmount-force.yml | 24 ++++++++++++++++++++++++ cleanup_image.sh | 12 ++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/test-unmount-force.yml diff --git a/.github/workflows/test-unmount-force.yml b/.github/workflows/test-unmount-force.yml new file mode 100644 index 0000000..0eb2d18 --- /dev/null +++ b/.github/workflows/test-unmount-force.yml @@ -0,0 +1,24 @@ +name: Test unmount succeeds even if processes are still running +on: + push: + branches: + - 'main' + - 'releases/**' + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ # pguyot/arm-runner-action@HEAD + with: + image_additional_mb: 1024 + commands: | + sudo apt update -y + sudo apt install xvfb fluxbox -y + export DISPLAY=:0.0 + Xvfb :0 -screen 0 1280x720x24 > /dev/null 2>&1 & + sleep 1 + fluxbox > /dev/null 2>&1 & diff --git a/cleanup_image.sh b/cleanup_image.sh index d3bdcdc..cd91612 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" || true - umount "${mount}/dev" || true - umount "${mount}/proc" || true - umount "${mount}/sys" || true - umount "${mount}/boot" || true - umount "${mount}" || true + 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 if [[ "${optimize}x" == "x" || "${optimize}x" == "yesx" ]]; then rootfs_partnum=${rootpartition}