=====Raspberry Pi - PXE server===== I was in need of a simple small PXE server (DHCP and TFTP). PXE server on ethernet, management via wifi. ====Prerequisites==== * 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 [[https://downloads.raspberrypi.org/raspbian_lite_latest|Raspbian Lite (Stretch)]] * Validate download:# From website: SHA-256: e942b70072f2e83c446b9de6f202eb8f9692c06e7d92c343361340cc016e0c9f 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:raspi-config - Boot options: console - Locale - Timezone - Expand filesystem * Reboot * Check for new firmware:rpi-update * Install and configure uncomplicated firewallapt-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 < * Install packages:apt-get install dnsmasq syslinux-common pxelinux * Configure dnsmasq: cat > /etc/dnsmasq.d/server.conf < ===Memtest example (for serial console)=== * Memtest 5.01 cd 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 < ===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 < * Log in and install Voyage:ssh root@ #pass = voyage /usr/local/sbin/format-cf.sh /dev/sdX mkdir /mnt/cf /usr/local/sbin/voyage.update 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 {{tag>[hardware rpi raspberry pxe linux ]}}