tomclegg.net


Diary
Examples
    256-router
    adzap
    apache-double-reverse
    cacti-adodb-php4
    debian-quota
    diskonmodule
    dollarsperbyte
    dynip
    ezmlm-linux
    fbsdhabits
    freebsdclone
    macbook-quantal-sound
    maildirpop3d-awfulhak
    mandy
    md
    mrtg
    net-snmp
    nodefaultroute
    oracle9i
    oracle9i-bsd5
    oracle9i-client
    oracle9i-nat
    php-cgi
    php-commandline
    php-image
    php-kics
    php-mini_httpd
    pinouts
    pizzaperdollar
    plesk-symlink-php
  >pxe<
    qmail-linux
    qmail-qfilter
    racoon-sonicwall
    redundant-vpn
    rewriterule
    seahorse-workaround
    setting-locale-failed
    smalldog
    snmpv3-cacti
    spamassassin
    squid-tproxy
    supfile
    suse73
    svc-nmbd
    svc-smbd
    svc-smtpd
    switch-virtualbox-virsh
    toyotastereo
    vm
    vn-file
    wmp-invalid
    xcode-remote-install
    xen-eth0-renamed
    xen-monowall
    xen3-ubuntu-dapper
    zz-update-grub-fail
Hire Tom
Mostly Mozart
Patches
School
Scrapbook
Software
Telephones




colocation
comments
davidireland
edsgranola
faq
funsites
goodlooking
goodmovies
google-earth-saucy-amd64
houserules
liberating
resume
resume2
scratch
shopping
snacks
todo
university
warisbogus

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 /home/pxe directory.

mkdir /home/pxe

Install a FreeBSD distribution in /home/pxe/.

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 /usr/local/etc/dhcpd.conf configuration file (server is 192.168.2.2):

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 /etc/exports

/home -alldirs -ro -maproot=root -network 192.168.2 -mask 255.255.255.0
(replace 192.168.2 with your network number)

Add to /etc/inetd.conf

tftp dgram udp wait root /usr/libexec/tftpd tftpd -s /home/pxe

Add to /etc/rc.conf

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 /home/pxe/etc/fstab

192.168.2.2:/home/pxe / nfs ro 0 0

Create /home/pxe/etc/rc.conf.

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 client

You 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 /home/pxe/etc/ttys starting with "ttyv0"

ttyv0 "/usr/libexec/getty image" cons25 on secure

Add to the end of /home/pxe/etc/gettytab

image:al=root:tc=Pc:

Add to the end of /home/pxe/root/.login

./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 /home/pxe/root/image executable.

chmod +x /home/pxe/root/image

Edit or remove /home/pxe/etc/motd as desired.