Ubuntu USB boot (Ubuntu Live CD boot from USB)

DEVICE=/dev/sdb
ISO=ubuntu-16.10-desktop-amd64.iso
VOLUME=BOOTUSB
 
# install needed apps
sudo apt-get install -y syslinux mbr mtools dosfstools
 
# OPTIONALY format drive 
# sudo umount ${DEVICE}1
# sudo mkfs.vfat -n ${VOLUME} ${DEVICE}1
 
# install mbr and syslinux
mkdir /tmp/${VOLUME}
sudo mount ${DEVICE}1 /tmp/${VOLUME}
sudo install-mbr ${DEVICE}
 
sudo mkdir /tmp/${VOLUME}/boot
sudo syslinux -f ${DEVICE}1 -d boot
#sudo syslinux -f ${DEVICE}1
#sudo syslinux -smf ${DEVICE}1
 
sudo cp /usr/lib/syslinux/modules/bios/vesamenu.c32 /tmp/${VOLUME}/boot/
 
sudo mkdir /tmp/${VOLUME}/boot/${ISO%.*}
sudo cp ${ISO} /tmp/${VOLUME}/boot/${ISO##*/}
 
sudo mount ${ISO} /mnt/ -o loop
#sudo cp -a /mnt/.disk/ /tmp/${VOLUME}/boot/
sudo cp -a /mnt/casper/vmlinuz.efi /tmp/${VOLUME}/boot/${ISO%.*}/
sudo cp -a /mnt/casper/initrd.lz /tmp/${VOLUME}/boot/${ISO%.*}/
sudo umount /mnt
 
 
cat << EOF | sudo tee -a "/tmp/${VOLUME}/boot/syslinux.cfg"
default /boot/vesamenu.c32
TIMEOUT 100
 
LABEL ${ISO%.*}
MENU LABEL ${ISO%.*}
KERNEL /boot/${ISO%.*}/vmlinuz.efi
APPEND boot=casper initrd=/boot/${ISO%.*}/initrd.lz iso-scan/filename=/boot/${ISO%.*}/ubuntu-13.04-desktop-i386.iso --
EOF
 
sync
sudo umount /tmp/${VOLUME}
 
# TODO
# include DISTRO part from pxe boot

Links
http://wiki.ubuntuusers.de/Live-USB
Casper parameter (from live-helper package)
/usr/share/live-helper/templates/casper/parameters.txt
http://debian-live.alioth.debian.org/
http://www.pendrivelinux.com/usb-boot-cd-for-ubuntu-810/
http://wiki.ubuntuusers.de/Live-USB
https://help.ubuntu.com/community/mkusb