In this configuration, DHCP will run on the OpenWrt Box, while the TFTP server (the one serves the boot files) runs on a different computer.
config boot linux
option filename 'pxelinux.0'
option serveraddress '192.168.?.?'
option servername '?'
/etc/init.d/dnsmasq restart
apt install tftpd-hpa
# vi /etc/default/tftpd-hpa
# systemctl status tftpd-hpa
# systemctl restart tftpd-hpa
# cd /tmp
# uname -a >/srv/tftp/test
# tftp 192.168.0.2
tftp> get test
tftp> quit
# diff test /srv/tftp/test
(nothing, they are identical)
sudo apt install nfs-kernel-server
echo "/srv/nfs 192.168.0.0/16(async,no_root_squash,no_subtree_check,ro)" >> /etc/exports
systemctl restart nfs-kernel-server.service
sudo mkdir /mnt/ubuntu_18_desktop_iso
sudo mount -o loop ubuntu-18.04.3-desktop-amd64.iso
ln -s /mnt/ubuntu_18_desktop_iso /srv/nfs/
mkdir /srv/tftp/casper
cp /srv/nfs/casper/initrd /srv/tftp/casper
cp /srv/nfs/casper/vmlinuz /srv/tftp/casper
Append to /srv/tftp/ubuntu-installer/amd64/boot-screens
label live
menu label Ubuntu Desktop 18.04 Live
menu default
kernel casper/vmlinuz
append nfsroot=192.168.x.x:/srv/nfs netboot=nfs boot=live boot=casper initrd=/casper/initrd systemd.mask=tmp.mount --
Replace default install
with default live
, delete menu default
under label install
. This only controls which menu item is selected by default.
In /srv/tftp/pxelinux.cfg/default
(NOT /srv/tftp/ubuntu-installer/amd64/pxelinux.cfg/default
), replace timeout 0
with:
timeout 50
ONTIMEOUT live
This controls the timeout action.
systemctl restart nfs-kernel-server
systemctl restart tftpd-hpa.service
rm -rf boot.img.gz netboot.tar.gz xen
Reference:
- https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
- TFTP boot, https://openwrt.org/docs/guide-user/base-system/dhcp_configuration
- https://wiki.debian.org/PXEBootInstall
- Another solution, https://forum.openwrt.org/t/solved-dhcp-config-pxe-boot-from-external-tftp-server/5880/2
- Openwrt doc, https://openwrt.org/docs/guide-user/base-system/dhcp
- Ubuntu Live PXE, http://c-nergy.be/blog/?p=13243