Netbooting g4u via PXE

Mariusz Zynel , Nov 29, 2011

g4u is a great tool for backup/restore disks and partitions to/from a FTP server. I will try to explain how to setup a server to automatically boot g4u over a network.

Prerequisites

Required

Optional

Notes

In my setup I'm using ISC DHCP server but I believe it can be easily ported to any implementation of dhcp server. I'm working on Solaris 10 U6 x86 but it is not relevant here.

Settings

  1. Assume that TFTP server's root directory is /tftpboot
  2. Create /tftpboot/g4u directory and populate it with theses files:
    pxeboot_ia32.bin
    PXE boot loader from NetBSD distribution. The standard one (as of writing this) is not capable of reading boot.cfg which makes it impossible to automate booting g4u over the net. You probably need to build it yourself from sources.
    boot.cfg
    Configuration file of the PXE boot loader. It is taken from g4u ISO image and slightly modified:
    banner=Welcome to g4u 2.4
    banner================================================================================
    banner=
    banner=ACPI should work on all modern and legacy hardware, however if you have 
    banner=problems, please try disabling it.
    banner=
    menu=Boot g4u:load tftp:g4u/miniroot.kmod;boot tftp:g4u/netbsd
    menu=Boot g4u (no ACPI):load tftp:g4u/miniroot.kmod;boot tftp:g4u/netbsd -2
    menu=Boot g4u (no ACPI, no SMP):load tftp:g4u/miniroot.kmod;boot tftp:g4u/netbsd -12
    menu=Drop to boot prompt:prompt
    timeout=10
    
    netbsd
    The NetBSD kernel used by g4u. You can extract it from g4u ISO image.
    miniroot.kmod
    This module contains the actual g4u code. You can extract it from g4u ISO image. What is on g4u CD (that is in g4u ISO image) is gzipped miniroot.kmod. My experience is that it must be uncompressed otherwise PXE loader fails. I mean

    mv miniroot.kmod miniroot.kmod.gz; gunzip miniroot.kmod.gz

    nfs.kmod
    This is a standard NetBSD kernel module. You can get in from NetBSD binary distribution or build it yourself. This bit is optional. Without it PXE loader will complain after booting the kernel that it cannot load nfs module but you can ignore it.

    For your (in)convenience there is a complete set of these files for download here: g4u.tgz. It contains pxeboot_ia32.bin and nfs.kmod that I have build on my own from NetBSD-current sources as of 20.11.2011 with some minor tweak in src/sys/arch/i386/stand/pxeboot/Makefile. Files netbsd, boot.cfg and miniroot.kmod are taken from g4u ISO image. So, appropriate licenses apply.

  3. Configure DHCP server. Its configuration file should contain more or less this:
    allow booting;
    allow bootp;
        
    filename "g4u/pxeboot_ia32.bin";
    
    subnet 192.168.0.0 netmask 255.255.255.0 {
    	range 192.168.0.100 192.168.0.199;
    	option broadcast-address 192.168.0.255;
    	option subnet-mask 255.255.255.0;
    	option routers 192.168.0.254;
            next-server 192.168.0.254;
    }
    
    if substring (option vendor-class-identifier, 0, 17) = "NetBSD:i386:libsa" {
        if filename = "boot.cfg" {
            filename "tftp:g4u/boot.cfg";
        } elsif filename = "nfs" {
            filename "tftp:g4u/nfs.kmod";
        } else {
            filename "";
        }      
    }
    

    You can have a more complex settings but what is listed above is the minimum. The most important entries are:

    filename
    This is the path to boot loader program.
    next-server
    It contains the IP of TFTP server.
    if statement
    PXE loader always asks DHCP server about the file it is going to fetch. We need to answer pointing to our TFTP server.
  4. That's it. Try it out.

Notes

TFTP server is only required to hand PXE loader over the net to a client machine. The other files like: boot.cfg, netbsd, miniroot.kmod and even nfs.kmod can be loaded over NFS. In order to that you need one extra option in DHCP namely

option root-path "/tftpboot";

telling where the files are on the NFS server. PXE loader doesn't request that pathname from DHCP server explicitly so, we need to force DHCP server to provide that information any way:

append dhcp-parameter-request-list 17;

As you may know option code 17 is root-path. To fetch files over NFS instead of TFTP all the prefixes tftp: in boot.cfg and dhcpd.conf should be replaced by the prefix nfs:.

References

Acknowledgements

Thanks go to Hubert Feyrer, the author and maintainer of g4u, and to people from NetBSD project.


Copyright (c) 2011 by Mariusz Zynel.