The Debian Project

Howto install Debian on a USB stick

Installing a GNU/Linux system on a USB stick is easy, but booting from a stick is not. The overall installation of the GNU/Linux system on the USB stick is similar to any other storage medium. Today USB sticks are recognised as /dev/sdX just like regular hard disks.

Since USB sticks tend to be slow it is wise to reduce disk access as much as possible. This is best done during the installation but can be done later as well if it is forgotton first.

You should select ext2 instead of ext3 and add both options noatime and relatime to the list of filesystem options. The rest of the installation is as usual. You might want to skip a swap partition, though.

After the installation is done, switch to the second console (using Alt-F2) to adjust the boot system. Switch to the installed system with chroot /target and edit /boot/grub/menu.lst using VI or any other editor you have installed already. You'll need to add rootdelay=8 to both kernel commandlines and to the kopt= line. This allows the initial ramdisk to to wait a few seconds until the USB stick is recognised as such before the root filesystem is mounted. Without this option Linux won't fine a root filesystem and will panic with a VFS error.

The Linux kernel names disk drives and usb sticks automatically. It is possible that sda on one system becomes sdc on another system. Therefore it is not reliable to keep such a setting on the kernel commandline. However, modern GNU/Linux systems create a unique UUID for every new filesystem.

For USB sticks that may be named differently on the next boot it is helpful to use the UUID instead of the device name. Therefore edit the menu.lst file again and exchange all occurrences of /dev/sda1 with UUID=XXX where XXX is what blkid /dev/sda1 emits as the UUID for the root filesystem. You should alter your /etc/fstab file as well.

With these few adjustments your Debian GNU/Linux system is able to boot off of a USB stick including X11 and GNOME or KDE.