mkarchiso: increase the additional free space added to efiboot.img

Less than 1 MiB (but rounded up to one) is needed to account for file and
directory entries, especially when using FAT32. Otherwise the ISO build could stop with:

    Disk full

The rest of the increase is to allow more space for adding custom files
after the fact, i.e. when repacking the ISO. E.g. for the purposes of
adding a signed boot loader for Secure Boot or similar. See
https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface/Secure_Boot#ISO_repacking
This commit is contained in:
nl6720 2024-05-07 13:59:30 +03:00
parent 2febfabd6c
commit 1ae3ff6ff6
No known key found for this signature in database
GPG key ID: 6B5387E670A955AD
2 changed files with 6 additions and 7 deletions

View file

@ -14,6 +14,9 @@ Changed
- Moved the ``pkglist.x86_64.txt`` file outside the bootstrap tarball's ``root.x86_64`` directly to avoid polluting the
root file system.
- Use 4 MiB OVMF files in ``run_archiso`` instead of the old 2 MiB ones.
- Increase the additional free space of the EFI partition size from 1 MiB to 8 MiB to account for file system overhead
when using FAT32 (needs less than 1 MiB) and to give more space for adding custom files when repacking an ISO (e.g.
when preparing it for Secure Boot).
Deprecated
----------

View file

@ -528,17 +528,13 @@ _make_efibootimg() {
local imgsize_kib="0"
local imgsize_bytes=${1}
if (( imgsize_bytes < 2*1024*1024 )); then
_msg_info "Validating '${bootmode}': efiboot.img size is ${imgsize_bytes} bytes is less than 2 MiB! Bumping up to 2 MiB"
imgsize_bytes=$((2*1024*1024))
fi
# Convert from bytes to KiB and round up to the next full MiB with an additional MiB for reserved sectors.
# Convert from bytes to KiB and round up to the next full MiB with an additional 8 MiB for reserved sectors, file
# and directory entries and to allow adding custom files when repacking the ISO.
imgsize_kib="$(
awk 'function ceil(x){return int(x)+(x>int(x))}
function byte_to_kib(x){return x/1024}
function mib_to_kib(x){return x*1024}
END {print mib_to_kib(ceil((byte_to_kib($1)+1024)/1024))}' <<<"${imgsize_bytes}"
END {print mib_to_kib(ceil((byte_to_kib($1)+8192)/1024))}' <<<"${imgsize_bytes}"
)"
# The FAT image must be created with mkfs.fat not mformat, as some systems have issues with mformat made images:
# https://lists.gnu.org/archive/html/grub-devel/2019-04/msg00099.html