Warning: session_start(): open(/tmp/sess_e01df484eb1e379c285e0e5d7091ecd4, O_RDWR) failed: No space left on device (28) in /var/www/html/inc/init.php on line 265

Warning: session_start(): Failed to read session data: files (path: ) in /var/www/html/inc/init.php on line 265

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/inc/init.php:265) in /var/www/html/inc/auth.php on line 432

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/inc/init.php:265) in /var/www/html/inc/actions.php on line 38
raspberry_pi_pxe_server [Ben's notes]

Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


Raspberry Pi - PXE server

I was in need of a simple small PXE server (DHCP and TFTP). PXE server on ethernet, management via wifi.


  • Old first gen. RPI.
  • SDCard, large enough to host images / files.
  • Wifi dongle (for management).
  • Most of the commands below need to be run as root.

Raspbian install

  • Download latest Raspbian Lite (Stretch)
  • Validate download:
    # From website:
    sha256sum 2017-11-29-raspbian-stretch-lite.zip 
    e942b70072f2e83c446b9de6f202eb8f9692c06e7d92c343361340cc016e0c9f  2017-11-29-raspbian-stretch-lite.zip
  • Check if partitions already have been mounted and unmount those.
    lsblk # or mount command
    umount /dev/sdX{1,2}
  • Copy image to SDCard:
    unzip 2017-11-29-raspbian-stretch-lite.zip
    dd if=2017-11-29-raspbian-stretch-lite.img of=/dev/sdX bs=1M && sync
  • Mount partitions (unmount first if auto-mounted under /run/media/…):
    mount /dev/sdX2 /mnt
    mount /dev/sdX1 /mnt/boot
  • Enable SSH:
    touch /mnt/boot/ssh
  • Generate wifi config:
    wpa_passphrase YOUR_SSID YOUR_PASSPHRASE >> /mnt/etc/wpa_supplicant/wpa_supplicant.conf
    # Remove the plaintext passphrase, change country
    vi /mnt/etc/wpa_supplicant/wpa_supplicant.conf
  • Set hostname:
    echo pxe >/mnt/etc/hostname
  • unmount partitions

RPI configuration

  • Boot the RPI with the above prepared SDcard.
  • If everything went well, it will connect to your wifi network.
  • Log in, using SSH, with username and password:pi:raspberry.
    ssh pi@pxe
  • Change user pi password. Or create a new account and delete the pi user.
  • Update the OS:
    sudo su -
    apt-get update
    apt-get upgrade
  • Configure the RPI:
    - Boot options: console
    - Locale
    - Timezone
    - Expand filesystem
  • Reboot
  • Check for new firmware:
  • Install and configure uncomplicated firewall
    apt-get install ufw
    ufw allow ssh
    ufw allow in on eth0 from any port 68 to any port 67 proto udp
    ufw allow in on eth0 from any to any proto udp port 69
    ufw default deny
    ufw enable
    modprobe nf_conntrack_tftp # temporary, line below is for loading at boot
    echo "nf_conntrack_tftp" >> /etc/modules-load.d/modules.conf
  • Disable unnecessary services:
    systemctl disable avahi-daemon --now

PXE server

  • Configure static IP address on network interface:
    cat >> /etc/dhcpcd.conf <<EOF
    interface eth0
    static ip_address=
    systemctl daemon-reload
    systemctl restart dhcpcd
  • Install packages:
    apt-get install dnsmasq syslinux-common pxelinux
  • Configure dnsmasq:
    cat > /etc/dnsmasq.d/server.conf <<EOF
    # For BIOS based systems
    mkdir /var/lib/tftp
    systemctl restart dnsmasq
    mkdir -p /var/lib/tftp/pxelinux.cfg
    ln -s /usr/lib/PXELINUX/pxelinux.0 /var/lib/tftp/
    ln -s /usr/lib/syslinux/modules/bios/ldlinux.c32 /var/lib/tftp/
    ln -s /usr/lib/syslinux/modules/bios/menu.c32 /var/lib/tftp/
    ln -s /usr/lib/syslinux/modules/bios/libutil.c32 /var/lib/tftp/

Memtest example (for serial console)

  • Memtest 5.01
    wget http://www.memtest.org/download/5.01/memtest86+-5.01.bin.gz
    gunzip memtest86+-5.01.bin.gz
    mkdir -p /var/lib/tftp/memtest
    cp memtest86+-5.01.bin /var/lib/tftp/memtest/memtest86+-5.01
    cat > /var/lib/tftp/pxelinux.cfg/default <<EOF
    console 0
    serial 0 115200 0
    default memtest86
    prompt 1
    timeout 15
    label memtest86
      menu label Memtest86+ 5.01
      kernel /memtest/memtest86+-5.01 console=ttyS0,115200
    systemctl restart dnsmasq

Voyage Linux example

  • Download voyage-0.11.0_amd64.iso.
  • Prepare Voyage Linux 0.11 config:
    mkdir /var/lib/tftp/voyage0.11
    mount -o loop voyage-0.11.0_amd64.iso /mnt
    cp /mnt/live/initrd.img /var/lib/tftp/voyage0.11/
    cp /mnt/live/vmlinuz /var/lib/tftp/voyage0.11/
    cp /mnt/live/filesystem.squashfs /var/lib/tftp/voyage0.11/
    cat > /var/lib/tftp/pxelinux.cfg/default <<EOF
    serial 0 115200 0
    console 0
    default menu.c32
    prompt 15
    TIMEOUT 30
    LABEL Voyage64bit
        MENU LABEL Voyage Linux 0.11 64 bit
        KERNEL /voyage0.11/vmlinuz
        APPEND initrd=/voyage0.11/initrd.img boot=live fetch=tftp:// live-getty noautologin console=ttyS0,115200
    LABEL Voyage32bit
        MENU LABEL Voyage Linux 0.11 32 bit
        KERNEL /voyage0.11-32bit/vmlinuz
        APPEND initrd=/voyage0.11-32bit/initrd.img boot=live fetch=tftp:// live-getty noautologin console=ttyS0,115200
  • Log in and install Voyage:
    ssh root@<dhcp-address> #pass = voyage
    /usr/local/sbin/format-cf.sh /dev/sdX
    mkdir /mnt/cf
    Configuration details:              
    Distribution directory:   /          
    Disk/Flash Device:        /dev/sda
    Installation Partition:   /dev/sda1                          
    Bootstrap Partition:      /dev/sda1
    Will be mounted on:       /mnt/cf                        
    Target system profile:    ALIX                        
    Target console:           serial
    Target baud rate:         115200
    Bootstrap installer:      grub
    Bootstrap partition:      /dev/sda1
    OK to continue (y/n)? y
raspberry_pi_pxe_server.txt · Last modified: 2021/10/09 15:14 by