For people who are new to Debian, it might be useful to have a convenient way to try out the different desktop environments before deciding for one. This article explains how to create a USB stick that boots all Debian desktops as live systems.

In a directory do:

mkdir -p root/boot/grub/
mkdir -p root/boot/iso/

And create root/boot/grub/grub.cfg with the following content:

set timeout=30
set default=0

menuentry "Boot from First HD (default)" {
  chainloader +1

insmod regexp

for isofile in /boot/iso/debian-live-*-amd64-*.iso; do
  regexp --set=isoname "/boot/iso/(.*)" "$isofile"
  submenu "$isoname ->" "$isofile" {
    loopback loop "$iso_path"
    menuentry 'Live (amd64)' {
      bootoptions="findiso=$iso_path boot=live components quiet splash"
      linux (loop)/live/vmlinuz $bootoptions
      initrd (loop)/live/initrd.img
    menuentry 'Live (amd64 failsafe)' {
      bootoptions="findiso=$iso_path boot=live components memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal"
      linux (loop)/live/vmlinuz $bootoptions
      initrd (loop)/live/initrd.img

Now you can populate root/boot/iso/ with any live image of your choice. They just have to match the glob debian-live-*-amd64-*.iso.

Finally run the following command to create the disk image for the USB stick:

grub-mkrescue -o boot.iso root

You can now transfer boot.iso either to a USB stick or to an optical medium.

It doesn't seem to be possible to also enable installation directly from the USB stick. So after a choice has been made, another USB stick is needed with the desired ISO copied to it.

It should be able to replace grub-mkrescue with manual invocation of grub-mkimage and then concatenating the result with /usr/lib/grub/i386-pc/cdboot.img and /usr/lib/grub/i386-pc/boot.img and finally calling genisoimage or xorriso but I was unable to do so.