This is a follow up to the previous article. I will briefly describe a way to boot Debian installation ISO image from USB flash drive using
syslinux bootloader.

This task requires more work then previously described Ubuntu or Clonezilla ISO, so I decided to write these instructions separately. It requires a little bit of Linux knowledge, but you can use these to boot Debian netinst CD or regular Debian DVD #1.

If you do not need to boot it from USB flash drive using custom boot menu then just use basic dd utility. Otherwise, I will save you some time and describe the whole process.

Step A

Perform steps described last week at How to create bootable USB flash drive.

Step B

Download Debian netinst ISO image from https://www.debian.org (debian-8.2.0-amd64-netinst.iso in this example) and store it inside /media/usb/images/ directory.

Step C

Create directory for initial boot loader image using text mode.

$ mkdir /media/usb/boot/debian-netinst-text

Change working directory and download required initrd image and Linux kernel.

$ cd /media/usb/boot/debian-netinst-text
$ wget http://ftp.debian.org/debian/dists/jessie/main/installer-amd64/current/images/hd-media/initrg.gz
$ wget http://ftp.debian.org/debian/dists/jessie/main/installer-amd64/current/images/hd-media/vmlinuz

Create directory for initial boot loader image using graphical mode.

$ mkdir /media/usb/boot/debian-netinst-gtk

Change working directory and download required initrd image and Linux kernel [hd-media].

$ cd /media/usb/boot/debian-netinst-gtk
$ wget http://ftp.debian.org/debian/dists/jessie/main/installer-amd64/current/images/hd-media/gtk/initrg.gz
$ wget http://ftp.debian.org/debian/dists/jessie/main/installer-amd64/current/images/hd-media/gtk/vmlinuz
Step D

Get the UUID of the USB flash drive to uniquely identify it.

$ sudo blkid /dev/sdc1
/dev/sdc1: UUID="159ec37e-19e4-478d-b603-f06d041a41cf" TYPE="ext4" PARTUUID="5110c451-01"
Step E

Modify initrd image to use specific device and ISO image.

Create temporary directory.

$ mkdir /media/usb/boot/debian-netinst-text/custom_initrd

Change working directory.

$ cd /media/usb/boot/debian-netinst-text/custom_initrd

Extract initrd.

$ gzip -d < ../initrd.gz | cpio --extract --verbose --make-directories --no-absolute-filenames

Edit iso-scan.postinst shell script.

$ sudo vi /media/usb/boot/debian-netinst-text/custom_initrd/var/lib/dpkg/info/iso-scan.postinst

Modify use_this_iso function call (near the end of file) to use specific ISO image and device. You should also simplify main loop to speed-up the whole process. Simple devices names like /dev/sdc1 cannot be used due to unpredictable hardware configurations.

[...]
# iso-scan is divided in following stages:
# 1  : get list of devices (no debconf question)
# 2/3: select a device (or all detected ones)
# 4/5: parse selected devices looking for Debian ISOs and let choose one
# This conf script is capable of backing up
db_capb backup
modprobe ext4 >/dev/null 2>&1 || true
modprobe loop >/dev/null || true
mkdir /cdrom 2>/dev/null || true
mkdir /hd-media 2>/dev/null || true
iso="/images/debian-8.2.0-amd64-netinst.iso"
device="/dev/disk/by-uuid/159ec37e-19e4-478d-b603-f06d041a41cf"
log "Selected ISO: $iso on $device"
use_this_iso $iso $device
exit 0

Store modified initrd image.

$ find . | cpio -H newc --create --verbose | sudo gzip -9 > ../initrd.gz

Delete temporary directory.

$ cd ..
$ rm -r custom_initrd

Repeat these steps for graphical mode.

Step F

Create menu entry to boot

MENU BEGIN Debian
  MENU TITLE Debian
  LABEL -
    MENU LABEL Debian 64bit netinstall:
    MENU DISABLE
  LABEL debian_netinstall_amd64_text
    MENU LABEL text mode
    MENU INDENT 1
    LINUX /boot/debian-netinst-text/vmlinuz
    APPEND vga=788 initrd=/boot/debian-netinst-text/initrd.gz --- quiet
  LABEL debian_netinstall_amd64_gtk
    MENU LABEL graphical mode
    MENU INDENT 1
    LINUX /boot/debian-netinst-gtk/vmlinuz
    APPEND vga=788 initrd=/boot/debian-netinst-gtk/initrd.gz --- quiet
MENU END

Boot USB flash drive and verify boot process.

ko-fi