Index ¦ Archives ¦ Atom

creating a multiboot usb drive for the debian installer (and others)

I like having a bunch of installers and live systems with me at any time, preferably all on one usb drive. Unfortunately the debian installer doesn't play well with others. Even when passing the iso-scan/filename boot parameter, the installer fails at the Detect and mount CD-ROM stage, when it tries to mount the iso and use it as a package repository.

To fix this, we will will patch the iso-scan package and recompile the Debian installer.

# You will need a clean build environment. Create a chroot
# of the release you want to build the installer for. In
# my case that's Debian Jessie.
debootstrap jessie ./jessie-installer-chroot http://deb.debian.org/debian/
cd jessie-installer-chroot
mount -t proc none proc/
mount -o bind /dev dev/
chroot .

After creating our desired build environment, we can install all build dependencies and get the source of the installer.

# add a deb-src line in /etc/apt/sources.list
apt-get update
apt-get source debian-installer
apt-get build-dep debian-installer
apt-get install fakeroot
# cd into the source directory debian-installer-*/
cd build/
# make sure the value of USE_UDEBS_FROM in config/common is
# matching your release.

Next we need to get the iso-scan udeb and unpack it. You can look for the udeb here.

wget http://ftp.de.debian.org/debian/pool/main/i/iso-scan/iso-scan_1.53_all.udeb
# now we need to edit the contents of the udeb
mkdir udebtmp
dpkg-deb -R iso-scan_1.53_all.udeb udebtmp
rm iso-scan_1.53_all.udeb

We have to edit udebtmp/DEBIAN/postinst. At the very end of the file, we are going to change the iso= variable and set it to the full path of the iso that we are going to place on our usb drive later on.

# iso=$(echo "$SELECTED_ISO" | sed -e 's/\[.*\] \(.*\) (.*/\1/')
iso="/isos/debian-8.11.0-amd64-netinst.iso"

We will will pack the changed files into a new udeb and place it in the localudebs/ directory.

dpkg-deb -b udebtmp iso-scan_1.53_all.udeb
mv iso-scan_1.53_all.udeb localudebs/

The only thing that's left is building the hd-media files.

# run make to get a list of possible targets.
make reallyclean
# we want to build the hd-media files, which we can then
# boot using Grub.
fakeroot make build_hd-media

The resulting hd-media files can be found in dest/hd-media/

For creating the multiboot usb i like to use the makeUSB.sh script from multibootusb, which should work with both legacy boot and UEFI. After running the script, I mount the partition that is not the EFI partition. I put the installer iso in isos/ and the hd-media files in hd-media/ in the root of the device. You can rename the files to make it more clear what they are for. In boot/grub/mbusb.d/debian.d I create a new file debian-installer.cfg with the following content:

menuentry "Debian 8.11 Installer" {
    search --no-floppy --fs-uuid --set=root ee5e-426e

    linux /hd-media/debian8.vmlinuz
    initrd /isos/debian8.initrd.gz
}

Make sure to adjust the UUID to the fs on your device. I deliberately put the iso in isos/ and not boot/isos/ as not to interfere with other configs in mbusb.d. If you want to add an iso that is supported by the project, like the debian live images, you can simply drop it in boot/isos/ and it should automatically pick it up and add an option to the Grub menu.

© Henryk Iwaniuk. Built using Pelican. Theme by Giulio Fidente on github.