Dec 16, 2013
3 min read
May 27, 2023 11:35 EEST

http://www.freebsd.org/doc/en_US.ISO8859-1/articles/pxe/index.html , http://www.daemonsecurity.com/pxe/jumpstart.html and http://www.daemonsecurity.com/pxe/diskless.html

 and http://www.daemonsecurity.com/pub/pxeboot/



To setup PXEBoot to autoinstall a FreeBSD:

mdconfig -a -t vnode -f kern.flp -u 0 # (vnconfig vn0 kern.flp) associate a vndevice with the file
mount /dev/md0 /mnt/test # (mount /dev/vn0 /mnt) mount it
cp -R /mnt /usr/tftp/boot # copy the contents to /usr/tftpboot
umount /mnt              # unmount it
mdconfig -d -u 0         # disassociate the vndevice from the file

mdconfig -a -t vnode -f mfsroot.flp -u 0
mount /dev/md0 /mnt/test              # mount it
cp /mnt/test/mfsroot.gz /usr/tftp/boot # copy the contents to /usr/tftp/boot
umount /mnt/test                     # unmount it
mdconfig -d -u 0                  # disassociate the vndevice from the file
cd /usr/tftp/boot                 # get into the pxeboot directory
gunzip mfsroot.gz                # uncompress the mfsroot

cd /usr/tftp/boot
mdconfig -a -t vnode -f mfsroot -u 0
mount /dev/md0 /mnt/test
cp /root/install.cfg /mnt/test
umount /mnt/test
mdconfig -d -u 0

Diskless client

Make a diskless client:

Building the base system

cd /usr/src
make buildworld
make DESTDIR=/usr/local/diskless/FreeBSD installworld
make DESTDIR=/usr/local/diskless/FreeBSD distribution

Building a custom kernel

cd /usr/src/sys/i386/conf

Add the following lines to the kernel configuration:

# Filesystems
options         PSEUDOFS        # Pseudo-filesystem framework
options         NFSCLIENT       # NFS filesystem support
options         NFS_ROOT        # NFS is a posible root device

# Memory pseudo devices
device          mem             # Memory and kernel memory devices
device          md              # Memory "disks"

options         BOOTP           # BOOTP is only needed to get hostname 

Now build the kernel with

cd /usr/src
make KERNCONF=DISKLESS buildkernel

Installing the boot files:

mkdir -p /usr/local/diskless/FreeBSD/boot/defaults
cp /boot/defaults/loader.conf /usr/local/diskless/FreeBSD/boot/defaults/
cp /usr/src/sys/boot/i386/loader/loader.rc /usr/local/diskless/FreeBSD/boot/
cp /usr/src/sys/i386/conf/GENERIC.hints /usr/local/diskless/FreeBSD/boot/device.hints

Install the kernel:

make KERNCONF=DISKLESS DESTDIR=/usr/local/diskless/FreeBSD installkernel

Installing tftp

Copy the files:

cp /usr/local/diskless/FreeBSD/boot/pxeboot /usr/local/tftp/boot/

Enable tftp in the inetd.conf

tftp    dgram   udp wait    nobody  /usr/libexec/tftpd  tftpd -l -s /usr/local/tftp

Setting up dhcp server

Put the following lines into the dhcpd.conf:

filename "boot/pxeboot";
subnet netmask {
     option root-path "";

Setting up the NFS server

Edit the /etc/exports and add the following lines:

# for pxe boot
/usr/local/diskless/FreeBSD    -alldirs    -ro
/usr    -alldirs    -ro

Disable ACPI

Edit the file /usr/local/diskless/FreeBSD/boot/loader.conf.local:

verbose_loading="YES"            # Set to YES for verbose loader output

If you boot the diskless system now, it should load the kernel and boot up to the login prompt with some error messages.

Configure the diskless client

At first we chroot to avoid confusion about pathes:

cd /usr/local/diskless
chroot FreeBSD/

To enable syslog edit /etc/rc.conf:

syslogd_enable="YES"            # Run syslog daemon (or NO).

Edit /etc/syslog.conf and put only these lines into it:

*.err;kern.warning;auth.notice;mail.crit        /dev/console
*.*                                             @server.idefix.loc

After the @ put the hostname which should receive the logs.

Disable cron and enable ntp for time syncronization, edit /etc/rc.conf:

cron_enable="NO"                # Run the periodic job daemon.
ntpdate_enable="YES"            # Run ntpdate to sync time on boot (or NO).
ntpdate_hosts=""   # ntp server to use for ntpdate

Configure the filesystems in the file /etc/fstab:

# Device                                   Mount  FStype  Options       Dump  Pass#  /      nfs     ro            0     0                    /home  nfs     rw,userquota  0     0
proc                                       /proc  procfs  rw            0     0

To enable /tmp and /var as ram drive add to /etc/rc.conf:

tmpmfs="YES"       # Set to YES to always create an mfs /tmp, NO to never
varmfs="YES"       # Set to YES to always create an mfs /var, NO to never

Creating the HOME directory:

mkdir /home

Set password for root account:

passwd root

Create a useraccount:


Exit from the chroot.

Installing software

Mount the porttree via nullfs to /usr/local/diskless/FreeBSD:

mount_nullfs /usr/ports/ /usr/local/diskless/FreeBSD/usr/ports

To get all software installed correctly mount /dev into the chroot environment:

mount -t devfs devfs /usr/local/diskless/FreeBSD/dev

Now chroot with:

cd /usr/local/diskless
chroot FreeBSD/

and install cvsup at first.

After installing required software with the port-tree unmount the devfs again with:

umount /usr/local/diskless/FreeBSD/dev

Related Posts