PXE boot Debian installer with firmwares

This article is mostly a reminder for me but might be useful to others.

1. Install/prepare TFTP server

First we need a tftp server (with symlink support is better) and a network bootloader (pxelinux)

apt install tftpd syslinux-common pxelinux

Then will link the minimum files required to display a text menu for our PXE entries

ln -s /usr/lib/PXELINUX/pxelinux.0                /srv/tftp/
ln -s /usr/lib/syslinux/modules/bios/ldlinux.c32  /srv/tftp/
ln -s /usr/lib/syslinux/modules/bios/libutil.c32  /srv/tftp/
ln -s /usr/lib/syslinux/modules/bios/menu.c32     /srv/tftp/

And a default menu booting normally after a 5 seconds timeout

mkdir /srv/tftp/pxelinux.cfg

cat << 'EOF' > /srv/tftp/pxelinux.cfg/default
DEFAULT menu.c32

LABEL Normal boot
LOCALBOOT 0

PROMPT 0
TIMEOUT 50
EOF

Additional keymaps

For luxembourgish, swiss people or whoever may use different keyboard layouts, will add ability to select a keymap (in case you want to edit an existing boot entry):

We need lilo here because it includes a (broken) tool to create syslinux compatible keymaps.

apt install kbd console-data lilo

Patch the broken keytab-lilo tool using the following diff (found at https://bugzilla.syslinux.org/show_bug.cgi?id=68)

--- orig	2016-07-15 22:14:28.000000000 +0200
+++ new		2018-01-12 21:37:16.349203039 +0100
@@ -44,9 +44,9 @@
     $empty = 1;
     while () {
 	chop;
-	if (/^(static\s+)?u_short\s+(\S+)_map\[\S*\]\s+=\s+{\s*$/) {
+	if (/^(static\s+)?(u_|unsigned )short\s+(\S+)_map\[\S*\]\s+=\s+{\s*$/) {
 	    die "active at beginning of  map" if defined $current;
-	    $current = $pfx.":".$2;
+	    $current = $pfx.":".$3;
 	    next;
 	}
 	undef $current if /^};\s*$/;
EOF

Create the keymap you want (french azerty here and swiss qwertz with french variant).
For then french azerty I found a few additional remaping here: https://forums.archlinux.fr/viewtopic.php?t=11953

mkdir /srv/tftp/keymaps
keytab-lilo -p 60=46 -p 92=60 -p 124=62 \
            /usr/share/keymaps/i386/qwerty/us.kmap.gz \
            /usr/share/keymaps/i386/azerty/fr-latin1.kmap.gz \
            > /srv/tftp/keymaps/fr.ktl
keytab-lilo /usr/share/keymaps/i386/qwerty/us.kmap.gz \
            /usr/share/keymaps/i386/qwertz/fr_CH-latin1.kmap.gz \
            > /srv/tftp/keymaps/fr-ch.ktl

Uninstall lilo:

apt purge lilo

And add entry in the menu to select an alternative keymap

ln -s /usr/lib/syslinux/modules/bios/kbdmap.c32  /srv/tftp/
ln -s /usr/lib/syslinux/modules/bios/libcom32.c32  /srv/tftp/
cat << 'EOF' >> /srv/tftp/pxelinux.cfg/default

LABEL Switch to french AZERTY
KERNEL kbdmap.c32
APPEND keymaps/fr.ktl

LABEL Switch to swiss french QWERTZ
KERNEL kbdmap.c32
APPEND keymaps/fr-ch.ktl
EOF

Debian installer with non-free firmware

Extract kernel and initrd from the Debian netboot archive:

mkdir /srv/tftp/debian-stretch-amd64-netinstall
wget -q -O- http://ftp.fr.debian.org/debian/dists/stretch/main/installer-amd64/current/images/netboot/netboot.tar.gz \
  | tar xvz -C /srv/tftp/debian-stretch-amd64-netinstall/ \
            ./debian-installer/amd64/initrd.gz \
            ./debian-installer/amd64/linux \
            --strip-components=3

Download firmware file and append to original initrd:

wget -q -O /srv/tftp/debian-stretch-amd64-netinstall/firmware.cpio.gz \
  http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stretch/current/firmware.cpio.gz

cat /srv/tftp/debian-stretch-amd64-netinstall/initrd.gz \
    /srv/tftp/debian-stretch-amd64-netinstall/firmware.cpio.gz \
    > /srv/tftp/debian-stretch-amd64-netinstall/initrd_firmware.gz

And add it to the boot menu:

cat << 'EOF' >> /srv/tftp/pxelinux.cfg/default

LABEL Debian Stretch NetInstall (firmware) amd64
KERNEL debian-stretch-amd64-netinstall/linux
APPEND initrd=debian-stretch-amd64-netinstall/initrd_firmware.gz
EOF

Leave a Reply

Your email address will not be published. Required fields are marked *