diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2022-11-03 21:14:37 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2022-11-11 13:54:56 +0100 |
commit | 7288319d5c0d246d38762bc99413476c826aa6e6 (patch) | |
tree | 9c3acb397d602cd95208be264ea3dfdf4458e4b2 | |
parent | 512bc9745583c5c642cf40cec4aaf033dc564238 (diff) | |
download | alpine-conf-7288319d5c0d246d38762bc99413476c826aa6e6.zip |
setup-disk: increase default boot partition size for EFI
Consider my laptop with linux-lts on UEFI with Secure Boot:
System.map-lts.....4 MiB
initramfs-lts.....36 MiB
vmlinuz-lts........8 MiB
linux-lts.efi.....44 MiB (signed Unified Kernel Image)
linux-lts.efi.bak 44 MiB (backup of the previous)
Total............136 MiB
256 MiB might be enough, but what if the user wants to experiment with
more kernel variants? It would be still too tight. On the other side,
if the user has only 1 GiB disk (e.g. ncopa uses 1GiB images for testing),
then even 256 MiB would be too much.
Originally, I just increased the default to 512 MiB, but ncopa pointed
out that it's too much for small disks and he personally uses 1GiB
disks (images) for testing. For this reason, I chose a more
sophisticated approach that takes into account the size of the disk.
* 512 MiB if disk > 8 GiB
* 264 MiB if disk > 2 GiB
* 160 MiB otherwise
And the size is never lower than the approximate minimal allowed size of
the FAT32 filesystem for the disk's block size (32 MiB for 512 bytes
blocks, 260 MiB for 4096 bytes blocks).
Issue reported by Andrey Maslyuk <andrey@maslyuk.net> (via email).
-rw-r--r-- | setup-disk.in | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/setup-disk.in b/setup-disk.in index 5f7d799..a65a088 100644 --- a/setup-disk.in +++ b/setup-disk.in @@ -1610,10 +1610,22 @@ fi # reduce size of ESP partition if [ -n "$USE_EFI" ] && [ -z "$USE_CRYPT" ] && [ -z "$BOOT_SIZE" ]; then blocksize=$(cat $(echo $diskdevs | sed -E -e 's:/dev/([^ ]+):/sys/block/\1/queue/logical_block_size:g') | sort -n | tail -n 1) + size_blk=$(cat $(echo $diskdevs | sed -E -e 's:/dev/([^ ]+):/sys/block/\1/size:g') | sort -n | tail -n 1) + size_mb=$(( ${blocksize:-512} * ${size_blk:-0} >> 20 )) + + if [ "$size_mb " -gt 8192 ]; then + BOOT_SIZE=512 + elif [ "$size_mb" -gt 2048 ]; then + BOOT_SIZE=264 + else + BOOT_SIZE=160 + fi + # calculate minimal FAT32 size # for block size 512 minimal size is 32MB # for block size 4096, minimal size is 260M - BOOT_SIZE=$(( ${blocksize:-512} * 64 / 1000 + 2 )) + min_size=$(( ${blocksize:-512} * 64 / 1000 + 2 )) + BOOT_SIZE=$(( BOOT_SIZE < min_size ? min_size : BOOT_SIZE )) fi set -- $diskdevs |