diff --git a/debian/changelog b/debian/changelog index bc80d065..f9d28f5c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -61,6 +61,9 @@ debian-cd (3.1.18) UNRELEASED; urgency=medium [ Helge Deller ] * Update hppa support. Closes: #744155 + [ Philipp Hahn ] + * Fix size calculation for EFI image + -- Steve McIntyre <93sam@debian.org> Mon, 20 Apr 2015 12:36:57 +0100 debian-cd (3.1.17) unstable; urgency=medium diff --git a/tools/boot/jessie/boot-x86 b/tools/boot/jessie/boot-x86 index 739a6304..2c2e7b0b 100644 --- a/tools/boot/jessie/boot-x86 +++ b/tools/boot/jessie/boot-x86 @@ -455,17 +455,38 @@ if [ -d boot$N/isolinux/grub ] && [ $BOOT_EFI -ne 0 ] ; then >> $CDDIR/boot/grub/grub.cfg # Stuff the EFI boot files into a FAT filesystem, making it as - # small as possible. 24KiB headroom seems to be enough; - # (x+31)/32*32 rounds up to multiple of 32. - # This is the same as in efi-image, but we need to redo it here in - # the case of a multi-arch amd64/i386 image + # small as possible. - size=0 + sector_bytes=512 # -S + cluster_sectors=4 # -s + cluster_bytes=$((sector_bytes * cluster_sectors)) + + clusters=2 # 1 cluster for each sub-directory for file in $CDDIR/efi/boot/boot*.efi; do - size=$(($size + $(stat -c %s "$file"))) + [ -f "$file" ] || continue + clusters=$(($clusters + (($(stat -c %s "$file") + $cluster_bytes - 1) / $cluster_bytes))) done + reserved_sectors=1 # boot-sector -R + reserved_bytes=$(($reserved_sectors * $sector_bytes)) + fat_copies=2 # -f + if [ "$clusters" -le $(((1 << 12) - 2)) ]; then + fat_entry_bytes=3/2 # -F + elif [ "$clusters" -le $(((1 << 16) - 2)) ]; then + fat_entry_bytes=2 # -F + else + fat_entry_bytes=4 # -F + fi + fat_bytes=$((($clusters * $fat_entry_bytes + $sector_bytes - 1) / $sector_bytes * $sector_bytes)) + root_entries=512 # -r + root_entry_bytes=32 + root_bytes=$(($root_entries * root_entry_bytes)) + size=$(($reserved_bytes + $fat_copies * $fat_bytes + $root_bytes + $clusters * $cluster_bytes)) - blocks=$((($size / 1024 + 55) / 32 * 32 )) + track_sectors=32 + track_bytes=$((sector_bytes * $track_sectors)) + tracks=$((($size + $track_bytes - 1) / $track_bytes)) + block_bytes=1024 + blocks=$(($tracks * $track_bytes / $block_bytes)) rm -f $CDDIR/boot/grub/efi.img mkfs.msdos -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null diff --git a/tools/boot/stretch/boot-x86 b/tools/boot/stretch/boot-x86 index fe270bce..9e29fd31 100644 --- a/tools/boot/stretch/boot-x86 +++ b/tools/boot/stretch/boot-x86 @@ -481,17 +481,38 @@ if [ -d boot$N/isolinux/grub ] && [ $BOOT_EFI -ne 0 ] ; then echo " CD$N/boot/grub/grub.cfg has $NUM_ENTRIES boot entries defined" # Stuff the EFI boot files into a FAT filesystem, making it as - # small as possible. 24KiB headroom seems to be enough; - # (x+31)/32*32 rounds up to multiple of 32. - # This is the same as in efi-image, but we need to redo it here in - # the case of a multi-arch amd64/i386 image + # small as possible. - size=0 + sector_bytes=512 # -S + cluster_sectors=4 # -s + cluster_bytes=$((sector_bytes * cluster_sectors)) + + clusters=2 # 1 cluster for each sub-directory for file in $CDDIR/efi/boot/boot*.efi; do - size=$(($size + $(stat -c %s "$file"))) + [ -f "$file" ] || continue + clusters=$(($clusters + (($(stat -c %s "$file") + $cluster_bytes - 1) / $cluster_bytes))) done + reserved_sectors=1 # boot-sector -R + reserved_bytes=$(($reserved_sectors * $sector_bytes)) + fat_copies=2 # -f + if [ "$clusters" -le $(((1 << 12) - 2)) ]; then + fat_entry_bytes=3/2 # -F + elif [ "$clusters" -le $(((1 << 16) - 2)) ]; then + fat_entry_bytes=2 # -F + else + fat_entry_bytes=4 # -F + fi + fat_bytes=$((($clusters * $fat_entry_bytes + $sector_bytes - 1) / $sector_bytes * $sector_bytes)) + root_entries=512 # -r + root_entry_bytes=32 + root_bytes=$(($root_entries * root_entry_bytes)) + size=$(($reserved_bytes + $fat_copies * $fat_bytes + $root_bytes + $clusters * $cluster_bytes)) - blocks=$((($size / 1024 + 55) / 32 * 32 )) + track_sectors=32 + track_bytes=$((sector_bytes * $track_sectors)) + tracks=$((($size + $track_bytes - 1) / $track_bytes)) + block_bytes=1024 + blocks=$(($tracks * $track_bytes / $block_bytes)) rm -f $CDDIR/boot/grub/efi.img mkfs.msdos -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null diff --git a/tools/boot/wheezy/boot-x86 b/tools/boot/wheezy/boot-x86 index 4143b04b..89667378 100644 --- a/tools/boot/wheezy/boot-x86 +++ b/tools/boot/wheezy/boot-x86 @@ -433,17 +433,38 @@ if [ -d boot$N/isolinux/grub ] ; then >> $CDDIR/boot/grub/grub.cfg # Stuff the EFI boot files into a FAT filesystem, making it as - # small as possible. 24KiB headroom seems to be enough; - # (x+31)/32*32 rounds up to multiple of 32. - # This is the same as in efi-image, but we need to redo it here in - # the case of a multi-arch amd64/i386 image + # small as possible. - size=0 + sector_bytes=512 # -S + cluster_sectors=4 # -s + cluster_bytes=$((sector_bytes * cluster_sectors)) + + clusters=2 # 1 cluster for each sub-directory for file in $CDDIR/efi/boot/boot*.efi; do - size=$(($size + $(stat -c %s "$file"))) + [ -f "$file" ] || continue + clusters=$(($clusters + (($(stat -c %s "$file") + $cluster_bytes - 1) / $cluster_bytes))) done + reserved_sectors=1 # boot-sector -R + reserved_bytes=$(($reserved_sectors * $sector_bytes)) + fat_copies=2 # -f + if [ "$clusters" -le $(((1 << 12) - 2)) ]; then + fat_entry_bytes=3/2 # -F + elif [ "$clusters" -le $(((1 << 16) - 2)) ]; then + fat_entry_bytes=2 # -F + else + fat_entry_bytes=4 # -F + fi + fat_bytes=$((($clusters * $fat_entry_bytes + $sector_bytes - 1) / $sector_bytes * $sector_bytes)) + root_entries=512 # -r + root_entry_bytes=32 + root_bytes=$(($root_entries * root_entry_bytes)) + size=$(($reserved_bytes + $fat_copies * $fat_bytes + $root_bytes + $clusters * $cluster_bytes)) - blocks=$((($size / 1024 + 55) / 32 * 32 )) + track_sectors=32 + track_bytes=$((sector_bytes * $track_sectors)) + tracks=$((($size + $track_bytes - 1) / $track_bytes)) + block_bytes=1024 + blocks=$(($tracks * $track_bytes / $block_bytes)) rm -f $CDDIR/boot/grub/efi.img mkfs.msdos -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null