diff --git a/config b/config index e1abbca..099d9e7 100644 --- a/config +++ b/config @@ -14,14 +14,6 @@ # default: /run/live/medium/boot/addons/memtest #MEMTEST_IMAGE_="" -# path to pxelinux boot message -# default: /run/live/medium/boot/isolinux/boot.msg -#PXE_BOOT_MSG_="" - -# path to pxelinux boot logo -# default: /run/live/medium/boot/isolinux/logo.16 -#PXE_BOOT_LOGO_="" - # should the terminalserver activate snat for the clients to his default gateway? # default: true #IPTABLES_SNAT_="" diff --git a/debian/TODO b/debian/TODO index ee1a611..2db558c 100644 --- a/debian/TODO +++ b/debian/TODO @@ -3,7 +3,6 @@ TODOs for grml-terminalserver * DON'T delete /var/lib/tftpdboot on a !grml-system * config vars to use external services (dhcp, tftp, nfs) - * make pxelinux configurable (to use another pxe-boot-manager) (MAYBE) * don't write to /etc/grml/terminalserver * don't recreate the config on every grml-terminalserver start * introduce a special config rewrite commando diff --git a/debian/control b/debian/control index 2937bc5..5e9ae37 100644 --- a/debian/control +++ b/debian/control @@ -21,13 +21,14 @@ Depends: dialog, dnsmasq-base | isc-dhcp-server, grml2usb, - grub-efi-amd64-signed | grub-efi-amd64-bin | grub-efi-arm64-signed | grub-efi-arm64-bin | pxelinux, + grub-efi-amd64-signed | grub-efi-amd64-bin | grub-efi-arm64-signed | grub-efi-arm64-bin, ipcalc, iptables, nfs-kernel-server, - pxelinux, - shim-signed:amd64 | shim-signed:arm64 | pxelinux, + shim-signed:amd64 | shim-signed:arm64, ${misc:Depends}, +Recommends: + grub-pc-bin, Description: terminalserver for grml to boot via PXE These packages provides all what's needed to boot grml over the network (PXE). An easy to use interface diff --git a/default_config b/default_config index 62da7f7..e714d53 100644 --- a/default_config +++ b/default_config @@ -15,15 +15,6 @@ else # no grml2usb but running from CD DATA_PATH_="$MOUNT_POINT_/boot" fi -# new grml2usb layout -if [ -d "$MOUNT_POINT_"/boot/syslinux ] ; then - ISOLIN_PATH_="$MOUNT_POINT_/boot/syslinux" - test -d $ISOLIN_PATH_ || ISOLIN_PATH_="$MOUNT_POINT_" -else # old layout - ISOLIN_PATH_="$DATA_PATH_/isolinux" - test -d $ISOLIN_PATH_ || ISOLIN_PATH_="$MOUNT_POINT_" -fi - # addons if [[ "$(find $MOUNT_POINT_ -maxdepth 3 -name memtest |head -n1)" != "" ]] ; then ADDONS_PATH_="$(dirname $(find $MOUNT_POINT_ -maxdepth 3 -name memtest |head -n1))" @@ -48,20 +39,6 @@ if [ ! -f "$MEMTEST_IMAGE_" ] ; then MEMTEST_IMAGE_=$(find /boot -name memtest*.bin | head -n1) fi -PXE_BOOT_MSG_="$ISOLIN_PATH_/boot.msg" -# grml2usb with grub doesn't provide boot.msg, so generate a default one -if ! [ -f "$PXE_BOOT_MSG_" ] ; then - PXE_BOOT_MSG_="$(mktemp)" - cat > $PXE_BOOT_MSG_ << EOF -17 logo.16 - -Some information and boot options available via keys F2 - F10. http://grml.org/ - -EOF -fi - -PXE_BOOT_LOGO_="$ISOLIN_PATH_/logo.16" - IPTABLES_SNAT_="true" # EOF diff --git a/grml-terminalserver b/grml-terminalserver index 824860e..0d2314b 100755 --- a/grml-terminalserver +++ b/grml-terminalserver @@ -229,21 +229,13 @@ function createTftpConf { removeTftpConf - execute "mkdir -p $TFTPD_DATA_DIR_/pxelinux.cfg" die - if [ -r /usr/lib/PXELINUX/pxelinux.0 ] ; then - execute "install -m 644 /usr/lib/PXELINUX/pxelinux.0 $TFTPD_DATA_DIR_" die - else # older versions of syslinux-common (<= 2:4.05+dfsg-6+deb7u1): - execute "install -m 644 /usr/lib/syslinux/pxelinux.0 $TFTPD_DATA_DIR_" die - fi if [ -d "$MOUNT_POINT_"/boot/release ] ; then cp -r "$MOUNT_POINT_"/boot/release "$TFTPD_DATA_DIR_" fi [ -f "$MEMTEST_IMAGE" ] && execute "install -m 644 $MEMTEST_IMAGE_ $TFTPD_DATA_DIR_/memtest" die - execute "install -m 644 $PXE_BOOT_MSG_ $TFTPD_DATA_DIR_" die - [ -f "$PXE_BOOT_LOGO_" ] && execute "install -m 644 $PXE_BOOT_LOGO_ $TFTPD_DATA_DIR_" die - # PXE / BIOS boot (pxelinux) - execute "source $TEMPLATE_CONFIG_DIR_/grub-pxelinux_config" die + # PXE / BIOS boot (GRUB) + execute "source $TEMPLATE_CONFIG_DIR_/grub-bios_config" die # PXE / EFI boot (GRUB) execute "source $TEMPLATE_CONFIG_DIR_/grub-shim_config" die @@ -422,17 +414,12 @@ isExistent $DEFAULT_CONFIG_ die # used config vars: # MOUNT_POINT_ # MEMTEST_IMAGE_ -# PXE_BOOT_MSG_ -# PXE_BOOT_LOGO_ if [[ $MEMTEST_IMAGE_ == "" ]]; then warn "MEMTEST_IMAGE_=\"$MEMTEST_IMAGE_\"" fi -if [[ $MOUNT_POINT_ == "" || \ - $PXE_BOOT_MSG_ == "" || $PXE_BOOT_MSG_ == "" ]]; then - warn "MOUNT_POINT_=\"$MOUNT_POINT_\" \ -PXE_BOOT_MSG_=\"$PXE_BOOT_MSG_\" -PXE_BOOT_LOGO_=\"$PXE_BOOT_LOGO_\"" +if [[ $MOUNT_POINT_ == "" ]]; then + warn "MOUNT_POINT_=\"$MOUNT_POINT_\"" die "Wrong configuration, please update $CONFIG_" fi diff --git a/templates/dhcpd_config b/templates/dhcpd_config index 68360ae..242dbe2 100644 --- a/templates/dhcpd_config +++ b/templates/dhcpd_config @@ -65,7 +65,7 @@ subnet $NETWORK_ netmask $NETMASK_ { } elsif option architecture-type = 00:0b { filename "bootaa64.efi"; } else { - filename "pxelinux.0"; + filename "grub/i386-pc/core.0"; } } } diff --git a/templates/dnsmasq_config b/templates/dnsmasq_config index 1bcae2b..a9fdbc8 100644 --- a/templates/dnsmasq_config +++ b/templates/dnsmasq_config @@ -64,7 +64,7 @@ dhcp-match=set:efi-aa64,option:client-arch,11 dhcp-boot=tag:efi-aa64,bootaa64.efi # BIOS/Legacy boot -dhcp-boot=pxelinux.0 +dhcp-boot=grub/i386-pc/core.0 no-resolv no-hosts diff --git a/templates/grub-bios_config b/templates/grub-bios_config new file mode 100644 index 0000000..e1ee88a --- /dev/null +++ b/templates/grub-bios_config @@ -0,0 +1,81 @@ +# the following variables are available in the template: +# +# $INTERFACE_ (interface for the terminalserver) +# $IP_ (ip for the terminalserver to bind) +# $NETMASK_ (network mask) +# $GW_ (gateway) +# $NAMESERVERS_ (nameservers for the nodes) +# $IPRANGE_FROM_ (user configured iprange, first ip) +# $IPRANGE_TO_ (user configured iprange, last ip) +# $NETWORK_ (first ip in this subnet) +# $OPTIONS_ (options for grml-terminalserver) +# $BOOT_ARGS_ (boot arguments for the nodes) +# +# NOTE: +# templates are shellscript fragments and will be sourced from the +# terminalserver +# +# GLOBAL_README_END + +if [ -e "$MOUNT_POINT_" ]; then + default_boot_args_="root=/dev/nfs rw nfsroot=$IP_:$MOUNT_POINT_ \ +noprompt noeject" +else + default_boot_args_="ramdisk_size=24000 root=/dev/ram0 rw \ +init=/etc/init nfsdir=$IP_:$MOUNT_POINT_ nodhcp noprompt noeject \ +apm=power-off nomce" +fi + +if ! [ -d /run/live/medium ] ; then + echo "Error: couldn't access /run/live/medium for executing grml2usb with it." >&2 + exit 2 +fi + +DEST_DIR=$(mktemp -d) +grml2usb --bootloader-only \ + --bootoptions="$default_boot_args_ $BOOT_ARGS_" \ + --remove-bootoption=nodhcp \ + /run/live/medium "$DEST_DIR" + +mv "$DEST_DIR"/boot/ "$TFTPD_DATA_DIR_" + +if [ -d "$DEST_DIR"/grub ] ; then + mkdir -p "$TFTPD_DATA_DIR_"/grub + cp -r "$DEST_DIR"/grub/. "$TFTPD_DATA_DIR_"/grub/ +fi + +# Copy initrd.img and vmlinuz from all directories which name begins +# with grml, e.g. grml-full and grml-small +# This way we can boot multiple ISOs. +# Try MULTIBOOT_PATH_ first; if that yields nothing also search the standard +# /run/live/medium/boot/ location directly (MULTIBOOT_PATH_ may fall back to +# MOUNT_POINT_ when the grml2usb release/ layout is absent on newer ISOs). +for filename in "${MULTIBOOT_PATH_}"/grml* "${MOUNT_POINT_}/boot"/grml* ; do + [ -d "$filename" ] || continue + dest_="${TFTPD_DATA_DIR_}/boot/$(basename "${filename}")" + [ -d "$dest_" ] && continue + cp -r "${filename}" "${TFTPD_DATA_DIR_}/boot/" +done + +# remove grub entries +rm -f "$TFTPD_DATA_DIR_/"addon_*grub*.cfg + +rm -rf "$DEST_DIR" + +# BIOS/Legacy GRUB netboot setup +if [ -d /usr/lib/grub/i386-pc ] ; then + if ! command -v grub-mknetdir >/dev/null 2>&1 ; then + echo "WARN: grub-pc-bin not found, cannot set up GRUB BIOS boot." + let ret_=$ret_+1 + else + if [ -r "${TFTPD_DATA_DIR_}/grub/i386-pc/core.0" ] ; then + echo "${TFTPD_DATA_DIR_}/grub/i386-pc/core.0 exists already, nothing to do." + else + echo "Generating GRUB i386-pc netboot image for BIOS PXE boot" + grub-mknetdir --net-directory="${TFTPD_DATA_DIR_}" --subdir=grub + fi + fi +fi + +let ret_=$ret_+$? +return $ret_ diff --git a/templates/grub-pxelinux_config b/templates/grub-pxelinux_config deleted file mode 100644 index 8360ac3..0000000 --- a/templates/grub-pxelinux_config +++ /dev/null @@ -1,121 +0,0 @@ -# the following variables are available in the template: -# -# $INTERFACE_ (interface for the terminalserver) -# $IP_ (ip for the terminalserver to bind) -# $NETMASK_ (network mask) -# $GW_ (gateway) -# $NAMESERVERS_ (nameservers for the nodes) -# $IPRANGE_FROM_ (user configured iprange, first ip) -# $IPRANGE_TO_ (user configured iprange, last ip) -# $NETWORK_ (first ip in this subnet) -# $OPTIONS_ (options for grml-terminalserver) -# $BOOT_ARGS_ (boot arguments for the nodes) -# -# NOTE: -# templates are shellscript fragments and will be sourced from the -# terminalserver -# -# GLOBAL_README_END - -# default boot arguments used for both grub and pxelinux -if [ -e "$MOUNT_POINT_" ]; then - default_boot_args_="root=/dev/nfs rw nfsroot=$IP_:$MOUNT_POINT_ \ -noprompt noeject" -else - default_boot_args_="ramdisk_size=24000 root=/dev/ram0 rw \ -init=/etc/init nfsdir=$IP_:$MOUNT_POINT_ nodhcp noprompt noeject \ -apm=power-off nomce" -fi - -# special boot arguments required by pxelinux -pxe_def_boot_args_="$default_boot_args_" - -### -## create pxelinux config -### -DEST_DIR=$(mktemp -d) -if [ -d /run/live/medium ] ; then # since December 2018 - grml2usb --bootloader-only \ - --bootoptions="$pxe_def_boot_args_ $BOOT_ARGS_" \ - --remove-bootoption=nodhcp \ - /run/live/medium "$DEST_DIR" - - mv "$DEST_DIR"/boot/syslinux/* "$TFTPD_DATA_DIR_/" - rmdir "$DEST_DIR"/boot/syslinux - - mv "$DEST_DIR"/boot/ "$TFTPD_DATA_DIR_" -elif [ -d /lib/live/mount/medium ] ; then - grml2usb --bootloader-only \ - --bootoptions="$pxe_def_boot_args_ $BOOT_ARGS_" \ - --remove-bootoption=nodhcp \ - /lib/live/mount/medium "$DEST_DIR" - - mv "$DEST_DIR"/boot/syslinux/* "$TFTPD_DATA_DIR_/" - rmdir "$DEST_DIR"/boot/syslinux - - mv "$DEST_DIR"/boot/ "$TFTPD_DATA_DIR_" -else - if [ ! -d /usr/share/grml-live/templates/boot/isolinux ] ; then - echo "E: Could not find isolinux directory, can not operate without. - -Did you boot the system with the toram=... boot option? If so please -either do not use the toram boot option at all or use boot option toram -without any arguments (just \"toram\" instead of \"toram=...\")." >&2 - exit 2 - fi - - array=( $(cat /etc/grml_version) ) - grml_name_=${array[0]} - grml_version_=${array[1]} - - cp /usr/share/grml-live/templates/boot/isolinux/* "$TFTPD_DATA_DIR_/" - - config_files_=$(find "$TFTPD_DATA_DIR_/" -name "*.cfg" -type f) - sed -i "s/%ARCH%/$(uname -m)/" $config_files_ - sed -i "s/%BOOTID%/$RANDOM/" $config_files_ - sed -i "s/%SHORT_NAME%/dummy/" $config_files_ - sed -i "s/%VERSION%/$grml_version_/" $config_files_ - sed -i "s/%GRML_NAME%/$grml_name_/" $config_files_ - sed -i "s/%DISTRI_SPLASH%/grml.png/" $config_files_ - sed -i "s/%DISTRI_INFO%/Grml/" $config_files_ - sed -i "s#\(^.*append.*initrd.*$\)#\1 $pxe_def_boot_args_ $BOOT_ARGS_#" $config_files_ - cat > "$TFTPD_DATA_DIR_/grmlmain.cfg"</dev/null 2>&1; then - sed -i -e 's#\(.*kernel .*/ldbsd.com\)#\1 set image /boot/addons/bsd4grml/bsd.rd`echo Type "boot" to load MirOS bsd4grml via keeppxe#' "$TFTPD_DATA_DIR_/"addon_*_bsd.cfg -fi - -# remove grub entries -rm -f "$TFTPD_DATA_DIR_/"addon_*grub*.cfg - -mv "$TFTPD_DATA_DIR_/syslinux.cfg" "$TFTPD_DATA_DIR_/pxelinux.cfg/default" -rm -rf "$DEST_DIR" - -let ret_=$ret_+$? -return $ret_ diff --git a/templates/grub-shim_config b/templates/grub-shim_config index e176401..79f34de 100644 --- a/templates/grub-shim_config +++ b/templates/grub-shim_config @@ -18,6 +18,7 @@ # GLOBAL_README_END if [ "$(uname -m)" = "x86_64" ]; then + # 64-bit UEFI (grubx64.efi / bootx64.efi) if [ -r "${TFTPD_DATA_DIR_}"/grubx64.efi ] ; then echo "${TFTPD_DATA_DIR_}/grubx64.efi exists already, nothing to do." elif [ -r /usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed ] ; then @@ -44,6 +45,21 @@ if [ "$(uname -m)" = "x86_64" ]; then echo "WARN: No shimx64.efi for usage with PXE boot found. Using GRUB directly as bootx64.efi." cp "${TFTPD_DATA_DIR_}"/grubx64.efi "${TFTPD_DATA_DIR_}"/bootx64.efi fi + + # 32-bit UEFI (grubia32.efi) + # targets 32-bit firmware on 64-bit CPU hardware + if [ -r "${TFTPD_DATA_DIR_}"/grubia32.efi ] ; then + echo "${TFTPD_DATA_DIR_}/grubia32.efi exists already, nothing to do." + elif [ -r /usr/lib/grub/i386-efi-signed/grubnetia32.efi.signed ] ; then + echo "Installing /usr/lib/grub/i386-efi-signed/grubnetia32.efi.signed as grubia32.efi for TFTP usage" + cp /usr/lib/grub/i386-efi-signed/grubnetia32.efi.signed "${TFTPD_DATA_DIR_}"/grubia32.efi + elif [ -r /usr/lib/grub/i386-efi/monolithic/grubnetia32.efi ] ; then + echo "Installing /usr/lib/grub/i386-efi/monolithic/grubnetia32.efi as grubia32.efi for TFTP usage" + cp /usr/lib/grub/i386-efi/monolithic/grubnetia32.efi "${TFTPD_DATA_DIR_}"/grubia32.efi + else + echo "WARN: No grubnetia32.efi for usage with PXE boot found, not setting up 32-bit UEFI boot via GRUB." + (( ret_=ret_+ $? )) + fi fi if [ "$(uname -m)" = "aarch64" ]; then if [ -r "${TFTPD_DATA_DIR_}"/grubaa64.efi ] ; then @@ -84,46 +100,43 @@ else echo "WARN: No unicode.pf2 for usage with PXE boot found." fi -echo "Setting up GRUB configuration for PXE/UEFI usage" +echo "Setting up GRUB configuration for PXE/EFI/BIOS usage" mkdir -p "${TFTPD_DATA_DIR_}/grub/" -cat > "${TFTPD_DATA_DIR_}/grub/grub.cfg" << EOT +cat > "${TFTPD_DATA_DIR_}/grub/grub.cfg" << "EOT" # GRUB PXE configuration file -# adjust according to your needs -#set timeout=300 - -insmod png -set gfxmode=auto -insmod gfxterm -terminal_output gfxterm - -loadfont unicode - -set menu_color_normal=white/black -set menu_color_highlight=black/yellow - -# this needs some tuning, so not enabled by default -# set theme=/boot/grub/grml-theme/theme.txt -# export theme +source "${prefix}/header.cfg" EOT -# theme support requires e.g. icons/submenu.png within the theme directory, -# which we don't ship though, so not enabled by default -#mkdir -p "${TFTPD_DATA_DIR_}"/grub/themes/boot/grub -#ln -s "${TFTPD_DATA_DIR_}"/boot/grub/grml-theme "${TFTPD_DATA_DIR_}"/grub/themes/boot/grub/ - -for file in "${TFTPD_DATA_DIR_}"/boot/grub/*_default.cfg "${TFTPD_DATA_DIR_}"/boot/grub/*_options.cfg ; do +# NOTE: GRUB in netboot doesn't support sourcing files with regexp, so we need to prepare this statically +for file in "${TFTPD_DATA_DIR_}"/grub/*_default.cfg "${TFTPD_DATA_DIR_}"/grub/*_options.cfg ; do + [ -f "$file" ] || continue filename="$(basename "${file}")" - echo "source boot/grub/${filename}" >> "${TFTPD_DATA_DIR_}/grub/grub.cfg" + echo "source \${prefix}/${filename}" >> "${TFTPD_DATA_DIR_}/grub/grub.cfg" done -cat >> "${TFTPD_DATA_DIR_}/grub/grub.cfg" << EOT +cat >> "${TFTPD_DATA_DIR_}/grub/grub.cfg" << "EOT" +# separator entry, no action +menuentry "" { + true +} + +source "${prefix}/help.cfg" + +if [ "${grub_platform}" == "efi" ] ; then +menuentry "UEFI Firmware Settings" { + fwsetup +} +fi # efi mode menuentry "Boot OS of first partition on first disk" { set root=(hd0,1) chainloader +1 } + +source "${prefix}/footer.cfg" +# EOF EOT (( ret_=ret_+ $? ))