How to install FreeBSD 82 via PXE from anywhere (i.e. without a NFS server)
December 2011.
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.
Step 1: build the FreeBSD image disk
Create some dirs:
# mkdir /tmp/build
# mkdir /tmp/build/iso.mnt
# mkdir /tmp/build/hd.mnt
# mkdir /tmp/build/mfs.mnt
# cd /tmp/build
Get the image:
# wget ftp://ftp.fr.freebsd.org/pub/FreeBSD/ISO-IMAGES-i386/8.2/FreeBSD-8.2-RELEASE-i386-bootonly.iso
--2011-12-15 09:30:41-- ftp://ftp.fr.freebsd.org/pub/FreeBSD/ISO-IMAGES-i386/8.2/FreeBSD-8.2-RELEASE-i386-bootonly.iso
=> `FreeBSD-8.2-RELEASE-i386-bootonly.iso.1'
Resolving ftp.fr.freebsd.org... 88.191.250.131
Connecting to ftp.fr.freebsd.org|88.191.250.131|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD (1) /pub/FreeBSD/ISO-IMAGES-i386/8.2 ... done.
==> SIZE FreeBSD-8.2-RELEASE-i386-bootonly.iso ... 49262592
==> PASV ... done. ==> RETR FreeBSD-8.2-RELEASE-i386-bootonly.iso ... done.
Length: 49262592 (47M) (unauthoritative)
100%[======================================>] 49,262,592 2.57M/s in 18s
2011-12-15 09:30:59 (2.62 MB/s) - `FreeBSD-8.2-RELEASE-i386-bootonly.iso.1' saved [49262592]
Mount the image:
# mdconfig -a -t vnode -f /tmp/build/FreeBSD-8.2-RELEASE-i386-bootonly.iso
md0
# 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-8.2-RELEASE-i386-bootonly.hd bs=1m count=60
60+0 records in
60+0 records out
62914560 bytes transferred in 0.737012 secs (85364374 bytes/sec)
# mdconfig -a -t vnode -f /tmp/build/FreeBSD-8.2-RELEASE-i386-bootonly.hd
md1
# 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: 122864 16 4.2BSD 0 0
c: 122880 0 unused 0 0 # "raw" part, don't edit
# newfs /dev/md1a
/dev/md1a: 60.0MB (122864 sectors) block size 16384, fragment size 2048
using 4 cylinder groups of 15.00MB, 960 blks, 1920 inodes.
super-block backups (for fsck -b #) at:
160, 30880, 61600, 92320
# mount /dev/md1a /tmp/build/hd.mnt
Copy the boot files from the iso to the disk image:
# cp -r /tmp/build/iso.mnt/boot /tmp/build/hd.mnt/boot
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 FreeBSD installer image disk.
Step2: Boot the image disk
Download pxelinux.0.
Download memdisk. You can find it packaged with syslinux: http://www.kernel.org/pub/linux/utils/boot/syslinux/
Create pxelinux config file (pxelinux.cfg/default):
DEFAULT fbsd
LABEL fbsd
kernel memdisk
append initrd=/FreeBSD82.hd harddisk
Setup your DHCP and TFTP servers to serve the directory and you're good.
Sources
- Gianpaolo Del Matto; Convert FreeBSD ISO image for PXE bootstrap: http://phaq.phunsites.net/2007/02/14/convert-freebsd-iso-image-for-pxe-bootstrap/