HOWTO: create a PXE netboot debian-installer image with firmware files

Debian-installer is a great piece of software, which allows one to install the system in a variety of situations: manually, on a serial console, graphically, automatically, there are a number of scenarios it handles well.

However, there is one issue: when installing Debian to a machine that requires firmware just to get at the network, getting things to work can be a hassle. There is a tarball containing the most-often required firmware blobs in order to be able to use the installer on such systems; but since they fail the DFSG, these cannot be part of Debian, for political reasons. To use them, you need to write the required firmware packages to a directory "/firmware" on a USB stick or similar, and put that in the system when asked. This is acceptable when you have just one system to install and have a USB stick handy; but if you have a lot of systems to install, or (as recently happened to me) you don't have a USB stick handy, then things become slightly more problematic.

Luckily, there's an easy solution: you can update the initrd image so it contains the firmware packages already on it; when doing that, you don't need to deal with USB sticks anymore. Of course, using such an initrd image will cause the installer to automatically install all provided firmware packages, even if your hardware will function (at a basic level) without said firmware. Additionally, if you pass firmware packages to the installer in any way (through a USB stick, or through the method I'm about to describe, that makes no difference), and the installer determines that it might help to install one of these firmware packages, then the installed system will have them installed, and have the non-free repository enabled, which is not the default. Don't do this if you don't want that.

Anyway, on to the actual procedure now:

  • First, get yourself a "netboot.tar.gz" tarball from one of Debian's mirrors. This will get you a pxeboot.0 file, a set of pxeboot configuration files, a linux kernel file, and an initrd.gz file. It's the latter file that we need to modify
  • Create a directory where you'll unpack the initrd image, 'cd' to it, and run zcat path/to/initrd.gz | cpio -vi. This will unpack the initrd into your current directory. You can explore it if you want to see how debian-installer works, but other than that it's not very interesting.
  • Add a directory "firmware" in the top-level extracted directory that you just created.
  • Into this "firmware" directory, add all the firmware package files that you'll need.
  • Now, run find . | cpio -ov -H newc | gzip --best > path/to/initrd.gz.

Tadaa! You've now created an initrd image that will not ask you for firmware images, instead just install them.

An easier method
Actually, you can cat cpio files together. So you can create a new cpio archive which only has the firmware files, and then cat it onto the supplied initrd image (un-gzip it first of course).
Comment by puck (andrew@etc.gen.nz) Sun Feb 3 15:05:56 2013