Installing FreeBSD with PXE

Posted by Ceri Davies Sun, 12 Feb 2006 21:03:00 GMT

Today has been very interesting, as in times.

Firstly, I discovered that the reason that my DHCP server was failing to respond to any requests was that I didn’t have the binaries installed. At some point in the past I obviously had a dumbass day like today and restored the configuration from backup without installing the package. When I think of the hours I have spent pulling my hair our in front of tcpdump and my ipfw configuration it makes me want to cry.

I also dropped a jar of redcurrant jelly on the floor, throwing sticky glass shards everywhere. And to top it all, I completely screwed the timing on today’s dinner, so everything is currently going cold in the kitchen while the meat is practically still trying to kick its way out of the oven.

On the plus side, my DHCP server works now. I managed to get FreeBSD installed non-interactively over the network, and proved that sysinstall doesn’t require you to specify a hostname in install.cfg, so long as your DHCP server provides one.

Back on the down side, the PXE article at FreeBSD.org is out of date and it looks like I just volunteered to update it. I cannot face any DocBook today, so here are some notes.

Setting up the TFTP server

  • Enable tftp in inetd.conf and restart inetd:
# grep tftp /etc/inetd.conf  
tftp    dgram   udp     wait    root    /usr/libexec/tftpd      tftpd -l -s /a/tftpboot
# /etc/rc.d/inetd reload
  • Copy pxeboot to the TFTP root
# mkdir -p /a/tftpboot
# cp /boot/pxeboot /a/tftpboot

Setting up the DHCP server

  • Don’t forget: install the net/isc-dhcp3-server package!
  • As a minimum, you want something like the following in your /usr/local/etc/dhcpd.conf:
option subnet-mask 255.255.255.0;
option routers 192.168.10.1;
filename "pxeboot";
option root-path "/a/pxeinstall";

ddns-update-style none;

option domain-name "private.submonkey.net";
option broadcast-address 192.168.10.255;
option domain-name-servers 192.168.10.17;
server-name "dr.private.submonkey.net";
server-identifier 192.168.10.17;

default-lease-time 7200;
max-lease-time 7200;

subnet 192.168.10.0 netmask 255.255.255.0 {
        next-server 192.168.10.17;
        range 192.168.10.32 192.168.10.64;

        host quinch     {
                hardware ethernet       aa:02:b3:d1:e2:77;
                fixed-address           192.168.10.19;
                option host-name        "quinch";
        }
}

If you will be specifying a hostname in install.cfg, you don’t need the host quinch entry. However, we’re definitely going to want to use the same install.cfg for all of our clients, since it has to go inside the mfsroot!

Setting up the NFS server

The loader is configured to do NFS by default. Can’t argue with that.

  • Create /a/pxeinstall and share it:
# mkdir /a/pxeinstall
# echo 'rpcbind_enable="YES"' >> /etc/rc.conf
# echo 'nfs_server_enable="YES"' >> /etc/rc.conf
# echo '/a -alldirs -maproot=nobody' >> /etc/exports
# reboot

Once the machine comes back up, you need to copy the boot files to the NFS root. The easiest place to get them is from a bootonly ISO, so grab one that’s appropriate for your environment - I’m installing the amd64 bits:

# ftp -a ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/ISO-IMAGES/6.0/6.0-RELEASE-amd64-bootonly.iso
# mdconfig -a -f `pwd`/6.0-RELEASE-amd64-bootonly.iso
md2
# mkdir /dist
# mount -t cd9660 /dev/md2 /dist
# rsync -avH /dist/ /a/pxeinstall/

Adding install.cfg to the mfsroot

Now you have the correct bits in the NFS root, we need to add our install.cfg to the mfsroot.

# gzip -d /a/pxeinstall/boot/mfsroot.gz
# mdconfig -a -f /a/pxeinstall/boot/mfsroot
md3
# mount /dev/md3 /mnt
# cp install.cfg /mnt
# umount /mnt
# mdconfig -d -u 3

Note that I haven’t gzip’d the mfsroot again, since in my testing that just caused the client to reboot.

Finally, we just need to add a loader.rc to tell loader to boot the mfsroot:

# cat >> /a/pxeinstall/boot/loader.rc << EOF
load /boot/kernel/kernel
load -t mfs_root /boot/mfsroot
set vfs.root.mountfrom="ufs:/dev/md0c"
boot
EOF

I’m pretty sure that the vfs.root.mountfrom line should read /dev/md0 rather than /dev/md0c, but this works, so we’ll go with it.

Now boot your target machine from PXE. Hope you didn’t have anything you wanted to keep on there!

Posted in ,  | no comments | no trackbacks

Comments

Trackbacks

Use the following link to trackback from your own site:
http://typo.submonkey.net/articles/trackback/63

Comments are disabled