[PATCH v4 05/14] scripts/make-gpt.sh: Allow specifying partition size

Demi Marie Obenour
2025-11-22T01:27:50Z

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 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..91c6038f67d4d4906fec4a3412f2ff5fca2671d5 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]*)MiB$ ]]; 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