[build] Use explicit disk geometry for generated FAT filesystem images

For FAT filesystem images larger than a 1.44MB floppy disk, round up
the image size to a whole number of 504kB cylinders before formatting.
This avoids losing up to a cylinder's worth of expected space in the
filesystem image.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
pull/141/merge
Michael Brown 2021-01-22 12:22:11 +00:00
parent a2a6618d46
commit 05d7591a71
1 changed files with 7 additions and 4 deletions

View File

@ -242,12 +242,15 @@ if [ -n "${FATIMG}" ] ; then
FATSIZE=$(( FATSIZE + PAD + 256 ))
touch "${FATIMG}"
if [ "${FATSIZE}" -le "1440" ] ; then
truncate -s 1440K "${FATIMG}"
mformat -v iPXE -i "${FATIMG}" -f 1440 ::
FATSIZE=1440
FATARGS="-f 1440"
else
truncate -s "${FATSIZE}K" "${FATIMG}"
mformat -v iPXE -i "${FATIMG}" ::
FATCYLS=$(( ( FATSIZE + 503 ) / 504 ))
FATSIZE=$(( FATCYLS * 504 ))
FATARGS="-s 63 -h 16 -t ${FATCYLS}"
fi
truncate -s "${FATSIZE}K" "${FATIMG}"
mformat -v iPXE -i "${FATIMG}" ${FATARGS} ::
mcopy -i "${FATIMG}" -s "${FATDIR}"/* ::
if [ "${BIOSDIR}" = "${FATDIR}" ] ; then
syslinux "${FATIMG}"