install.sh fixes: free space detection, btrfs online resize, partition naming #13

Closed
unbrot wants to merge 12 commits from main into devel
Showing only changes of commit 5ef48c84e5 - Show all commits
+10 -3
View File
@@ -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 ───────────────────────────────────────────────────