-- MikeGore - 2018-06-28

DNSMASQ Multiarch PXE booting

Summary

  • This is a standalone version of the DNSMASQ PXE boot configuration process that removed all of the external configuration dependencies. We only focus on the dnsmasq configuration and syslinux installation

Ubuntu 16.04 packages

  • apt-get install zip unzip make build-essential binutils gcc-5 g++-5 dpkg-dev nasm autoconf automake make git vim liblzma-dev genisoimage syslinux ipcalc

Overview of software installation and setup

  1. ) Create a tftpboot root folder for network booting - example mkdir -p /tftpboot/pxes
  2. ) cd /tftpboot/pxes
  3. ) wget https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.04-pre1.tar.gz
  4. ) tar xzf syslinux-6.04-pre1.tar.gz
  5. ) cd syslinux-6.04-pre1
  6. ) Install as follows - note /usr/share/syslinux is the default install folder for the sources above.
             # Clean out any prior object files from a previous Make
             # This Directory may not have come from this host
             echo "running make clean - this will take a while..."
             make clean 1>"$0.clean.log" 2>"$0.clean.errors.log"
             echo Done clean
             echo ==================================
             
             if ! grep "__FIRMWARE_EFI64__" core/include/fs.h >/dev/null 2>&1
             then 
                echo "Adding #define __FIRMWARE_EFI64__ to core/include/fs.h"
                sed -i -e "s/^#define FS_H/a#define __FIRMWARE_EFI64__/" core/include/fs.h
             else
                echo "#define __FIRMWARE_EFI64__ alread exists in core/include/fs.h"
             fi
             
             echo "running make - this will take a while..."
             make install 1>"$0.log" 2>"$0.errors.log"
             echo "make done"
             echo ==================================
             
             echo "   For debugging you can look at the file"
             echo "      $VERSION/$0.log - for the make log"
             if [ -s "$VERSION/$0.errors.log" ]
             then 
             echo ==================================
                echo "Errors detected - see $VERSION/$0.errors.log"
                cat "$VERSION/$0.errors.log"
             echo ==================================
             else
                echo "No errors"
             fi
          
  7. ) replicate syslinux binaries into our PXE boot folder
    • rsync -a -x -H "/usr/share/syslinux/" /tftpboot/pxes/syslinux
  8. ) Update system pxelinux-options file with latest verion from our source tree
    • rsync -a -x -H utils/pxelinux-options /usr/bin
    • rsync -a -x -H utils/pxelinux-options /usr/local/bin
  9. ) Download example pxe configs configs.tgz and extract these under /tftpboot/pxes
  10. ) Copy dnsmasq.conf example into /etc/dnsmasq.conf
  11. ) Notes
    • A VERY import trick we use here is the ability of the pxelinux-options command to alter the requested config file from each boot loader.
      • These boot loader config files just set their unique PATH settings - and then can include a set of common config files.
        • Why ? So we do not have to have every config file replicated for every architecture - maintaining such a mess would be a nightmare.
        • This is the reason behind the "odd" symlinking and copying below
      • The loaders are "chosen" via the following /etc/dnsmasq.conf options * See dnsmasq.conf . Here are trhe key lines:
    • See files bios.cfg bootx64.efi efi32.cfg efi64.cfg These files set PATH then include the common pxelinux.cfg/main we also have a pxelinux.cfg/default for lagacy bios systems that may not work correctly via this method.
    • Config files: configplus.tgz or config.tgz
                  dhcp-boot=tag:x86PC,pxelinux.0
                  dhcp-match=set:X86-64_EFI,option:client-arch,6
                  dhcp-match=set:X86-64_EFI,option:client-arch,7
                  dhcp-match=set:X86-64_EFI,option:client-arch,9
                  dhcp-boot=tag:X86-64_EFI,syslinux64.efi
            
  12. ) Installing the multiarch dnsmasq config files and updating syslinux install tree to work with it.
           ======================================================
          # Make sure we have initial boot config files to populate the /tftpboot/pxes root folder
          # This refer to pxelinux.cfg folder optionally updated above
          echo =======================================
          echo "Verifying existance of bios.cfg efi32.cfg efi64.cfg in /tftpboot/pxes folder"
          for i in bios.cfg efi32.cfg efi64.cfg
          do
             if [ ! -f "/tftpboot/pxes/$i" ]
             then
                echo "creating /tftpboot/pxes/$i"
                rsync -a -x -H "pxe/$i" "/tftpboot/pxes/"
             else
                echo "have    /tftpboot/pxes/$i"
             fi
          done
          # ======================================================
    
          # ======================================================
          #  Make sure we have BIOS EFI64 and EFI32 boot loaders under the /tftpboot/pxes root folder
          echo "Update the PXE boot loaders and their respective config file under /tftpboot/pxes"
          echo
          # ======================================================
    
          # ======================================================
          #  BIOS PXE boot support
          echo =======================================
          echo "updating BIOS level boot loaders"
          # Remove old symlinks first
          rm -f "/tftpboot/pxes/bios"
          rm -f  "/tftpboot/pxes/syslinux/syslinux"
          # Notes: Special case: the syslinux folder is also the default bios folder with menu.c32 etc so just link it
          ln -sf "/tftpboot/pxes/syslinux"                            "/tftpboot/pxes/bios"
          # Notes: SYSLINUX already contains pxelinux.cfg folder - so no need to link here
          # We need syslinux inside bios so we link it intol itself
          # Adding this folder is not likely required - ends up linking to PXE/syslinux/syslinux - harmless
          ln -sf "/tftpboot/pxes/syslinux"                            "/tftpboot/pxes/syslinux/syslinux"
          cp -fp "/tftpboot/pxes/syslinux/pxelinux.0"                 "/tftpboot/pxes/pxelinux.0"
          cp -fp "/tftpboot/pxes/syslinux/lpxelinux.0"                "/tftpboot/pxes/lpxelinux.0"
          #  Patch pxelinux.0 with config file name
          echo "updating BIOS loader /tftpboot/pxes/pxelinux.0"
          pxelinux-options --after config-file "bios.cfg" "/tftpboot/pxes/pxelinux.0"
          # ======================================================
    
          # ======================================================
          #  64Bit EFI PXE boot support
          echo =======================================
          echo "updating EFI64 level boot loaders"
          rm -f  "/tftpboot/pxes/efi64"
          ln -sf "/tftpboot/pxes/syslinux/efi64/"                      "/tftpboot/pxes/efi64"
          ln -sf "/tftpboot/pxes/pxelinux.cfg"                     "/tftpboot/pxes/efi64/pxelinux.cfg"
          ln -sf "/tftpboot/pxes/syslinux/efi64/"                      "/tftpboot/pxes/efi64/syslinux"
          cp -fp "/tftpboot/pxes/syslinux/efi64/syslinux.efi"          "/tftpboot/pxes/syslinux64.efi"
          cp -fp "/tftpboot/pxes/syslinux/efi64/ldlinux.e64"           "/tftpboot/pxes/ldlinux.e64"
          #  Patch syslinux64.efi with config file name
          echo "updating EFI64 loader /tftpboot/pxes/esyslinux64.efi"
          pxelinux-options --after config-file "efi64.cfg" "/tftpboot/pxes/syslinux64.efi"
          # ======================================================
    
          # ======================================================
          #  32Bit EFI PXE boot support
          echo =======================================
          echo "updating EFI32level boot loaders"
          rm -f  "/tftpboot/pxes/efi32"
          ln -sf "/tftpboot/pxes/syslinux/efi32/"                      "/tftpboot/pxes/efi32"
          ln -sf "/tftpboot/pxes/pxelinux.cfg"                     "/tftpboot/pxes/efi32/pxelinux.cfg"
          ln -sf "/tftpboot/pxes/syslinux/efi32/"                      "/tftpboot/pxes/efi32/syslinux"
          cp -fp "/tftpboot/pxes/syslinux/efi32/syslinux.efi"          "/tftpboot/pxes/syslinux32.efi"
          cp -fp "/tftpboot/pxes/syslinux/efi32/ldlinux.e32"           "/tftpboot/pxes/ldlinux.e32"
          #  Patch syslinux32.efi with config file name
          echo "updating EFI32 loader /tftpboot/pxes/esyslinux32.efi"
          pxelinux-options --after config-file "efi32.cfg" "/tftpboot/pxes/syslinux32.efi"
          echo
          # ======================================================
          
  13. ) Testing the boot loader changes
          # ======================================================
          #  List each boot loder config file name to verify updates
          echo =======================================
          echo Listing patches to PXE boot loaders
          pxelinux-options --list                        "/tftpboot/pxes/pxelinux.0"
          pxelinux-options --list                        "/tftpboot/pxes/syslinux64.efi"
          pxelinux-options --list                        "/tftpboot/pxes/syslinux32.efi"
          # ======================================================
       

  • configplus.tgz: Expanded configuration files for Multiarch PXE boot envirponment from cs-tech1 included clonezilla and live menues
Topic attachments
I Attachment Action Size Date Who Comment
Compressed Zip archivetgz configplus.tgz manage 534.5 K 2018-06-28 - 13:32 MikeGore Expanded configuration files for Multiarch PXE boot envirponment from cs-tech1
Compressed Zip archivetgz configs.tgz manage 532.3 K 2018-06-28 - 10:39 MikeGore Example configuration files for Multiarch PXE boot envirponment
Unknown file formatconf dnsmasq.conf manage 2.2 K 2018-06-28 - 10:50 MikeGore example /etc/dnsmasq.conf file for dnsmasq
Topic revision: r3 - 2018-07-05 - LawrenceFolland
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback