tools: Calculate EFI ESP FAT FS size based on contents.

This requires switching to the dosfstools from alpine:edge since neither the
busybox nor alpine:3.5 dosfstools supports the -C option (in fact alpine:3.5
only has mkfs.fat and not mkfs.vfat).

The 511k slack seems like a lot to me, but 256k was somehow not enough.

Fixes #1304.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
Ian Campbell
2017-03-15 13:24:41 +00:00
parent 1b31c5582d
commit fb242fad9d
3 changed files with 8 additions and 6 deletions

View File

@@ -1,8 +1,9 @@
FROM alpine:3.5
FROM alpine:edge
RUN \
apk update && apk upgrade && \
apk add --no-cache \
dosfstools \
libarchive-tools \
binutils \
gummiboot \

View File

@@ -37,14 +37,15 @@ objcopy \
# create a ISO with a EFI boot partition
mkdir -p iso
dd if=/dev/zero of=iso/efi.raw bs=1024 count=78000
mkfs.vfat iso/efi.raw
# Stuff it into a FAT filesystem, making it as small as possible. 511KiB
# headroom seems to be enough; (x+31)/32*32 rounds up to multiple of 32.
mkfs.vfat -v -C iso/efi.raw \
$(( ($(stat -c %s "mobylinux.efi") / 1024 + 511) \
/ 32 * 32 ))
echo "mtools_skip_check=1" >> /etc/mtools.conf && \
mmd -i iso/efi.raw ::/EFI
mmd -i iso/efi.raw ::/EFI/BOOT
mcopy -i iso/efi.raw mobylinux.efi ::/EFI/BOOT/BOOTX64.EFI
xorriso -as mkisofs \
-R -f -e efi.raw -no-emul-boot -o mobylinux-efi.iso iso