[PATCH v5 03/13] scripts/make-gpt.sh: Allow specifying partition size

Demi Marie Obenour
2025-11-26T19:41:57Z

systemd-sysupdate requires that partitions are large enough to hold the
newly downloaded images. This requires that they be large enough to
have room to grow. Allow specifying the partition size manually,
overriding the default (the size of the file that will be copied into
the partition).

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
---
Changes since v4:
- Remove the MiB suffix.

Changes since v2:
- Split into separate commit.
---
scripts/make-gpt.sh | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/scripts/make-gpt.sh b/scripts/make-gpt.sh
index 0ae3d0005e5ae7d6214270fedb2fafb0a7064cf5..c3f16e6c029d1d27d3da9e05e50945a56bfad9f8 100644
--- a/scripts/make-gpt.sh
+++ b/scripts/make-gpt.sh
@@ -45,8 +45,13 @@ table="label: gpt"
# Keep 1MiB free at the start, and 1MiB free at the end.
gptBytes=$((ONE_MiB * 2))
for partition; do
- partitionPath=$(partitionPath "$partition")
- sizeMiB=$(sizeMiB "$partitionPath")
+ if [[ "$partition" =~ :([1-9][0-9]*)$ ]]; then
+ sizeMiB=${BASH_REMATCH[1]}
+ partition=${partition%:*}
+ else
+ partitionPath=$(partitionPath "$partition")
+ sizeMiB=$(sizeMiB "$partitionPath")
+ fi
table+=$'\n'"size=${sizeMiB}MiB,$(awk -f "$scriptsDir/sfdisk-field.awk" -v partition="$partition")"
gptBytes=$((gptBytes + sizeMiB * ONE_MiB))
done

--
2.52.0