Fix size calculation for EFI image
Backport fix from master
This commit is contained in:
parent
c9d99a53bc
commit
15ecf43c09
|
@ -25,6 +25,7 @@ debian-cd (3.1.17-jessie) UNRELEASED; urgency=medium
|
||||||
+ Switch references to d-i.debian.org to use https instead of http.
|
+ Switch references to d-i.debian.org to use https instead of http.
|
||||||
Closes: #809698. Also use --ca-directory /etc/ssl/ca-debian/ with wget
|
Closes: #809698. Also use --ca-directory /etc/ssl/ca-debian/ with wget
|
||||||
to ensure this works.
|
to ensure this works.
|
||||||
|
+ Fix size calculation for EFI image
|
||||||
|
|
||||||
-- Steve McIntyre <93sam@debian.org> Mon, 20 Apr 2015 12:36:57 +0100
|
-- Steve McIntyre <93sam@debian.org> Mon, 20 Apr 2015 12:36:57 +0100
|
||||||
|
|
||||||
|
|
|
@ -458,17 +458,38 @@ if [ -d boot$N/isolinux/grub ] && [ $BOOT_EFI -ne 0 ] ; then
|
||||||
>> $CDDIR/boot/grub/grub.cfg
|
>> $CDDIR/boot/grub/grub.cfg
|
||||||
|
|
||||||
# Stuff the EFI boot files into a FAT filesystem, making it as
|
# Stuff the EFI boot files into a FAT filesystem, making it as
|
||||||
# small as possible. 24KiB headroom seems to be enough;
|
# small as possible.
|
||||||
# (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
|
|
||||||
|
|
||||||
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
|
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
|
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
|
rm -f $CDDIR/boot/grub/efi.img
|
||||||
mkfs.msdos -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null
|
mkfs.msdos -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null
|
||||||
|
|
Loading…
Reference in New Issue