In few weeks, I’ll have to upgrade our 2 clusters from old customised redhat 7.3 linux to FreeBSD 6-STABLE. The preliminary tasks are already done: applications are now FreeBSD friendly, they have been ports-ified too, config files are ready to be deployed. It sounds really good doesn’t it? But I have a big constraint: I have to install one of the clusters in 3 hours. The only way to install ten servers in this timeframe is to use PXE. I already use PXE for basic installations, but here I must install ready-to-go servers. The cluster is also made of 3 different kinds of servers. I need to support different NICs, types of disk and even set up software RAID on one box. How can I do with our PXE stuff? I was dreaming of kickstart for FreeBSD ;-) I was thinking about patching sysinstall, but I’m too lazy :-) Let’s cheat!

(you can download a tarball with files and scripts here. Warning ! it’s quick and dirty !)


  • FreeBSD source of the desired version
  • A FreeBSD ISO image
  • a Web and a FTP servers
  • a working PXE installation (Ceri’s post on PXE)

Basically, the idea is the to fetch a configuration file at the begining of sysinstall process, load it into sysinstall, commit install, fetch a post-install script and finally run it.

  1. Cook mfsroot (please read Ceri’s post to know how to play with it)
    First of all we have modify the mfsroot image to add fetch(1), our install.cfg and a simple script to fetch/configure our sysinstall.
    To add fetch, we need to regenerate boot_crunch to support fetch, like this one: pxe_crunch.conf.
    mkdir crunch

    cd crunch
    crungen pxe_crunch.conf
    make -f
    cd ..
    Mount mfsroot in a directory called mfsfd. Now we repopulate /stand with our new mfsfd/stand
    rm *
    install 755 ../../crunch/pxe_crunch .
    for i in $(crunchgen -l ../../pxe_crunch.conf); do ln pxe_crunch ${i} ; done
    install -m 755 /sbin/dhclient-script .
    Now we install our small install.cfg and the script fetch
    chmod +x
    cd ..
    mkdir -p var/db tmp var/run

    Umount mfsroot and copy it in you boot/ directory in your nfs share.
  2. Populate web server
    On your webserver, install pxe.conf and
    mkdir ${DOCUMENTROOT}/pxeinstall

    Edit those files to suit your needs.
    vi pxe.conf

    If you want to install FreeBSD via the interface PXE used, keep %%IFNAME%% as netDev value.
    Currently disk support is not yes available. It will be supported soon. is executed in post-install stage so you can use previously installed stuff, like perl or so. It’s a live system so beware :)
    Note: don’t put stuff in /etc/rc.conf, it will be commented out. Use /etc/rc.conf.local instead.
    Note 2: you can put those file on the FTP server instead.
  3. Populate FTP server
    mkdir ${FTPROOT}/pub/FreeBSD/releases/i386/
    tar xvf /path/to/6.1-RELEASE-i386-disc1.iso 6.1-RELEASE ${FTPROOT}/pub/FreeBSD/releases/i386/
  4. Edit boot/loader.rc
    We use loader.rc to set 2 variables: pxe_conf_url and pxe_post_install_script_url.
    Your loader.rc shoud look like this:
    load /boot/kernel/kernel
    load -t mfs_root /boot/mfsroot
    set vfs.root.mountfrom=”ufs:/dev/md0c”
    set pxe_conf_url=””
    set pxe_post_install_script_url=””
  5. The end
    Boot your machine via PXE and it should be ok :-)

The future is to replace hard-coded pxe.conf et for a php script to generation config file/script on the fly. should be improved to make gmirror configuration, nss stuff, and more (like data restoration via bacula for example). I’ll surely add more functions when it get rewriten.

FYI, I use my own FreeBSD release, packages are built in marcuscom tinderbox and a script to generate INDEX file. I also use a meta-port to avoid polluting pxe.conf.

See ya for part II… if any :-)

0 Kommentare zu “PXE for lazy sysadmins (part I – proof of concept)”  

  1. No Comments

Kommentar hinterlassen

Log-In | Wordpress | Cappuccino