Revision 2 of 2026-11-25 15:32 UTC by tux, the current one. Current version - History
PXE boot server
5.1
PXE lets a computer boot from the network, with no CD, USB key or even disk. A SliTaz machine on the same network hands it a boot loader, a kernel and the SliTaz system, and the client runs SliTaz in its RAM, like a live CD. Useful for a classroom, a rack of old PCs, or a machine whose drives are dead.
A PXE server does two jobs:
- DHCP: give the client an address, and tell it which file to load and from which server;
- TFTP: send that file, then the kernel and
rootfs.gz.
Here both run on one SliTaz machine. The client loads GRUB from the network, and GRUB loads SliTaz. The same files serve BIOS and UEFI clients.
What you need
- A SliTaz server with a fixed address on the network of the clients,
for example
192.168.0.10oneth0. See wired network in the Handbook. - The
grub2package: on x86_64 it brings the GRUB images for BIOS (i386-pc) and UEFI (x86_64-efi), with their network modules. The i486grub2has the BIOS images only. - A SliTaz ISO, to take the kernel and the system from.
- For the DHCP and TFTP servers: BusyBox (
udhcpd,tftpd,udpsvd), already there, or thednsmasqpackage.
Only one DHCP server per network. If your router already gives the addresses, turn its DHCP off, or put the server and the clients on their own network or switch.
The files to serve
All the files go in one directory, the TFTP root. Here /srv/tftp. As
root:
# spk-add grub2
# mkdir -p /srv/tftp
# grub-mknetdir --net-directory=/srv/tftp
grub-mknetdir writes the network boot images, each with its modules:
boot/grub/i386-pc/core.0for BIOS clients;boot/grub/x86_64-efi/core.efifor UEFI clients.
Both read the same menu, /srv/tftp/boot/grub/grub.cfg.
Then copy the kernel and the system from the ISO:
# mount -o loop,ro slitaz-core-x86_64-cooking.iso /media/cdrom
# mkdir /srv/tftp/slitaz
# cp /media/cdrom/boot/bzImage /media/cdrom/boot/rootfs.gz /srv/tftp/slitaz
# umount /media/cdrom
Each ISO has one boot/bzImage and one boot/rootfs.gz, on i486 and
x86_64 alike. The tftpd of BusyBox locks itself into its directory: copy
the files there, a link pointing outside does not work.
Write the menu, /srv/tftp/boot/grub/grub.cfg:
set timeout=5
insmod all_video
menuentry "SliTaz" {
linux /slitaz/bzImage rw root=/dev/null autologin
initrd /slitaz/rootfs.gz
}
Paths are read from the TFTP root. insmod all_video gives the kernel
a screen to draw on with UEFI clients. The kernel line takes the usual
boot options:
lang=fr_FR kmap=fr-latin1, screen=text and so on.
i486 and x86_64 side by side
A 64-bit UEFI client only runs the x86_64 system. A BIOS client can run
either. Copy the i486 files into /srv/tftp/slitaz32 and add a second
entry, shown to BIOS clients only:
if [ "$grub_platform" = pc ]; then
menuentry "SliTaz 32-bit" {
linux /slitaz32/bzImage rw root=/dev/null autologin
initrd /slitaz32/rootfs.gz
}
fi
DHCP and TFTP with dnsmasq
dnsmasq does both jobs in one program, and tells BIOS and UEFI clients apart. As root:
# spk-add dnsmasq
The package installs a long example as /etc/dnsmasq.conf. Keep it
aside and write your own:
# mv /etc/dnsmasq.conf /etc/dnsmasq.conf.example
/etc/dnsmasq.conf, for a network 192.168.0.0/24 with the router on
192.168.0.1:
interface=eth0
dhcp-range=192.168.0.100,192.168.0.150,12h
dhcp-option=option:router,192.168.0.1
dhcp-option=option:dns-server,192.168.0.1
enable-tftp
tftp-root=/srv/tftp
dhcp-match=set:efi64,option:client-arch,7
dhcp-match=set:efi64,option:client-arch,9
dhcp-boot=tag:!efi64,boot/grub/i386-pc/core.0
dhcp-boot=tag:efi64,boot/grub/x86_64-efi/core.efi
A UEFI client says it is one (client architecture 7 or 9) and gets
core.efi; the others get core.0. dnsmasq also answers DNS on the
server; port=0 turns that off. Check the file, then start it, and
start it at each boot:
# dnsmasq --test
# trame service start dnsmasq
# trame service enable dnsmasq
DHCP and TFTP with BusyBox
Nothing to install, but udhcpd gives the same file to every client:
choose core.0 for BIOS clients or core.efi for UEFI ones.
In /etc/udhcpd.conf, set the range, the router and DNS, then the two
boot lines (siaddr is the address of the TFTP server):
start 192.168.0.100
end 192.168.0.150
interface eth0
option subnet 255.255.255.0
option router 192.168.0.1
option dns 192.168.0.1
siaddr 192.168.0.10
boot_file boot/grub/i386-pc/core.0
Start it, and at each boot:
# trame service start udhcpd
# trame service enable udhcpd
The BusyBox tftpd does not listen by itself: udpsvd does, and runs
it for each request. Start it by hand:
# udpsvd -E 0.0.0.0 69 tftpd -r /srv/tftp &
-r refuses uploads. To start it at each boot, add that line to
/etc/init.d/local.sh.
The client
Turn on network boot in the firmware setup (often called PXE, LAN boot or Network stack on UEFI machines), then pick the network card in the boot menu, often with F12. The client gets its address, loads GRUB, shows the SliTaz menu and boots. Secure Boot must be off on UEFI clients: the GRUB images are not signed.
No PXE in the firmware? Boot a SliTaz ISO or USB key and choose
Web Boot in its menu. It starts iPXE (/boot/ipxe.exe), which asks
the network for an address, finds the boot file your server announces,
and boots it: the client then runs the SliTaz of your server.
Adding your own files
GRUB can load several archives after rootfs.gz. The kernel unpacks
them in order, and the last one wins. To give every client the same
settings without rebuilding the ISO, pack the files into a small
archive. For example a host name, as root on the server:
# mkdir -p /tmp/extra/etc
# echo classroom > /tmp/extra/etc/hostname
# cd /tmp/extra
# find etc | cpio -o -H newc | gzip -9 > /srv/tftp/slitaz/my-config.gz
and add it to the initrd line:
initrd /slitaz/rootfs.gz /slitaz/my-config.gz
The clients now boot as classroom. Run the commands as root, so the
files in the archive belong to root.
Test it in a virtual machine
QEMU has its own small DHCP and TFTP server: it can check the files and the menu before you touch the network. As a user, on the server:
$ qemu-system-x86_64 -m 1024 -boot n \
-netdev user,id=n0,tftp=/srv/tftp,bootfile=boot/grub/i386-pc/core.0 \
-device e1000,netdev=n0
Use bootfile=boot/grub/x86_64-efi/core.efi with a UEFI firmware
(OVMF) to test the UEFI side. See also the
virtual machine page.
Troubleshooting
The client finds no DHCP offer: check that the server is on the
same network, that the service runs (trame service status dnsmasq or
udhcpd), and that the firewall lets DHCP (UDP 67) and TFTP (UDP 69)
in, see the firewall.
"PXE-E32: TFTP open timeout", or the file is not found: the TFTP
server is not running, or the path is wrong. File names are relative
to the TFTP root, with no leading /. Test from another SliTaz machine,
with the tftp client of BusyBox:
$ tftp -g -r boot/grub/grub.cfg 192.168.0.10
GRUB starts but drops to grub>: it did not find
boot/grub/grub.cfg on the server. Run grub-mknetdir again with the
right --net-directory.
"error: no suitable video mode found" on a UEFI client: GRUB has no
video driver loaded, and the kernel may then have no screen. Add
insmod all_video at the top of grub.cfg.
The client hangs while loading rootfs.gz, or the system is killed
at boot: not enough RAM. The live system runs in memory, see
memory; SliTaz Base
needs the least.
Links
- Boot process: what happens after GRUB.
- Handbook: boot options, network, servers.
man dnsmasq, and the dnsmasq documentation.- iPXE, the network boot firmware behind Web Boot.