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 respectfully of the NFS server where the filesytem image will be located at boot-time.

Now build the image with lh_build helper command:

# lh_build

In a network boot, the client runs a small piece of software, usually on the EEPROM of the Ethernet card, which sends a DHCP request to get an IP address and also information about what to do next; such as getting (through TFTP protocol) a higher level boot software like Grub or PXLINUX, or directly to an operating system like Linux.

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

We must now configure three services on the server:

DHCP server

We must configure our network's DHCP server to be sure to give a 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 serves 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 will have downloaded and booted a Linux kernel and its initrd, it will try to mount the Live filesystem image through a NFS server.

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

Then, declare that the directory of the filesystem image is available through NFS, by writing in /etc/exports :

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

and let the NFS server knowing it typing following command :

# exportfs -rv

Setting all these services is quite error prone, you'll need some patience to let all of them working together.