From 890b6b115b967aa9a35c73d55dfd579c5f07c597 Mon Sep 17 00:00:00 2001 From: Per-Arne Hellarvik Date: Tue, 10 Nov 2026 13:10:42 +0100 Subject: [PATCH] Fix the inode count in pct-shrink-rootfs GNU df refuses -i together with --output, so the script stopped right after mounting the container ("options -i and --output are mutually exclusive"). The iused field needs no -i: use df --output=iused. The df stub in the tests accepted the combination and hid the bug; it now rejects it the way GNU df does. Generated with AI Co-Authored-By: Claude Opus 5.5 --- scripts/pct-shrink-rootfs | 2 +- tests/test_pct_shrink.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/pct-shrink-rootfs b/scripts/pct-shrink-rootfs index d4aa48b..f054fcd 100755 --- a/scripts/pct-shrink-rootfs +++ b/scripts/pct-shrink-rootfs @@ -133,7 +133,7 @@ main() { mounted=1 pct mount "$ctid" used=$(df -B1 --output=used "$root" | tail -n1 | tr -d ' ') - iused=$(df -i --output=iused "$root" | tail -n1 | tr -d ' ') + iused=$(df --output=iused "$root" | tail -n1 | tr -d ' ') unmount_or_die [[ $used =~ ^[0-9]+$ && $iused =~ ^[0-9]+$ ]] || die "cannot read df output" diff --git a/tests/test_pct_shrink.py b/tests/test_pct_shrink.py index 1fc6622..3b6329a 100644 --- a/tests/test_pct_shrink.py +++ b/tests/test_pct_shrink.py @@ -20,7 +20,9 @@ STUBS = { "ha-manager": 'echo "${STUB_HA_OUT:-}"', "pvesr": 'echo "${STUB_PVESR_OUT:-}"', "df": """echo "df $*" >> "$STUB_LOG" -if [[ "$*" == *-i* ]]; then echo IUsed; echo "${STUB_IUSED:-1000}" +# like GNU df: -i and --output cannot be combined +if [[ " $* " == *" -i "* && "$*" == *--output* ]]; then echo "df: options -i and --output are mutually exclusive" >&2; exit 1; fi +if [[ "$*" == *--output=iused* ]]; then echo IUsed; echo "${STUB_IUSED:-1000}" else echo Used; echo "${STUB_USED:-1073741824}"; fi""", "rsync": """echo "rsync $*" >> "$STUB_LOG" [[ -z ${STUB_RSYNC_FAIL:-} ]]""",