From 5492843aa8f06554d9a1eba452922ef4724cd43b Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 14 Aug 2019 15:24:03 +1000 Subject: [PATCH] block-device-efi : expand disk size calculation As noted in the change, 7fd52ba84180b4e749ccf4c9db8c49eafff46ea8 increased the size of the EFI partition considerably. This has meant that our padding upwards of the disk size is insufficient and EFI builds (arm64 in particular) is failing due to out-of-disk errors during final image operations like installing kernels. Similar to the discussion we had in I65fa13a088eecdfe61636678578577ea2cfb3c0c, this feels a bit ugly because we're mixing logic here with sizes specified in block-device config files. But it boils down to the same problem; we are calculating the disk size here and passing it to the block-layer, so unless we want to make large changes to the status quo about where these sizes are calculated, small adjustments here are the most KISS solution. Thus we check if we have selected the EFI bootloader element, and thus assume there will be a large system EFI partition and expand the disk size accordingly. Change-Id: Ifa05366c2f2b95259f3312e4dde8c85347075ba1 --- diskimage_builder/lib/disk-image-create | 12 ++++++++++++ .../efi-bootloader-disk-size-4c1a9f18967104fb.yaml | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 releasenotes/notes/efi-bootloader-disk-size-4c1a9f18967104fb.yaml diff --git a/diskimage_builder/lib/disk-image-create b/diskimage_builder/lib/disk-image-create index 7dd03909..3d3996d7 100644 --- a/diskimage_builder/lib/disk-image-create +++ b/diskimage_builder/lib/disk-image-create @@ -446,6 +446,18 @@ if [ "$DIB_ROOT_FSTYPE" = "ext4" ] ; then fi fi +# EFI system partitions default to be quite large at 512mb for maximum +# compatability (see notes in +# 7fd52ba84180b4e749ccf4c9db8c49eafff46ea8) . We need to increase the +# total size to account for this, or we run out of space creating the +# final image. See if we have included the block-device-efi element, +# which implies we have a large EFI partition, and then pad the final +# image size. +if [[ ${IMAGE_ELEMENT} =~ "block-device-efi" ]]; then + echo "Expanding disk for EFI partition" + du_size=$(( $du_size + (525 * 1024) )) +fi + # Rounding down size so that is is a multiple of 64, works around a bug in # qemu-img that may occur when compressing raw images that aren't a multiple # of 64k. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1180021 diff --git a/releasenotes/notes/efi-bootloader-disk-size-4c1a9f18967104fb.yaml b/releasenotes/notes/efi-bootloader-disk-size-4c1a9f18967104fb.yaml new file mode 100644 index 00000000..c8124307 --- /dev/null +++ b/releasenotes/notes/efi-bootloader-disk-size-4c1a9f18967104fb.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + When using the ``block-device-efi`` element to create an EFI based + system (most notably, with ARM64), the final disk size is now + expanded for the 512MiB system EFI partition introduced with 2.24.0