Compiling pxelinux and memdisk on FreeBSD

Posted by: admin  :  Category: FreeBSD

Building pxelinux and memdisk on FreeBSD is not as straight forward as on Linux. A fair amount of additional handwork is involved.

But don’t worry, all steps required to master this task are outlined below.

The requirement to build pxelinux came while implementing a FreeBSD-hosted network bootstrap environment, where I wanted to use it as primary boot loader.

Of course I could have taken pxelinux from an existing Linux distro’s binary package. I couldn’t resist the challenge however…

#1 Prerequisites

These prerequisite tools need to be installed first: nasm and gmake

It’s easiest you install them from the ports:

#cd /usr/ports/devel/gmake
#make clean build install && make clean
#cd /usr/ports/devel/nasm
#make clean build install && make clean

#2 Get the source

Since pxelinux and memdisk are part of syslinux, you need to fetch a current syslinux release tarball to a temporary directory and extract it.

#cd /tmp
#wget http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.36.tar.bz2
#tar -xjpvf syslinux-3.36.tar.bz2

#3 Apply source code patch

Now you could run ‘gmake’ within the source directory, this would however yield a linker error.
Let’s fix this first.

#cd syslinux-3.36
#find . -type f -exec grep -le ‘elf_i386’ {} \; | xargs perl -i -p -e ‘s/elf_i386/elf_i386_fbsd/g;’

#4 Building pxelinux and memdisk

Now let’s head on to building pxelinux and memdisk, the two components needed in particular.

#gmake pxelinux.bin
#cd memdisk; gmake; cd ..

They should compile cleanly so the next step would be copying them to your tftpd boot directory, which is /var/tftpd for me.

#cp pxelinux.bin /var/tftpd/pxelinux
#cp memdisk/memdisk /var/tftpd/memdisk

#5 Conclusion

pxelinux and memdisk can now be used in a pxe bootstrap environment (see also Convert FreeBSD ISO image for PXE bootstrap).

There still remain some compile time issues with syslinux itself. This is why running ‘gmake’ within the source directory yet fails due to unresolved include file dependencies.

I didn’t tamper with them because I was only interested in getting pxelinux and memdisk to run in the first place. Also I coulnd’t think of a practical reason in using syslinux on FreeBSD so I spared me these efforts.

Comments are closed.