Skip to content

Commit

Permalink
allow to build ISO image with EFI support (ipxe.eiso)
Browse files Browse the repository at this point in the history
  • Loading branch information
eworm-de committed May 8, 2016
1 parent 17c6f32 commit 189652b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/arch/x86/Makefile.pcbios
Expand Up @@ -86,6 +86,12 @@ NON_AUTO_MEDIA += iso
$(Q)ISOLINUX_BIN=$(ISOLINUX_BIN) LDLINUX_C32=$(LDLINUX_C32) \
VERSION="$(VERSION)" bash util/geniso -o $@ $<

# rule to make a non-emulation ISO boot image with EFI support
NON_AUTO_MEDIA += eiso
%eiso: %lkrn bin-i386-efi/ipxe.efi bin-x86_64-efi/ipxe.efi util/geniso
$(QM)$(ECHO) " [GENISO] $@"
$(Q)ISOLINUX_BIN=$(ISOLINUX_BIN) VERSION="$(VERSION)" bash util/geniso -e -o $@ $<

# rule to make a floppy emulation ISO boot image
NON_AUTO_MEDIA += liso
%liso: %lkrn util/geniso
Expand Down
52 changes: 40 additions & 12 deletions src/util/geniso
Expand Up @@ -6,16 +6,21 @@ function help() {
echo "usage: ${0} [OPTIONS] foo.lkrn [bar.lkrn,...]"
echo
echo "where OPTIONS are:"
echo " -e build image with EFI support"
echo " -h show this help"
echo " -l build legacy image with floppy emulation"
echo " -o FILE save iso image to file"
}

EFI=0
LEGACY=0
FIRST=""

while getopts "hlo:" opt; do
while getopts "ehlo:" opt; do
case ${opt} in
e)
EFI=1
;;
h)
help
exit 0
Expand All @@ -37,17 +42,25 @@ if [ -z "${OUT}" ]; then
exit 1
fi

# There should either be mkisofs or the compatible genisoimage program
for command in genisoimage mkisofs; do
if ${command} --version >/dev/null 2>/dev/null; then
mkisofs=(${command})
break
fi
done

if [ -z "${mkisofs}" ]; then
echo "${0}: mkisofs or genisoimage not found, please install or set PATH" >&2
# We need xorriso (from libisoburn) for EFI support, so try that first.
if xorriso --version >/dev/null 2>/dev/null; then
mkisofs=(xorriso -as mkisofs)
elif [ ${EFI} -eq 1 ]; then
echo "${0}: xorriso not found, but required for EFI support. Please install." >&2
exit 1
else
# fall back to mkisofs or the compatible genisoimage program
for command in genisoimage mkisofs; do
if ${command} --version >/dev/null 2>/dev/null; then
mkisofs=(${command})
break
fi
done

if [ -z "${mkisofs}" ]; then
echo "${0}: mkisofs or genisoimage not found, please install or set PATH" >&2
exit 1
fi
fi

dir=$(mktemp -d bin/iso.dir.XXXXXX)
Expand Down Expand Up @@ -122,13 +135,28 @@ case "${LEGACY}" in
# copy isolinux bootloader
cp ${ISOLINUX_BIN} ${dir}

mkisofs+=(-b isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table)

if [ "${EFI}" -eq 1 ]; then
# generate EFI image
img=${dir}/efiboot.img

mformat -f 2880 -C -i ${img} ::
mmd -i ${img} "::/EFI"
mmd -i ${img} "::/EFI/BOOT"
mcopy -m -i ${img} bin-x86_64-efi/ipxe.efi "::EFI/BOOT/BOOTX64.EFI"
mcopy -m -i ${img} bin-i386-efi/ipxe.efi "::EFI/BOOT/BOOTIA32.EFI"

mkisofs+=(-eltorito-alt-boot -e efiboot.img -isohybrid-gpt-basdat -no-emul-boot)
fi

# syslinux 6.x needs a file called ldlinux.c32
if [ -n "${LDLINUX_C32}" -a -s "${LDLINUX_C32}" ]; then
cp ${LDLINUX_C32} ${dir}
fi

# generate the iso image
"${mkisofs[@]}" -b isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -output ${OUT} ${dir}
"${mkisofs[@]}" -output ${OUT} ${dir}

# isohybrid will be used if available
if isohybrid --version >/dev/null 2>/dev/null; then
Expand Down

1 comment on commit 189652b

@darmach
Copy link

@darmach darmach commented on 189652b Feb 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am having some problems, while generating eiso itself works quite fine - eiso is efi bootable I don't seem to be able to embed ipxe configuration file.

I tried to build it with according to this post of yours so I did:

 2461  01/02/18 15:01:22 make all && make bin-i386-efi/ipxe.efi bin-x86_64-efi/ipxe.efi && make bin/ipxe.eiso EMBED=custom-boot.ipxe

My custom-boot.ipxe looks like follows:

#!ipxe
set net0/ip 10.180.255.155
set net0/netmask 255.255.255.192
set net0/gateway 10.180.255.129
ifopen net0
menu
item --gap -- ---------------- iPXE boot menu ----------------
item netboot    Boot from http
item shell      Shell
choose --default netboot --timeout 30000 target && goto ${target}

:netboot
kernel http://10.180.255.161/esx/mboot.c32 -c http://10.180.255.161/esx/boot.cfg
boot

:sanboot
sanboot http://10.180.255.161/esxsoft321.vmware.cosng.net.iso ||
echo failed to load iso
goto MENU

:shell
shell ||
goto MENU

iPXE boots, but instead of configuring static address tries to DHCP all of the network interfaces.
Maybe I'm embedding this file wrong?

EDIT: I think it did work after embedding like follows:

2482  01/02/18 15:21:33 make all EMBED=custom-boot.ipxe
 2483  01/02/18 15:22:28 make bin-i386-efi/ipxe.efi bin-x86_64-efi/ipxe.efi EMBED=custom-boot.ipxe
 2484  01/02/18 15:22:59 make bin/ipxe.eiso EMBED=custom-boot.ipxe

Please sign in to comment.