···
, # size of the boot partition, is only used if partitionTableType is
# either "efi" or "hybrid"
18
+
# This will be undersized slightly, as this is actually the offset of
19
+
# the end of the partition. Generally it will be 1MiB smaller.
, # The files and directories to be placed in the target file system.
···
${if diskSize == "auto" then ''
${if partitionTableType == "efi" || partitionTableType == "hybrid" then ''
256
-
additionalSpace=$(( ($(numfmt --from=iec '${additionalSpace}') + $(numfmt --from=iec '${bootSize}')) ))
258
+
# Add the GPT at the end
259
+
gptSpace=$(( 512 * 34 * 1 ))
260
+
# Normally we'd need to account for alignment and things, if bootSize
261
+
# represented the actual size of the boot partition. But it instead
262
+
# represents the offset at which it ends.
263
+
# So we know bootSize is the reserved space in front of the partition.
264
+
reservedSpace=$(( gptSpace + $(numfmt --from=iec '${bootSize}') ))
265
+
'' else if partitionTableType == "legacy+gpt" then ''
266
+
# Add the GPT at the end
267
+
gptSpace=$(( 512 * 34 * 1 ))
268
+
# And include the bios_grub partition; the ext4 partition starts at 2MB exactly.
269
+
reservedSpace=$(( gptSpace + 2 * 1024*1024 ))
270
+
'' else if partitionTableType == "legacy" then ''
271
+
# Add the 1MiB aligned reserved space (includes MBR)
272
+
reservedSpace=$(( 1024*1024 ))
258
-
additionalSpace=$(( $(numfmt --from=iec '${additionalSpace}') ))
276
+
additionalSpace=$(( $(numfmt --from=iec '${additionalSpace}') + reservedSpace ))
# Compute required space in filesystem blocks
diskUsage=$(find . ! -type d -exec 'du' '--apparent-size' '--block-size' "${blockSize}" '{}' ';' | cut -f1 | sum_lines)