3.4. Building a netboot image

The following sequence of helper commands will create a basic netboot image containing the Debian standard system without X.org. It is suitable for booting over the network.

Note if you performed any previous examples, you will need to clean up your working directory with the lh clean helper command:

$ lh clean --binary

Run the lh config helper command with the parameters to configure the "config/" hierarchy to create our netboot image:

$ lh config -b net --net-root-path "/srv/debian-live" --net-root-server "192.168.0.1"

In contrast with the ISO and USB hdd images, netbooting does not support serving a filesystem image with the client so the files must be served via NFS. The net-root-path and net-root-server options specify the location and server, respectively, of the NFS server where the filesytem image will be located at boot-time.

Now build the image with the lh build helper command:

# lh build

In a network boot the client runs a small piece of software, which usually resides on the EEPROM of the Ethernet card. This program sends a DHCP request to get an IP address and information about what to do next. Typically the next step is getting a higher level boot loader via the TFTP protocol. That could be Grub, PXELINUX, or even boot directly to an operating system like Linux.

For example, if you unpack the generated binary-net.tar.gz archive in the /srv/debian-live directory, you'll find the filesystem image in live/filesystem.squashfs and the kernel, initrd and PXE Linux bootloader in tftpboot/debian-live/i386.

We must now configure three services on the server to enable netboot:

DHCP server

We must configure our network's DHCP server to be sure to give an IP address to the computer netbooting, and to advertise the location of the PXE bootloader.

Here is an example for inspiration, written for the ISC DHCP server (package dhcp3-server) in the /etc/dhcp3/dhcpd.conf configuration file:

# Options DHCP spécifiques à Pxelinux:
option space pxelinux;
option pxelinux.magic      code 208 = string;
option pxelinux.configfile code 209 = text;
option pxelinux.pathprefix code 210 = text;
option pxelinux.reboottime code 211 = unsigned integer 32;


subnet 192.168.1.0 netmask 255.255.255.0 {   # 192.168.1.0/24

  # IP addresses available for guests
  range 192.168.1.100 192.168.1.149;

  # allow booting from the net
  allow bootp;

  # for net booting, server where the first file to be loaded (by TFTP
  # protocol) ("filename" following definition) lies : so the TFTP
  # server's name.
  next-server myserver;

  # net boot configuration for guests with a PXE client :
  if substring (option vendor-class-identifier, 0, 9) = "PXEClient" {
    # Note : all files for PXE are relatives to the TFTP server's root
    # path, as usually defined in /etc/inetd.conf.

    # PXE boot loader (first program to be loaded, by TFTP)
    filename "pxelinux.0";

    # describe some specific pxelinux's options through DHCP options :
    site-option-space "pxelinux";
    option pxelinux.magic f1:00:74:7e;
    if exists dhcp-parameter-request-list {
      # Always send the PXELINUX options (specified in hexadecimal)
      option dhcp-parameter-request-list = concat(option dhcp-parameter-request-list,d0,d1,d2,d3);
    }

    # For a PXE boot menu, different versions are available : simple
    # text, text with curses, graphic (VESA)
    #option pxelinux.configfile "pxelinux/config_simple";
    #option pxelinux.configfile "pxelinux/config_curses";
    option pxelinux.configfile "pxelinux/config_vesa";

    # automatically reboot after 10 minutes of no activity
    option pxelinux.reboottime 600;
  }
}

TFTPd server

This serves the kernel and initial ramdisk to the system at run-time.

You should install the tftpd-hpa package. It can serve all files contained inside a root directory, usually /var/lib/tftpboot/, as defined with its -s option. To let it serve files inside /srv/debian-live/tftpboot, modify its start definition in /etc/inetd.conf with:

tftp           dgram   udp     wait    root  /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /srv/debian-live/tftpboot -r blksize -v -v

and reload the super server with /etc/init.d/openbsd-inetd reload.

NFS server

Once the guest computer has downloaded and booted a Linux kernel and loaded its initrd, it will try to mount the Live filesystem image through a NFS server.

You should install the nfs-kernel-server package -- nfs-user-server does not function correctly with netboot.

Then, make the filesystem image available through NFS by adding a line like the following to /etc/exports:

/srv/debian-live *(ro,async,subtree_check,no_root_squash)

and tell the NFS server about this new export with the following command:

# exportfs -rv

Setting up these three services can be a little tricky. You might need some patience to get all of them working together. The Debian Installer Manual's TFTP Net Booting section might help as that process is very similar.