]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Use explicit disk geometry for generated FAT filesystem images
authorMichael Brown <mcb30@ipxe.org>
Fri, 22 Jan 2021 12:22:11 +0000 (12:22 +0000)
committerMichael Brown <mcb30@ipxe.org>
Fri, 22 Jan 2021 12:29:25 +0000 (12:29 +0000)
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>
src/util/genfsimg

index 3f1356eae3268f20c671c4b853a4bbdd0914e67d..85fb006c49696f2eed90051703fc83621559ac9e 100755 (executable)
@@ -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}"