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 serverUncomment the line with tftp in /etc/inetd.conf
tftp dgram udp wait root /usr/libexec/tftpd tftpd -s /tftpfbsdshell>kill -HUP `pgrep inetd`Setting up dhcp server
Adding the part below to /etc/dhcpd.conf
shared-network LOCAL-NET { option domain-name "dissectible.org"; option domain-name-servers 192.168.0.100; subnet 192.168.0.0 netmask 255.255.255.0 { option routers 192.168.0.1; filename "pxeboot"; option root-path "/usr/pxeboot"; range 192.168.0.201 192.168.0.240; default-lease-time 84600; max-lease-time 90000; }}Now add one liner to /etc/rc.conf.local
shell>echo "dhcpd_flags=" >> /etc/rc.conf.localTo start without rebooting, change the $NIC to your network interface variable -
shell>dhcpd $NICFilename 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 ServerCreate the directory you want to export as network file system.
shell>mkdir /usr/pxebootAdding the line belows to /etc/exports
/usr -alldirs -maproot=nobody Or if you want to be stricter and only allow hosts in the 192.168.0.0/24 network to access only,
/usr /usr/pxeboot -maproot=nobody -network=192.168.0 -mask=255.255.255.0To run everything manually,
shell>/sbin/nfsd -tun 4shell>echo -n > /var/db/mountdtabshell>/sbin/mountd -d /etc/exportsYou can check the nfs server info with rpcinfo -p and showmount -a
To mount nfs filesystem
shell>mount -o ro -t nfs 192.168.0.55:/usr /mntOr to have it mounted on boot, add this to /etc/fstab
192.168.0.55:/usr/pxeboot /mnt nfs ro.nodev,nosuid 0 0To put nfs starts onboot, add them to /etc/rc.conf.local
portmap=YESnfs_server=YESnfsd_flags="-tun 4"After you have setup all the servers, you need to download FreeBSD installation iso.
shell>cd /tmp; wget \ ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/6.1/6.1-RELEASE-i386-disc1.isoNow I have the iso, I need to extract the image contents out of it.
shell>vnconfig svnd0 /tmp/6.1-RELEASE-i386-dist.isoshell>mount -t cd9660 /dev/svnd0c /mntSync 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/kernelload -t mfs_root /boot/mfsrootset vfs.root.mountfrom="ufs:/dev/md0c"bootCopy the pxeboot to the tftp server directory
shell>cp /usr/pxeboot/boot/pxeboot /tftpfbsd