Wednesday, May 17, 2006

FreeBSD Mass Installations Using OpenBSD PXE Setup

I try to setup PXE environment to install FreeBSD by using OpenBSD box. After tinkering with it, I have a great success and I think this should be shared in case anyone may find it useful, for OpenBSD installation, it is rather easy by following the OpenBSD faq. Here's how I get things work.

Setting up Tftp server

Uncomment the line with tftp in /etc/inetd.conf

tftp dgram udp wait root /usr/libexec/tftpd tftpd -s /tftpfbsd

shell>kill -HUP `pgrep inetd`

Setting up dhcp server

Adding the part below to /etc/dhcpd.conf

shared-network LOCAL-NET {
option domain-name "";
option domain-name-servers;

subnet netmask {
option routers;
filename "pxeboot";
option root-path "/usr/pxeboot";
default-lease-time 84600;
max-lease-time 90000;

Now add one liner to /etc/rc.conf.local

shell>echo "dhcpd_flags=" >> /etc/rc.conf.local

To start without rebooting, change the $NIC to your network interface variable -

shell>dhcpd $NIC

Filename refers to the pxeboot that you copy to /tftpfbsd which the client will fetch it once getting IP from dhcp server.

Root-path refers to the nfs path that storing freebsd base files(for installation) that extracted from the FreeBSD 6.1 iso.

Setting up the Nfs Server

Create the directory you want to export as network file system.

shell>mkdir /usr/pxeboot

Adding the line belows to /etc/exports

/usr -alldirs -maproot=nobody

Or if you want to be stricter and only allow hosts in the network to access only,

/usr /usr/pxeboot -maproot=nobody -network=192.168.0 -mask=

To run everything manually,

shell>/sbin/nfsd -tun 4

shell>echo -n > /var/db/mountdtab

shell>/sbin/mountd -d /etc/exports

You can check the nfs server info with rpcinfo -p and showmount -a

To mount nfs filesystem

shell>mount -o ro -t nfs /mnt

Or to have it mounted on boot, add this to /etc/fstab /mnt nfs ro.nodev,nosuid 0 0

To put nfs starts onboot, add them to /etc/rc.conf.local

nfsd_flags="-tun 4"

After you have setup all the servers, you need to download FreeBSD installation iso.

shell>cd /tmp; wget \

Now I have the iso, I need to extract the image contents out of it.

shell>vnconfig svnd0 /tmp/6.1-RELEASE-i386-dist.iso

shell>mount -t cd9660 /dev/svnd0c /mnt

Sync the content of the image to /usr/pxeboot/

shell>rsync -avH /mnt/ /usr/pxeboot/

By now you have the content of FreeBSD 6.1 image in /usr/pxeboot.

Then append this part to /usr/pxeboot/boot/loader.rc

load /boot/kernel/kernel

load -t mfs_root /boot/mfsroot

set vfs.root.mountfrom="ufs:/dev/md0c"


Copy the pxeboot to the tftp server directory

shell>cp /usr/pxeboot/boot/pxeboot /tftpfbsd

Reboot it once you have everything configured.

It's done now and you can start the network client with netboot. If you are installing fbsd using nfs, just specify /usr/pxeboot as base directory when asked.

I use this setup to install FreeBSD 6.1, for anyone who owns IBM Thinkpad x41 where you don't have the docking station, this is the best way to install FreeBSD 6.1 on it since you can't install with your usb combo drive.

Here are the internet resources I found useful,

I wrote a simple pxe setup script to automate the setup since I hate doing the same things over and over again. You can download it here.

Peace :]

1 comment:

Anonymous said...

nice work. thanx a lot :). tom.