How to install FreeBSD 90 via PXE from anywhere (i.e. without a NFS server)

February 2012.

The situation

You want to install FreeBSD on another machine. You don't want to use a NFS server, because you are either on a Windows computer or because you simply want to boot the installer using pxeboot or gpxe.

From FreeBSD 9.0, the bootonly CD does not use a mfs file system anymore, so instead of just copying the existing one, you either need to make one yourself or find one on the internet.

We will be using one from mfsbsd, from Martin Matuška.

[2014-06-15] Update: I've been told by email that mfsbsd now provides images directly from their website:
Thanks to Roman Makarov for the information.

Step 1: build the FreeBSD image disk

Create some dirs:

# mkdir /tmp/build
# mkdir /tmp/build/iso.mnt
# mkdir /tmp/build/hd.mnt
# cd /tmp/build

Get the image:

mfsbsd-9.0-amd64.iso 100% of 28 MB 3904 kBps

Mount the image:

# mdconfig -a -t vnode -f /tmp/build/mfsbsd-9.0-amd64.iso
# mount_cd9660 /dev/md0 /tmp/build/iso.mnt/

Create a hard disk image. Be sure to choose the right size.

# dd if=/dev/zero of=/tmp/build/FreeBSD-9.0-RELEASE-amd64-bootonly-mfsbsd.hd bs=1m count=30
30+0 records in
30+0 records out
31457280 bytes transferred in 0.371249 secs (84733651 bytes/sec)
# mdconfig -a -t vnode -f /tmp/build/FreeBSD-9.0-RELEASE-amd64-bootonly-mfsbsd.hd
# fdisk -B -I /dev/md1
******* Working on device /dev/md1 *******
fdisk: invalid fdisk partition table found
fdisk: Class not found
# bsdlabel -B -w /dev/md1
# bsdlabel -e /dev/md1
# /dev/md1:
8 partitions:
# size offset fstype [fsize bsize bps/cpg]
a: 61424 16 4.2BSD 0 0
c: 61440 0 unused 0 0 # "raw" part, don't edit
/tmp/EdDk.LJ3WUbdhRH: 5 lines, 212 characters
# newfs /dev/md1a
/dev/md1a: 30.0MB (61424 sectors) block size 16384, fragment size 2048
using 4 cylinder groups of 7.50MB, 480 blks, 960 inodes.
super-block backups (for fsck -b #) at:
160, 15520, 30880, 46240
# mount /dev/md1a /tmp/build/hd.mnt

Copy the boot files from the iso to the disk image:

# cp -r iso.mnt/* hd.mnt/

Umount everything:

# umount /tmp/build/hd.mnt
# mdconfig -d -u 1
# umount /tmp/build/iso.mnt
# mdconfig -d -u 0

You now have a bootable mfsBSD image disk.

Step2: Boot the image disk

Download pxelinux.0.
Download memdisk. You can find it packaged with syslinux:

Create pxelinux config file (pxelinux.cfg/default):


LABEL fbsd
kernel memdisk
append initrd=/FreeBSD-9.0-RELEASE-amd64-bootonly-mfsbsd.hd harddisk raw

Setup your DHCP and TFTP servers to serve the directory and you're good.

Once booted, login as root and launch the usual installer: