Raspberry Pi as a PXE, TFTP, NFS, proxy DHCP server
apt-get install syslinux-common #This is for pxe booting files. apt-get install dnsmasq #Since I already have a router providing DHCP we need to use a proxy dhcp. dnsmasq is a great set of tools providing us with both tftp and proxy dhcp. mkdir /srv/tftpboot #root folder for pxe server. cp /usr/lib/syslinux/pxelinux.0 /srv/tftpboot/ #copy necessary files for pxe boot. cp /usr/lib/syslinux/menu.c32 /srv/tftpboot/ mkdir /srv/tftpboot/pxelinux.cfg #folder for boot menu vi /srv/tftpboot/pxelinux.cfg/default #Menu file |
Add following info for /srv/tftboot/pxelinux.cfg/default
DEFAULT menu.c32
PROMPT 0
MENU TITLE PXE Boot
LABEL Test
MENU LABEL Test |
Edit dnsmasq settings.
vi /etc/dnsmasq.conf |
Just add following lines at the end of the file.
# Don't function as a DNS server: port=0 # Log lots of extra information about DHCP transactions. log-dhcp # Dnsmasq can also function as a TFTP server. You may uninstall # tftpd-hpa if you like, and uncomment the next line: enable-tftp # Set the root directory for files available via FTP. tftp-root=/srv/tftpboot # The boot filename. dhcp-boot=/srv/tftpboot/pxelinux.0 # rootpath option, for NFS #dhcp-option=17,/opt/ltsp/i386 # kill multicast dhcp-option=vendor:PXEClient,6,2b # Disable re-use of the DHCP servername and filename fields as extra # option space. That's to avoid confusing some old or broken DHCP clients. dhcp-no-override # PXE menu #pxe-prompt="Press F8 for boot menu", 3 # The known types are x86PC, PC98, IA64_EFI, Alpha, Arc_x86, # Intel_Lean_Client, IA32_EFI, BC_EFI, Xscale_EFI and X86-64_EFI pxe-service=X86PC, "Boot from network...", /srv/tftpboot/pxelinux # A boot service type of 0 is special, and will abort the # net boot procedure and continue booting from local media. pxe-service=X86PC, "Boot from local hard disk", 0 # If an integer boot service type, rather than a basename is given, then the # PXE client will search for a suitable boot service for that type on the # network. This search may be done by multicast or broadcast, or direct to a # server if its IP address is provided. #pxe-service=x86PC, "Install windows from RIS server", 1 # This range(s) is for the public interface, where dnsmasq functions # as a proxy DHCP server providing boot information but no IP leases. # Any ip in the subnet will do, so you may just put your server NIC ip here. dhcp-range=10.0.10.200,proxy,255.255.255.0 |
Restart dnsmasq to load config
root@pi:/srv/tftpboot#service dnsmasq restart |
Try to boot a machine with pxe booting. Just to verify that's working.
Next we need to install nfs support for sharing the mounted iso files.
root@pi:/srv/tftpboot#apt-get install nfs-kernel-server root@pi:/srv/tftpboot#mkdir /tftpboot/iso #this is where we put distro iso files root@pi:/srv/tftpboot#mkdir /tftpboot/nfs #this is where we share nfs files root@pi:/srv/tftpboot#mkdir /tftpboot/nfs/ubuntu #folder for ubuntu dist |
Edit nfs shares
root@pi:/srv/tftpboot/#vim.tiny /etc/exports |
Add following line:
/srv/tftpboot/nfs/ubuntu/ *(ro,sync,no_subtree_check) |
root@pi:/srv/tftpboot# mount -o loop iso/ubuntu-13.04.iso nfs/ubuntu/ #mount iso file to nfs folder mount: warning: nfs/ubuntu/ seems to be mounted read-only. |
Then we need to enable rpcbind and restart nfs
root@pi:/srv/tftpboot#update-rc.d rpcbind enable && update-rc.d nfs-common enable root@pi:/srv/tftpboot#service rpcbind start root@pi:/srv/tftpboot#service nfs-kernel-server restart |
Add following entry to the /srv/tftpboot/pxelinux.cfg/default
DEFAULT menu.c32 PROMPT 0 MENU TITLE PXE Boot LABEL Test MENU LABEL Test LABEL Ubuntu MENU LABEL ^Ubuntu 13.04 KERNEL nfs/ubuntu/casper/vmlinuz APPEND initrd=nfs/ubuntu/casper/initrd.lz boot=casper netboot=nfs nfsroot=192.168.0.180:/srv/tftpboot/nfs/ubuntu |
Change IP to your server IP in default config file
Please Register.
If you wish to add comments.
Cheers
Adam