Introduction
It is possible to have Ubuntu or Kubuntu on a USB drive (AKA USB Stick or Thumb drive or Flash drive) or USB hard disk drive with persistent mode. This means that you can boot from a USB drive and keep customisations such as keyboard layout, numlock, preferences, additional packages saved on the drive. This can be done using linux or windows. You will need a USB drive of 1 GB or more. This page is written after having tested the instructions on a Peak III 1 GB drive. The preparation of the drive is explained using 'fdisk' because I had errors with 'gparted' and i could not give the partitions a volume name. I used Ubuntu to make the drive. In Kubuntu it is more or less the same. Where you see 'ubuntu' replace it by 'kubuntu'. I will mark the other differences.
If you are looking for help in putting the 'alternate' cd on a pen drive, then try the instructions here: . They're for feisty, but more or less work for gutsy too. Note that you may need to add "vesa vga=771" to the append= line in syslinux.cfg in order to get the installer to display properly.
Method 0: Automatically create Live USB system
Live USB creator (GUI-based, runs from Live CD)
Live USB creator automates the process of creating a bootable Live USB system from a running Ubuntu Live CD. Simply run the Live CD, install the tool and start the Live USB installation from the System administration menu.
-- probono
(A better link: which explains that you run the livecd and the you click on the link: )
{}
Method 1: Installing Ubuntu directly to USB drive from installer CD
You can directly install Ubuntu 8.04 Hardy Heron to a USB drive using the Live CD. Simply select the USB drive as the installation target instead of the local hard disk.
Note: This will use the USB drive for /tmp, which will cause extra wear on the flash memory. If you're booting from a system with enough RAM, it would be more desirable to use a tmpfs in RAM for /tmp, in which case you'd want to copy the ISO CD image to the USB drive and add a persistent partition (see next section). On the other hand, if you're not concerned with your USB drive wearing out (lifetime warranty, wear leveling, etc), continue in this section.
Ensure in the "Installation Summary" screen that you choose to install GRUB to the USB key stick, and not the computer's hard disk (click the Advanced button to do so). Choose to install GRUB to the first partition (i.e. /dev/sdb1, rather than simply /dev/sdb [not sure about this]). Failure to do this will cause the GRUB on your hard disk to be changed and render the system unbootable from the hard disk, requiring you to boot from a CD and reinstall GRUB to the hard disk (possibly requiring a chroot to the hard disk filesystem first).
You will also need to manually edit the menu.lst file of the new USB installation to change the boot references to /dev/sda, rather than /dev/sdb (or /dev/sdc etc.). This can be done by booting to the live distro mode of the Ubuntu install CD and editing the /boot/grub/menu.lst file on the USB stick. You can mount the USB stick using the Places menu -- once mounted, it can be found at /media/disk. Note: This step may not always be necessary.
Note: There is a bug with the Ubuntu 8.04 install CD that means USB key stick installs are screwed -- the desktop won't appear when you login. To get around this, you must do the following when you boot for the first time (before logging in at GDM):
1) switch to a virtual console (Ctrl+Alt+F2)
2) kill the X-server (sudo killall gdm)
3) empty the /tmp folder (sudo rm -rf /tmp/*)
4) Type startx, and perform a system update when the desktop appears (if you don't want to install a lot of software, just update the gnome-keyring package(s) -- that's the one that causes the problem)
Note that this should be fixed in the Ubuntu 8.04.1 install CD.
Method 2: Copying the ISO CD image to the USB drive
Preparing the USB drive
8.04 Hardy: Unfortunately, there is a in the versions of casper in Hardy that cause the persistent partition to not be mounted on boot. There is a available, and you can download a for 8.04.1 (place in casper directory on first partition of USB key).
Good news! It IS possible to make Feisty persistent! These instructions are needed but not sufficient. Check this. Essentially, you need to decompress initr.gz (with gzip and cpio); edit the init file adding a case called 'persistent' (see details at the link) and recreate initr.gz. I guess that without this case, the 'persistent' passed in the syslinux.cfg is simply ignored. I got persistence at the first attempt. Elfantin
Making partitions
The preparation of the drive is explained using 'fdisk'. You could use 'gparted' or 'qtparted' as well. However I had errors with 'gparted' and I could not give the partitions a volume name. I tested 'qtparted' as well and it worked fine. You can install 'qtparted' under Ubuntu through synaptic although it is native to Kubuntu. Another issue in my case was that 'fdisk' recognised a fat32 filesystem as linux. So I checked it with gparted and it was OK.
Plug in the drive and check its device name:
mount
Assuming you have your Ubuntu set up to automatically mount your USB stick, this should show you what /media/drive or whatever it's called corresponds to on the device level.
Alternatively, you could run
sudo fdisk -l
but if you have multiple devices on your system, it will print a fair amount of fairly technical information.
We are going to suppose that its name is /dev/sdX where X is the disk device such as /dev/sda or /dev/sdc. Please be sure to use the correct number for X which matches the name you find for your pen drive. Double check it! [Note: on newer computers, which use serial ATA disks, /dev/sda is typically the main hard drive; do not overwrite this!]
Note: on some usb-sticks fdisk says "Note: sector size is 2048 (not 512)", in which case you may very well be out of luck trying to boot from it, see mailing list thread: