PXE Network Install from Linux Server

Hi guys,

I'm trying to add FreeBSD 10.0 to our internal PXE network install server but I'm failing miserably.

I've configured the pxelinux.cfg file in this way:

Code:
#FreeBSD 10.0 RELEASE amd64
label 1
        menu label ^1. FreeBSD 10.0 AMD64
        pxe http://stormwind.if.ufrj.br/freebsd/10.0/amd64/boot/pxeboot

It's not working due to the fact that pxeboot needs an NFS server to continue the boot process. The main problem is how to set this option. I'm aware of the DHCP root-path option. But I can't setup it globally, it should be passed through PXELINUX or must be a way to only server this option from DHCP when a FreeBSD PXE requests this info.

Googling I've found this:
Code:
# FreeBSD       sys/nfs/bootp_subr.c bootpc_init()
option space FreeBSD;
option FreeBSD.root-opts        code 130 = string;  # root mount options "rsize=8192,wsize=8192,intr,soft,noconn,tcp"
option FreeBSD.cookie           code 134 = string;  # sysctl kern.bootp_cookie
# root-path and swap-path are expanded using:  %H -> hostname   %I -> IP address
# Kernel request:
# Vendor-Class Option 60
# "FreeBSD:amd64:8.0-CURRENT"
# "FreeBSD:i386:5.2-CURRENT"
#  012345678901234567890
# ostype:MACHINE:osrelease

class "FreeBSD" {
        match if substring (option vendor-class-identifier,0,7) = "FreeBSD";

        log(info,concat("FreeBSD kernel: ",option vendor-class-identifier));        # fatal/error/info/debug
        site-option-space "FreeBSD";
        option FreeBSD.root-opts "nolockd"; # RO root. Równoważne boot.nfsroot.options="nolockd" ?

        if substring (option vendor-class-identifier,8,4) = "i386" { # 32bit
                option root-path "stormwind.if.ufrj.br:/srv/tftp/freebsd";     # volt:/nfs/freebsd/i386/8.x
        } elsif substring (option vendor-class-identifier,8,5) = "amd64" { # 64bit
                option root-path "stormwind.if.ufrj.br:/srv/tftp/freebsd";      # volt  - OK
        } else {
                log (info, "unknown arch?");
                option root-path "194.29.146.3:/JAKA-ARCH?";
    }
}

Unfortunately wasn't useful since FreeBSD pxeboot still looks for the NFS server in the root path and ignores the option.

Thanks in advance,
 
I have gone through this just this weekend, but my PXE Server is hosted on FreeBSD.

So, technically the PXE loader waits for a DHCP server, if the DHCP server is discovered it will than look for an external loader such as pxelinux which will be loaded from a TFTP server, and once that is loaded up it will than load and eventually boot the installation image off of the TFTP server.

Because PXE is unable to load in RAM more than 45 MB (I believe that is) and because I didn't want to use NFS, what I have done is I have went for using a mfsbsd image, which is essentially a stripped down installation of freebsd FreeBSD with the MFS filesystem, than creating a HDD image of it, placing it on the tftpboot folder, than passed it onto pxelinux.cfg/default ( I might be wrong but PXElinux reads from pxelinux.cfg/default and not from pxelinux.cfg, at least I got it working this way).

In order to obtain a copy mfsbsd and to do the image I suggest you take a look at this http://zewaren.net/site/?q=node/82

Once that done, you will than need to set up a DHCP server to provide the PXE loader with the informations about PXEinux loader and also to provide internet connection, and of course tfptd to serve PXElinux and the installation image.

In /etc/rc.conf you will need to enable dhcpd and inetd.

Code:
# enable inetd server
inetd_enable="YES"

# dhcpd
dhcpd_enable="YES"				# dhcpd enabled?
dhcpd_flags="-q"				# command option(s)
dhcpd_conf="/usr/local/etc/dhcpd.conf"	# configuration file
dhcpd_ifaces="em1"				# the interface which the dhp server will be running on

You will need to enable tftp in /etc/inetd.conf

Code:
tftp   dgram   udp     wait    nobody  /usr/libexec/tftpd      tftpd /usr/local/tftpboot

You will need to install net/isc-dhcp42-server and set it up according to your needs.

This is my DHCP server configuration for the PXE Server /usr/local/etc/dhcpd.conf

Code:
option domain-name "freebsdpxeserver.org";
option subnet-mask 255.255.255.0;
default-lease-time 600;
max-lease-time 72400;
ddns-update-style none;

subnet 192.168.2.0 netmask 255.255.255.0 {
  range 192.168.2.30 192.168.2.40;
  option routers 192.168.1.1, 192.168.2.1;
# PXE Server configuration
  next-server 192.168.2.1;   # TFTP server address
  filename "pxelinux.0";    # PXE boot loader filename
}

