Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A little script to generate a debian netboot image and automatically integrate the latest firmware bundle.Requires pax (apt-get install pax) and a working PXE setup. Change the variable BOOTDIR to suit your needs. Still in development, would recommend double checking to make sure it won't do anything harmful to your setup.
# V2 (This one actually works!)
# (I put the preseed.cfg file in /firmware. Don't ask.)
TMP=$(mktemp -d)
[ $# -eq 0 ] && { echo "Usage: $0 arch" ; echo 'Try "i386" or "amd64"' ; exit 1; }
echo "Setting arch to "$1"..."
wget -qO $TMP/netboot.tar.gz$ARCH/current/images/netboot/netboot.tar.gz
rm -r $BOOTDIR/*
tar xzp -C $BOOTDIR -f $TMP/netboot.tar.gz
mkdir -p $TMP/firmware
wget -qO $TMP/firmware.tar.gz
tar -zxp -C $TMP/firmware -f $TMP/firmware.tar.gz
echo "default /debian-installer/$ARCH/linux" > $BOOTDIR/pxelinux.cfg/default
if [ -f $PRESEED ]
echo "Preseed file found at $PRESEED"
cp $PRESEED $TMP/firmware
echo "append initrd=/debian-installer/$ARCH/initrd.gz locale=en_US keymap=us auto preseed/file=/firmware/preseed.cfg --">> $BOOTDIR/pxelinux.cfg/default
echo "No preseed file found at $PRESEED"
echo "append initrd=/debian-installer/$ARCH/initrd.gz --">> $BOOTDIR/pxelinux.cfg/default
cd $TMP; pax -x sv4cpio -s'%firmware%/firmware%' -w firmware | gzip -c > $TMP/firmware.cpio.gz
[ -f $BOOTDIR/debian-installer/$ARCH/initrd.gz.orig ] || cp -p $BOOTDIR/debian-installer/$ARCH/initrd.gz $BOOTDIR/debian-installer/$ARCH/initrd.gz.orig
cat $BOOTDIR/debian-installer/$ARCH/initrd.gz.orig $TMP/firmware.cpio.gz > $BOOTDIR/debian-installer/$ARCH/initrd.gz
rm -r $TMP
chown tftp:tftp $BOOTDIR
chmod -R 755 $BOOTDIR

Dimtree commented May 9, 2014

  • Will now automatically include ./preseed.cfg, and update kernel parameters accordingly.
  • Will now actually use a single temp dir (yay!)
  • Made it cleaner and quieter

TODO: move the preseed.cfg somewhere other than the firmware directory.
TODO: option to change mirrors, releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment