These are steps that I used on an Ubuntu 16.04.3 LTS (Xenial Xerus) 64-bit system to build an x86 Debian 9 (Stretch) live environment that I can boot from CD or USB

This article is periodically updated. So older user comments below may no longer be valid.

See other related articles here:

Warning: I have highlighted all the places you should be in the chroot environment. Be careful! Running some of these commands on your local environment instead of in the chroot can damage your system.

  1. Install applications we need to build the environment.

    sudo apt-get install \
        debootstrap \
        syslinux \
        isolinux \
        squashfs-tools \
        genisoimage \
        memtest86+ \
  2. Create a directory where we will store all of our files for creating the live environment.

    mkdir $HOME/live_boot
  3. Set up the base Debian environment. I am using stretch for my distribution and i386 for the architecture. Please change your mirror if you are not in the United States or if you know of a mirror closer to you. Consult the list of debian mirrors.

    sudo debootstrap \
        --arch=i386 \
        --variant=minbase \
        stretch $HOME/live_boot/chroot \
  4. Chroot to our Debian environment.

    sudo chroot $HOME/live_boot/chroot
  5. chroot

    Set a custom hostname for your Debian environment.

    echo "debian-live" > /etc/hostname
  6. chroot

    Figure out which Linux Kernel you want in your live environment.

    apt-cache search linux-image
  7. chroot

    I chose the image linux-image-686. I also believe live-boot is a necessity. systemd-sys (or an equivalent) is also necessary to provide init.

    apt-get update && \
    apt-get install --no-install-recommends \
        linux-image-686 \
        live-boot \
  8. chroot

    Install programs of your choosing, and then run apt-get clean to save some space. I use --no-install-recommends to avoid superfluous packages. You should decide what you need for your environment.

    Read Debian’s ReduceDebian article for tips on minimizing the size of your Debian environment if size is important.

    apt-get install --no-install-recommends \
        network-manager net-tools wireless-tools wpagui \
        tcpdump wget openssh-client \
        blackbox xserver-xorg-core xserver-xorg xinit xterm \
        pciutils usbutils gparted ntfs-3g hfsprogs rsync dosfstools \
        syslinux partclone nano pv \
        rtorrent iceweasel chntpw && \
    apt-get clean
  9. chroot

    Set the root password (root will be the only user in this live environment)

    passwd root
  10. chroot

  11. Make directories that will be copied to our bootable medium.

    mkdir -p $HOME/live_boot/image/{live,isolinux}
  12. Compress the chroot environment into a Squash filesystem.

    (cd $HOME/live_boot && \
        sudo mksquashfs chroot image/live/filesystem.squashfs -e boot
  13. Prepare our USB/CD bootloader. You should be able to copy and paste these lines into a terminal to save you some time.

    (cd $HOME/live_boot && \
        cp chroot/boot/vmlinuz-4.9.0-4-686 image/live/vmlinuz1
        cp chroot/boot/initrd.img-4.9.0-4-686 image/live/initrd1
  14. Create a menu for the isolinux bootloader. Create a text file at $HOME/live_boot/image/isolinux/isolinux.cfg with this content.

    UI menu.c32
    prompt 0
    menu title Debian Live
    timeout 300
    label Debian Live 4.9.0-3-686
    menu label ^Debian Live 4.9.0-3-686
    menu default
    kernel /live/vmlinuz1
    append initrd=/live/initrd1 boot=live
    label hdt
    menu label ^Hardware Detection Tool (HDT)
    kernel hdt.c32
    text help
    HDT displays low-level information about the systems hardware.
    label memtest86+
    menu label ^Memory Failure Detection (memtest86+)
    kernel /live/memtest

Create a bootable medium


Copy files necessary for the ISO to boot and then create the ISO

(cd $HOME/live_boot/image/ && \
	cp /usr/lib/ISOLINUX/isolinux.bin isolinux/ && \
	cp /usr/lib/syslinux/modules/bios/menu.c32 isolinux/ && \
	cp /usr/lib/syslinux/modules/bios/hdt.c32 isolinux/ && \
	cp /usr/lib/syslinux/modules/bios/ldlinux.c32 isolinux/ && \
	cp /usr/lib/syslinux/modules/bios/libutil.c32 isolinux/ && \
	cp /usr/lib/syslinux/modules/bios/libmenu.c32 isolinux/ && \
	cp /usr/lib/syslinux/modules/bios/libcom32.c32 isolinux/ && \
	cp /usr/lib/syslinux/modules/bios/libgpl.c32 isolinux/ && \
	cp /usr/share/misc/pci.ids isolinux/ && \
	cp /boot/memtest86+.bin live/memtest
genisoimage \
    -rational-rock \
    -volid "Debian Live" \
    -cache-inodes \
    -joliet \
    -hfs \
    -full-iso9660-filenames \
    -b isolinux/isolinux.bin \
    -c isolinux/ \
    -no-emul-boot \
    -boot-load-size 4 \
    -boot-info-table \
    -output $HOME/live_boot/debian-live.iso \

Now burn the ISO to a CD and you should be ready to boot from it and go.


Copy files necessary for the USB to boot and copy the environment to the USB drive (I am assuming you have an umounted FAT32 formatted USB drive /dev/sdz and the BOOT flag is set on /dev/sdz1 and you have a ready mount point at /mnt/usb)

sudo syslinux -i /dev/sdz1
sudo dd \
    if=/usr/lib/syslinux/mbr.bin \
    of=/dev/sdz \
    conv=notrunc bs=440 count=1
sudo mount /dev/sdz1 /mnt/usb

You should be able to copy and paste this block into a terminal to save you some time.

sudo cp /usr/lib/syslinux/modules/bios/menu.c32 /mnt/usb/ && \
sudo cp /usr/lib/syslinux/modules/bios/hdt.c32 /mnt/usb/ && \
sudo cp /usr/lib/syslinux/modules/bios/ldlinux.c32 /mnt/usb/ && \
sudo cp /usr/lib/syslinux/modules/bios/libutil.c32 /mnt/usb/ && \
sudo cp /usr/lib/syslinux/modules/bios/libmenu.c32 /mnt/usb/ && \
sudo cp /usr/lib/syslinux/modules/bios/libcom32.c32 /mnt/usb/ && \
sudo cp /usr/lib/syslinux/modules/bios/libgpl.c32 /mnt/usb/ && \
sudo cp /boot/memtest86+.bin /mnt/usb/memtest && \
sudo cp $HOME/live_boot/image/isolinux/isolinux.cfg /mnt/usb/syslinux.cfg && \
sudo cp /usr/share/misc/pci.ids /mnt/usb/ && \
sudo rsync -rv $HOME/live_boot/image/live /mnt/usb/

Now unmount the drive and you should be ready to boot from it and go.