tftp server on Debian
context
dit document beschrijft de installatie van een TFTP server op Debian
✅ GOAL:
Set up a PXE server on Debian that can serve:
PXE bootloader via TFTP
Debian installer and preseed file via HTTP
🧰 Required Packages (all on your Debian PXE server)
Install all necessary packages:
sudo apt update sudo apt install apache2 tftpd-hpa syslinux-common pxelinux
These install:
tftpd-hpa: TFTP server
apache2: HTTP server
syslinux / pxelinux.0: PXE bootloaders
📁 Directory Structure Overview
We'll organize everything like this:
/var/lib/tftpboot/ ├── pxelinux.0 ├── ldlinux.c32 ├── pxelinux.cfg/ │ └── default ├── debian-installer/ │ └── amd64/ │ ├── linux │ └── initrd.gz
/var/www/html/ └── preseed/
└── debian.cfg
1️⃣ TFTP Server Setup 1.1 Create required directories: sudo mkdir -p /var/lib/tftpboot/pxelinux.cfg
1.2 Copy PXE bootloader files: sudo cp /usr/lib/PXELINUX/pxelinux.0 /var/lib/tftpboot/ sudo cp /usr/lib/syslinux/modules/bios/ldlinux.c32 /var/lib/tftpboot/
1.3 Configure tftpd-hpa
Edit the config file:
sudo nano /etc/default/tftpd-hpa
Update it to:
TFTP_USERNAME=“tftp” TFTP_DIRECTORY=“/var/lib/tftpboot” TFTP_ADDRESS=“0.0.0.0:69” TFTP_OPTIONS=“–secure”
Then restart the service:
sudo systemctl restart tftpd-hpa sudo systemctl enable tftpd-hpa
Check that it's listening:
sudo netstat -ulnp | grep 69
2️⃣ Download Debian Netboot Files
Download the kernel and initrd files for PXE boot:
cd /var/lib/tftpboot/ sudo mkdir -p debian-installer/amd64 cd debian-installer/amd64
sudo wget http://deb.debian.org/debian/dists/bookworm/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux sudo wget http://deb.debian.org/debian/dists/bookworm/main/installer-amd64/current/images/netboot/debian-installer/amd64/initrd.gz
✅ Now your PXE server can load the Debian installer kernel + initrd.
3️⃣ Create PXE Boot Menu
Create the PXE config file:
sudo nano /var/lib/tftpboot/pxelinux.cfg/default
Paste:
DEFAULT install LABEL install
KERNEL debian-installer/amd64/linux APPEND vga=788 initrd=debian-installer/amd64/initrd.gz auto=true priority=critical url=http://<PXE_SERVER_IP>/preseed/debian.cfg
Replace <PXE_SERVER_IP> with the actual IP address of your PXE server (e.g. 192.168.1.100).
4️⃣ HTTP Server Setup (for Preseed)
The Debian installer will fetch the preseed.cfg via HTTP.
4.1 Create the directory and file: sudo mkdir -p /var/www/html/preseed sudo nano /var/www/html/preseed/debian.cfg
Paste a minimal working preseed (adjust usernames, etc.):
# Locale and keyboard d-i debian-installer/locale string en_US d-i keyboard-configuration/xkb-keymap select us
# Network d-i netcfg/choose_interface select auto
# Mirror d-i mirror/country string manual d-i mirror/http/hostname string deb.debian.org d-i mirror/http/directory string /debian d-i mirror/http/proxy string
# Timezone d-i time/zone string UTC d-i clock-setup/utc boolean true
# Users d-i passwd/root-password password rootpass d-i passwd/root-password-again password rootpass d-i passwd/make-user boolean true d-i passwd/user-fullname string Debian User d-i passwd/username string debian d-i passwd/user-password password debianpass d-i passwd/user-password-again password debianpass
# Partitioning (entire disk, LVM) d-i partman-auto/method string lvm d-i partman-lvm/device_remove_lvm boolean true d-i partman-auto/choose_recipe select atomic d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true
# Package selection tasksel tasksel/first multiselect standard, ssh-server d-i pkgsel/include string sudo curl vim
# Grub d-i grub-installer/only_debian boolean true
# Finish d-i finish-install/reboot_in_progress note
Make sure the file is readable:
sudo chmod 644 /var/www/html/preseed/debian.cfg
Now verify it in browser: 👉 http:<PXE_SERVER_IP>/preseed/debian.cfg 5️⃣ Configure Firewall (Optional) If you use ufw: sudo ufw allow 69/udp # TFTP sudo ufw allow 80/tcp # HTTP 6️⃣ You're Ready to Boot VMs via PXE On your ESXi Web UI: Create a new VM (use BIOS, not UEFI). Make sure the NIC is on the same VLAN/subnet. Boot the VM — it should: Get IP from your Windows DHCP server Receive PXE bootloader via TFTP from your Debian PXE server Boot into the Debian installer Pull preseed file from PXE server via HTTP Complete a fully automated install ✅ At This Point, You Have: Component Status TFTP ✅ Installed and configured (/var/lib/tftpboot) HTTP ✅ Apache running and serving /preseed/debian.cfg PXE Menu ✅ Points to Debian installer + preseed Netboot Files ✅ Downloaded from Debian mirrors DHCP ✅ Handled by your existing Windows server 🔁 Next Steps / Optional Customize preseed with static IPs or SSH keys Add post-install hooks using d-i preseed/late_command Support multiple Debian versions Add Ubuntu PXE support in future Would you like me to: Customize a preseed for your environment (hostname, users, static IP)? Help set up PXE for UEFI boot? Generate a post-install script? Let me know — and good job getting this far! ===== meer info ===== voeg hier linken toe naar verdere uitleg

