From: Michael Brown Date: Mon, 23 Mar 2026 16:08:09 +0000 (+0000) Subject: [build] Use a partition table in generated USB disk images X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2c84b68;p=thirdparty%2Fipxe.git [build] Use a partition table in generated USB disk images The USB disk image constructed by util/genfsimg is currently a raw FAT filesystem, with no containing partition. This makes it incompatible with the use of CONSOLE_INT13, since there is no way to add a dedicated log partition without a partition table. Add a partition table when building a non-ISO image, using the mbr.bin provided by syslinux (since we are already using syslinux to invoke the ipxe.lkrn within the FAT filesystem). The BIOS .usb targets are built using a manually constructed partition table with C/H/S geometry x/64/32. Match this geometry to minimise the differences between genfsimg and non-genfsimg USB disk images. Signed-off-by: Michael Brown --- diff --git a/src/util/genfsimg b/src/util/genfsimg index 84deea42b..9187f63f0 100755 --- a/src/util/genfsimg +++ b/src/util/genfsimg @@ -97,15 +97,13 @@ efi_boot_arch() { esac } -# Copy syslinux file +# Find syslinux file # -copy_syslinux_file() { +find_syslinux_file() { local FILENAME - local DESTDIR local SRCDIR FILENAME="${1}" - DESTDIR="${2}" for SRCDIR in \ /usr/lib/syslinux \ @@ -122,7 +120,7 @@ copy_syslinux_file() { /usr/lib/ISOLINUX \ ; do if [ -e "${SRCDIR}/${FILENAME}" ] ; then - install -m 644 "${SRCDIR}/${FILENAME}" "${DESTDIR}/" + echo "${SRCDIR}/${FILENAME}" return 0 fi done @@ -130,6 +128,20 @@ copy_syslinux_file() { return 1 } +# Copy syslinux file +# +copy_syslinux_file() { + local FILENAME + local DESTDIR + local SRCFILE + + FILENAME="${1}" + DESTDIR="${2}" + + SRCFILE=$(find_syslinux_file "${FILENAME}") + install -m 644 "${SRCFILE}" "${DESTDIR}/" +} + # Parse command-line options # OUTFILE= @@ -190,6 +202,7 @@ fi WORKDIR=$(mktemp -d "${OUTFILE}.XXXXXX") ISODIR="${WORKDIR}/iso" FATDIR="${WORKDIR}/fat" +MTOOLSRC="${WORKDIR}/mtoolsrc" mkdir -p "${ISODIR}" "${FATDIR}" # Configure output @@ -200,15 +213,33 @@ case "${OUTFILE}" in FATIMG="${ISODIR}/esp.img" BIOSDIR="${ISODIR}" SYSLINUXCFG="${ISODIR}/isolinux.cfg" + FATPART= + ;; + *.sdsk) + ISOIMG= + FATIMG="${OUTFILE}" + BIOSDIR="${FATDIR}" + SYSLINUXCFG="${FATDIR}/syslinux.cfg" + FATPART= ;; *) ISOIMG= FATIMG="${OUTFILE}" BIOSDIR="${FATDIR}" SYSLINUXCFG="${FATDIR}/syslinux.cfg" + FATPART="4" ;; esac +# Configure mtools +# +cat >"${MTOOLSRC}" <