tomclegg.net |
FreeBSD network boot server Posted April 18, 2005 How to boot diskless clients into FreeBSD using PXE: Set up the client's root directory on the server.Create the mkdir /home/pxe Install a FreeBSD distribution in cd /usr/src && make installworld DESTDIR=/home/pxe cd /usr/src && make distribution DESTDIR=/home/pxe -DNO_MAKEDEV_RUN cd /home/pxe/dev && sh MAKEDEV all cd /home/pxe && ln -s boot/pxeboot Install a dhcp server.cd /usr/ports/net/isc-dhcp3-server make install echo dhcpd_enable=YES >> /etc/rc.conf /usr/local/etc/rc.d/isc-dhcpd.sh start Configure the dhcp server to supply a network boot filename.Sample option domain-name ""; option domain-name-servers 192.168.2.1; default-lease-time 600; max-lease-time 7200; ddns-update-style none; log-facility local7; option routers 192.168.2.1; subnet 192.168.2.0 netmask 255.255.255.0 { option subnet-mask 255.255.255.0; range 192.168.2.100 192.168.2.199; filename "pxeboot"; next-server 192.168.2.2; option root-path "192.168.2.2:/home/pxe"; } Restart the server after modifying the configuration file. /usr/local/etc/rc.d/isc-dhcpd.sh restart Turn on tftp and nfs services on the server.Add to /home -alldirs -ro -maproot=root -network 192.168.2 -mask 255.255.255.0(replace 192.168.2 with your network number) Add to tftp dgram udp wait root /usr/libexec/tftpd tftpd -s /home/pxe Add to inetd_enable=YES portmap_enable=YES nfs_server_enable=YES Reboot, or start inetd and nfsd manually. cat /var/run/inetd.pid || inetd netstat -an | fgrep -w '*.111' || /usr/sbin/portmap cat /var/run/mountd.pid || /sbin/mountd netstat -an | fgrep -w '*.2049' || /sbin/nfsd -u -t -n 4 Set up net client configuration files.Create 192.168.2.2:/home/pxe / nfs ro 0 0 Create ipaddr="`ifconfig|grep inet | head -n 1 | cut -d\ -f2`" hostname="`echo "$ipaddr" | tr . -`".example.com(this will give the client a hostname like 192-168-2-199.example.com) Set up applications to run on the clientYou can set up the client to run a script instead of showing a login prompt. In this example, the client downloads a disk image from a web server and writes it to the built-in flash disk on an HP T5700 thin terminal. Replace the line in ttyv0 "/usr/libexec/getty image" cons25 on secure Add to the end of image:al=root:tc=Pc: Add to the end of ./image Create /home/pxe/root/image #!/bin/sh image=sampleimagefilename device=/dev/ad0 echo -n "Install \"$image\" image on $device? (yes/no) " read yesno case "$yesno" in yes) (sleep 5; while killall -INFO dd 2>/dev/null; do sleep 20; done) & fetch -o - -q http://192.168.2.2/software/Images/$image.img \ | dd of=/dev/ad0 bs=1m ;; esac Make chmod +x /home/pxe/root/image Edit or remove |