Skip to content

Commit

Permalink
PoC RFC Generate (i)PXE files in create-iso for amd64 and friends
Browse files Browse the repository at this point in the history
Copy out needed files from iso to perform iPXE boot from gentoo mirrors
Provided as PoC of what is needed for this to be vaild
If merged this would resolve NiKiZe/Gentoo-iPXE#2
There is an alternative aproch to extract and generate these files during upload instead
Really want to have this in the same target as minimal livecd

To test result with qemu localy after build (replace your variables):
qemu-system-x86_64 -enable-kvm -M q35 -m 1024 -cpu host -nic user,model=virtio,\
tftp="${BUILD_SRCDIR_BASE}"/builds/default,\
bootfile=install-amd64-minimal-${TIMESTAMP}.ipxe \
-watchdog i6300esb -watchdog-action reset -boot menu=on -usb

Signed-off-by: Christian Nilsson <[email protected]>
  • Loading branch information
NiKiZe committed Jul 28, 2021
1 parent 6b23e58 commit 399cb88
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions targets/support/create-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,46 @@ case ${clst_hostarch} in
echo 'Creating ISO with fingers crossed that you know what you are doing...'
run_mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o "${1}" "${clst_target_path}"/
fi

# Use same kernel, initrd and squashfs to generate PXE bootable files
iso="${1}"
dstpath=${iso%%.iso}
dstname=$(basename ${dstpath})
kernel=${clst_boot_kernel}
for x in ${clst_boot_kernel}
do
kernel=${x}
done
echo "Copy kernel for use outside iso ${dstpath}.lkrn"
cp -vf "${clst_target_path}/boot/${kernel}" "${dstpath}.lkrn"
echo "Generate combined initrd + squashfs ${dstpath}.igz"
# change dir to get squashfs in current dir for correct cpio creation
pushd "${clst_target_path}"
# combine original initrd with squashfs
# different variants can be used, compression
# the selected combination here gives most responsive boot (avoids several seconds of black screen)
(cat "boot/${kernel}.igz" ; (echo image.${clst_fstype} | cpio -H newc -o)) > "${dstpath}.igz"
popd

# Generate kernel cmdline for use in iPXE script
if [ -z "${cmdline_opts}" ]
then
check_bootargs
check_filesystem_type
fi
default_append_line="root=/dev/ram0 init=/linuxrc ${cmdline_opts} ${custom_kopts} cdroot"
ipxename="${dstpath}.ipxe"
echo "Generating iPXE script ${ipxename}"
echo '#!ipxe' > ${ipxename}
echo '# allow for external keymap setting' >> ${ipxename}
echo 'isset ${keymap} || set keymap dokeymap' >> ${ipxename}
echo '# allow for external cmdline options' >> ${ipxename}
echo 'isset ${cmdline} || set cmdline vga=791' >> ${ipxename}
# initrd= on cmdline is needed for efi
echo "kernel ${dstname}.lkrn ${default_append_line/dokeymap/\$\{keymap\}} initrd=${dstname}.igz \${cmdline}" >> ${ipxename}
echo "initrd ${dstname}.igz" >> ${ipxename}
echo 'imgstat' >> ${ipxename}
echo 'boot' >> ${ipxename}
;;
esac
exit $?

0 comments on commit 399cb88

Please sign in to comment.