aptosid netboot introduction

Warning

dnsmasq includes a dhcp server which can conflict with an existing dhcp server on your network (such as your router might provide). The safest option is always to only use one dhcp server on any network which means disabling any other dhcp servers on the same network. The dnsmasq proxy options outlined below should be able to co-exist with another dhcp server on the same network but please do not try this unless you administer the network and are ready to deal with any unforeseen consequences which might crop up.

Basics

Network booting anything first requires that you have a machine capable of network booting which can connect via a network you run to a machine which you can setup to offer the netowrk booting services. You do not want to do this on your work network, or any other network you do not control, unless you run that network (or get permission and guidance from those who do). If you are co-operating in a larger network you can investigate all the options to dnsmasq (such as limiting the interfaces it listens on or the clients it will respond to) to restrict the impact of your setup on the network.

Prerequisites

This assumes you have downloaded a 2009-04 (or newer) aptosid iso, booted it and are going to use it as the network boot server. The instructions should be basically the same with any up to date aptosid or debian sid machine and should provide all the clues you need to use other systems (Linux is probably required to serve nbd devices). dnsmasq provides everything for the initial booting phases, though it shouldn't be hard to translate the required knowledge to other software.

Install

apt-get install nbd-server dnsmasq

Setup

nbd-server

Presuming the iso can be found at /dev/scd0 (which it probably can be if you booted from cd otherwise substitue in any suitable file or device) then you can setup a nbd-server conf file called nbd-aptosid.conf with a section called aptosid-iso to export the cd on port 9040 by running the following.

echo '[generic]' > nbd-aptosid.conf
nbd-server 9040 /dev/scd0 -o aptosid-iso >> nbd-aptosid.conf
The generic header is always required but if you want to setup the nbd-server to work automatically on a real system you will probably want to setup /etc/nbd-server.conf instead. There are a lot more options to nbd-server then shown here, see man nbd-server.

To actually start the server now as a normal user and without bothering setting up or copying the file to /etc/nbd-server.conf you can just run:

nbd-server -C nbd-aptosid.conf

dnsmasq

Now we get into the complicated network issues. To show a possibly working config this assumes you are running on a simple network where your machine has one ethernet connection which is setup by dhcp from another machine which the network boot clients can use to setup their interfaces by dhcp.

The main relevant options for dnsmasq to network boot aptosid are to setup a path for the tftp server and a file for it to boot from there. The tftp directory for booting is /home/tftp so change that below if you want. Put the following into a file called /etc/dnsmasq.d/pxe-aptosid.conf

dhcp-range=0.0.0.0,proxy
pxe-service=x86PC, "boot linux", pxelinux
enable-tftp
tftp-root=/home/tftp
tftp-secure
For a network (e.g. 192.168.0.*) with no other dhcp server you could swap the first two lines for:

dhcp-range=192.168.0.100,192.168.0.199,1h
dhcp-boot=pxelinux.0
to give out ip addresses starting with 192.168.0.100 and ending with 192.168.0.199 with a lease time of an hour, and to give the filename to just run pxelinux.0 as part of the dhcp request (when using the proxy you instead provide a pxe menu with only pxelinux as an entry which will therefore automatically start it).   This probably won’t setup your network as you wish though unless your dnsmasq server should also be your dns server and gateway for the boot clients.

To enable the new file you will need to uncomment the conf-dir setting at the bottom of /etc/dnsmasq.conf and then restart dnsmasq.

dnsmasq has a lot of options and can act as a dns server as well as a dhcp, pxe and tftp server. The above is simply a minimal outline of the pieces needed to use pxelinux with gfxboot to boot aptosid.

tftp

tftp is the network equivalent of the boot directory. Having specified /home/tftp above, create and populate it now. Assuming the cdrom is mounted on /fll/scd0:

mkdir /home/tftp
cp /fll/scd0/boot/isolinux/* /home/tftp
mkdir /home/tftp/pxelinux.cfg
mv /home/tftp/isolinux.cfg /home/tftp/pxelinux.cfg/default
mkdir /home/tftp/boot
cp /fll/scd0/boot/vmlin* /fll/scd0/boot/initr* /fll/scd0/boot/memtest* /home/tftp/boot/
cp /usr/lib/syslinux/pxelinux.0 /home/tftp/
# required for the tftp-secure option to dnsmasq
chown -R dnsmasq.dnsmasq /home/tftp/*
Now you can edit boot options to your hearts content in /home/tftp both the pxelinux.cfg/default and the gfxboot.cfg file. Under the [install] section you probably want to set the install= to install=nbd , the install.nbd.server to the servers ip on the network the client will access it by and the install.nbd.port value to the one set when you created you nbd-server. Alternatively you could disable the F3 menu completely and edit the kernel command lines to use something like:

fromhd=/dev/nbdroot root=/dev/nbdroot nbdroot=192.168.1.23,9040

Boot

As long as your bios supports booting from the network, you can trigger it to try, the machine is connected to the network with your server and the aptosid kernel and initrd.img support your network card you should be able to boot aptosid from the network. Some network cards may require firmwares which will require rebuilding the initrd image to include the firmwares which is outside the scope of this document. You can still access the nbd system booting from cd or hd and likewise can boot to a aptosid squashfs system on a cd/hd from the network.

Tips

If you add toram to the boot options, machines with enough ram will release the server as soon as they copy the file and machines without sufficient ram will carry on and boot normally.

The target of the nbd-server does not have to be an iso or cd/dvd, it just has to contain a suitable filesystem image.