I am pretty sure you can do the same way with Linux. I have done a PXE Server Debian Installation on OpenWrt with dnsmaq in the past.

Hopefully this will help .
 
Hello @DutchDaemon, thank you for your help.

Unfortunately I already have a netboot server working. I've taken your info about mfsBSD and was able to boot mfsBSD from my server :)

Now I've another dilemma. I want to automatically start the bsdinstall with some options defined, as example, the default mirror and DHCP on whatever interface FreeBSD finds.

I'm aware of the /etc/installerconfig; I've created one with this info:

Code:
BSDINSTALL_DISTSITE="http://mylocalrepo.mydomain/freebsd/10"

#!/bin/sh
echo "ifconfig_em0=DHCP" >> /etc/rc.conf
echo "sshd_enable=YES" >> /etc/rc.conf
echo "ntpd_enable=YES" >> /etc/rc.conf
echo "dumpdev=AUTO" >> /etc/rc.conf

Now I just want to build the image, but mfsBSD build script complains about a missing /base directory on the FreeBSD-10.0-RELEASE-amd64 image. I don't know if I'm doing something wrong. The error message is this one:

Code:
make
Cannot find directory "/mnt/freebsd-dist/base"
*** Error code 1

Stop.
make: stopped in /root/mfsbsd

Thanks for any help,
 
Last edited by a moderator:
Ok. I was able to build the image and automatically start the installation process. I was pointing to the wrong folder inside the FreeBSD-10.0-RELEASE-disc1 image.

Next problem:
The /etc/installerconfig is just ignored, I've dropped it on files/etc expecting the installerconfig to be copied to /etc of mfsBSD.
 
In the end I decided to ditch the FreeBSD image with mfsroot file system due to it's limitation of 45MB, and instead I went with serving the boot only FreeBSD installation files through NFS.

I have also learned that it's pointless to use the pxelinux loader if you only need to to serve the FreeBSD installation image LAN wide without any restrictions. FreeBSD comes with it's own pxeboot loader in /boot.

If instead you are going to restrict which MAC's should listen from the PXE Server or you simply want to set up a Multiboot PXE Server between between different OS's installations and diskless entries, than your best bet is probably pxelinux.
 
@unknownuser, my PXE server runs on Linux and it serves a lot of things. So at this moment I must use it.

I was able to fully automate, install and deeply modify a installation (even overriding user settings) with PXELINUX and mfsBSD.

Was very hard to do, took me four days to get everything setup. The key point was to enable swap space during installation and use shell scripts in /etc/rc.local to fetch necessary files.

I can post my modified /etc/rc.local file if you want.
 
Last edited by a moderator:
I'd be very keen of any additional info you're able to provide. Are you able to script your installs in such a way that you can template rc.local and perform different actions (e.g. hostname, network configuration, packages) for different machines in much the same way as is possible with Red Hat's Kickstart?
 
I also tried to do PXE Network Install via mfsBSD from CentOS on corporate network,
but met the following problem.

Code:
Loading memdisk....Ready
MEMDISK 3.11 2005-09-02 Copyright 2001-2005 H. Peter Anvin
MEMDISK: No ramdisk image specified

Same process works if the server is FreeBSD.

Anybody share the complete process to make this?

Thanks,
 
Are you missing the image name? Here is an example for booting mfsBSD.

Code:
label mfsbsd64
  menu label Load mfsBSD 10.1-RELEASE amd64
  kernel memdisk
  initrd images/mfsbsd-10.1-RELEASE-amd64.img raw

This works using syslinux-6.01 downloaded directly from kernel.org.
 
Thanks, mostly our company's syslinux-3.11-4 on Centos is too old.
My configuration is similar:

Code:
LABEL mfsbsd
  menu label mfsBSD
  kernel memdisk
  initrd images/mfsbsd-10.1.img.gz raw

Will check tomorrow to see whether it can be updated.
 
On older versions of Syslinux, I found that sticking to 8.3 filenames helped. Can't recall the exact situation, but something about longer filenames did not go over well.
 
On older versions of Syslinux, I found that sticking to 8.3 filenames helped. Can't recall the exact situation, but something about longer filenames did not go over well.

Thanks @wblock.
In fact, I followed your blog and make PXE boot work on FreeBSD.
New to FreeBSD, I did not get what do you mean "8.3 filenames" .
I went to the mfsBSD website, and saw the naming convention
of 10.1 and 8.3 are almost the same.
 
"8.3" means the old MS-DOS format of eight characters, a dot, and then a three-character extension.
 
Figure out the solution finally, instead of configuration in latest syslinux:
Code:
LABEL mfsbsd
menu label mfsBSD
kernel memdisk
initrd images/mfsbsd-10.1.img.gz raw
In legacy syslinux, the following configuration works:
Code:
LABEL mfsbsd
menu label mfsBSD
kernel memdisk
append initrd=images/mfsbsd-10.1.img.gz raw
 
Back
Top