public
Last active

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 PEX 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.

  • Download Gist
updatenetboot.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#!/bin/sh
#https://github.com/Dimtree
 
 
BOOTDIR=/var/tftp
 
[ $# -eq 0 ] && { echo "Usage: $0 arch" ; echo 'Try "i386" or "amd64"' ; exit 1; }
echo "Setting arch to "$1"..."
ARCH=$1
 
FWTMP=/tmp/d-i_firmware
 
echo 'Downloading Netboot Bundle...'
wget -q -O /tmp/netboot.tar.gz http://ftp.us.debian.org/debian/dists/stable/main/installer-$ARCH/current/images/netboot/netboot.tar.gz
 
#Clean the netboot dir, will fail if already empty
rm -r $BOOTDIR/* 2>/dev/null
 
#Extract the netboot image
tar xzp -C $BOOTDIR -f /tmp/netboot.tar.gz
 
#Prep a temp dir for the firmware
rm -r $FWTMP 2>/dev/null
mkdir -p $FWTMP/firmware
cd $FWTMP
 
echo "Downloading Firmware Bundle..."
wget -q -O firmware.tar.gz http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stable/current/firmware.tar.gz
 
#Extract it
tar -zxp -C ./firmware -f firmware.tar.gz
 
#Create a cpio bundle
pax -x sv4cpio -s'%firmware%/firmware%' -w firmware | gzip -c > firmware.cpio.gz
 
#cd to the initrd
cd $BOOTDIR/debian-installer/$ARCH
[ -f initrd.gz.orig ] || cp -p initrd.gz initrd.gz.orig
 
#Combine the bundles
cat initrd.gz.orig $FWTMP/firmware.cpio.gz > initrd.gz
 
echo "Done, cleaning up..."
rm -r /tmp/netboot.tar.gz $FWTMP initrd.gz.orig

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.