Assertion failed

Oct 07, 2014

Netbooting mfsbsd

Currently I’m trying to automatically installing FreeBSD on zfs by netbooting a comuter. As a part of this I have to pxeboot a mfsbsd image which actually does the install. So far this is how I got mfsbsd to netboot of a FreeBSD host.

First of all we need to grab an mfsbsd image and setup the root for tftp. The tftp root folder is commonly placed at /tftpboot.

# fetch http://mfsbsd.vx.sk/files/iso/10/amd64/mfsbsd-10.0-RELEASE-amd64.iso
# mkdir -p /tftpboot/mfsroot
# tar -xf mfsbsd-10.0-RELEASE-amd64.iso -C /tftpboot/mfsroot
# cp /boot/pxeboot /tftpboot

After this is done we will need an tftp server. FreeBSD comes with one in the base system so we will only have to activate this in /etc/inetd.conf. This is done by uncommenting the following lines in /etc/inetd.conf, the second line is only necessary if you want to use ipv6.

tftp    dgram   udp     wait    root    /usr/libexec/tftpd  tftpd -l -s /tftpboot
tftp    dgram   udp6    wait    root    /usr/libexec/tftpd  tftpd -l -s /tftpboot

Unfortunately the freebsd pxe loader only supports nfs without recompiling it. This isn’t a big issue though as FreeBSD as an nfs server in the base system. To tell nfsd to share the location where we placed the mfsbsd image, add the following to /etc/exports

/tftpboot/mfsroot -ro -maproot=root -network=192.168.1.0 -mask=255.255.255.0

Before we are done we will need an dhcp server, if you don’t have one allready you can get one from port by using the following command.

# pkg install isc-dhcp42-server

Following is an example of dhcpd.conf, you will probably have to modify it for your needs.

subnet 192.168.1.1 netmask 255.255.255.0 {
    range 192.168.1.50 192.168.1.100;
    option routers 192.168.1.1;
    option domain-name-servers 192.168.1.1;
    option domain-name "domain.tld";
    default-lease-time 3600;
    max-lease-time 3600;
    next-server 192.168.1.2;
    option root-path "/tftpboot/mfsroot";
    filename "pxeboot";
}

host host.domain.tld {
    ethernet AA:BB:CC:DD:EE:FF;
    option host-name "host";
}

At last before we can netboot mfsbsd we will have to activate and start all the services we just configured. This can be done with the following commands.

# sysrc dhcpd_enable=YES
# sysrc nfsd_enable=YES
# sysrc mountd_enable=YES
# sysrc inetd_enable=YES
# service nfsd start
# service isc-dhcpd start
# service inetd start

Finally we should be able to boot netboot mfsbsd. Going forward I’m looking into modifying the mfsbsd image to include either an installer or some bootstraping to download and execute an installer. The goal is to install FreeBSD without human intervention, only by pxe booting a host in the correct subnet.

Mastodon