From 5ef48c84e5a819f405006aa36d9b056b38220aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Mon, 27 Apr 2026 16:40:18 +0200 Subject: [PATCH] Replace parted resizepart with sfdisk --force parted fails to resize a mounted partition non-interactively. sfdisk --no-reread --force writes the updated partition table directly without TTY/confirmation issues, and partprobe re-reads it afterwards. Co-Authored-By: Claude Sonnet 4.6 --- system_setup/install.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/system_setup/install.sh b/system_setup/install.sh index 3615166..f0c5a5f 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -377,9 +377,16 @@ if [[ "$MODE" == "shrink" ]]; then fi info "Shrinking partition $S_PNUM to ${NEW_END} MiB in partition table..." - # Use printf instead of -s so parted's "partition is busy" confirmation is answered Yes - printf 'Yes\n' | parted "$S_DISK" resizepart "$S_PNUM" "${NEW_END}MiB" \ - || die "parted resizepart failed." + SECTOR_SIZE=$(cat /sys/block/"${S_DISK##*/}"/queue/hw_sector_size 2>/dev/null || echo 512) + NEW_END_SEC=$(( NEW_END * 1048576 / SECTOR_SIZE )) + sfdisk -d "$S_DISK" | awk -v dev="$S_DEV" -v new_end="$NEW_END_SEC" ' + $0 ~ "^" dev " : " { + match($0, /start= *([0-9]+)/, a) + sub(/size= *[0-9]+/, "size= " (new_end - a[1]+0)) + } + { print } + ' | sfdisk --no-reread --force "$S_DISK" \ + || die "sfdisk partition resize failed." fi # ── Create OEMDRV partition ───────────────────────────────────────────────────