Kubuntu / Ubuntu from USB stick

The idea is to use create a bootable USB stick (instead of a CD) where you can boot or install Kubuntu from. This is useful for laptops without a CDROM/DVD drive, like the EeePC.

The guide at https://help.ubuntu.com/community/Installation/FromUSBStick did not work for me. In fact the basic command

syslinux -s /dev/sdb1

(where sdb1 is a FAT16 or FAT32 partition on a USB stick) produced a USB stick that did not boot. It just hung, where it supposed to give a boot prompt. The graphical programs were all based on this, so I decided to try something else.

Fortunately I found a Gentoo guide which helped me a lot: http://en.gentoo-wiki.com/wiki/Gentoo_minimal_CD_on_USB_stick. They use an ext2 partition instead of a FAT partition. This works.

Here is what I did. First become root:

sudo su

Determine which device is your USB stick:

fdisk -l

Assuming that the USB stick is on /dev/sdb, use the following command to erase it and start the partitioner:

dd if=/dev/zero of=/dev/sdb count=1024
fdisk /dev/sdb

Within fdisk, use these commands to create a bootable Linux partition:

n p 1 enter enter
a 1
p
w

Then proceed with the following commands:

mke2fs /dev/sdb1
tune2fs -i 0 /dev/sdb1
aptitude install syslinux extlinux
cat /usr/lib/syslinux/mbr.bin > /dev/sdb
mkdir /src /dst
mount -t iso9660 -r -o loop /path/to/kubuntu.iso /src
mount -t ext2 /dev/sdb1 /dst
cd /dst
cp -a /src/. .
mv -i isolinux extlinux
cd extlinux
mv -i isolinux.cfg extlinux.conf
rm isolinux.bin
cd /
extlinux -i /dst/extlinux
umount /src
umount /dst
rmdir /src /dst

That's it! Reboot and change the boot priority on the BIOS setup screen.