This is a handy hack that lets you install Ubuntu to a UsB key stick, so you can use it on just about any computer (provided the computer concerned can boot from USB—computers younger than about three years-old should be fine). This is ideal for situations where using a computer's permanent operating system might pose a security risk, such as in Internet cafes. You can even use it on computers that lack a hard disk.
Unfortunately there are a number of caveats. Running Ubuntu from a USB stick is slow, due to read/write speeds that are a fraction of those of standard hard disks (write speeds in particular). Additionally, you'll need a large USB key stick to make this work properly—at least 4GB— and the Ubuntu 8.04.1 install CD, or later, because there's a bug in the original 8.04 install CD that stops the new OS from booting correctly once installed.39 See Tip 31, on page 88, to see how to get an Ubuntu installation on smaller USB sticks, although a handful of compromises are necessary in that case.
Here are the steps involved to install Ubuntu on a USB key stick:
1. If possible, disconnect any hard disks in your computer while you carry out the installation onto the USB stick. This stops Ubuntu's setup routine from incorrectly referring to the USB key stick during boot menu configuration. Disconnecting the hard disk(s) can be done by opening up your computer and temporarily removing the data cable connected to the hard disk drive. If your drive is SATA, bear in mind that the smaller of the two cable connections is the data one—take a look at Figure 3.58, on the following page to see where the data cables connect on SATA and older EIDE hard disks.
39. The bug with the original Ubuntu 8.04 install CD causes the desktop to hang after you login when installing on a USB key stick. If you have no choice but to use the original install CD, the bug can be fixed by booting from the USB stick after installation, then switching to a virtual console before logging in. Kill the X server (sudo killall gdm), empty the /tmp folder (sudo rm -rf /tmp/") and manually start X (startx). Once the desktop appears, configure your network connection and update online. This will install new system software that fixes the bug.
If you have a notebook computer, it might be possible to temporarily remove the hard disk—consult the manual, where removing the disk might be described under the section describing upgrading it. You'll be able to reconnect the disks after the installation has finished.
However, if you can't disconnect the hard disks, don't worry too much—it just adds a little complexity to the issue and you'll have to perform a handful of extra steps later on (and also whenever a system upgrade brings a new kernel file).
2. Other than the step above, installing Ubuntu on a USB key stick doesn't differ much from installing it on any kind of storage device. Ensure the stick is inserted and start by booting from the Ubuntu
CD, selecting Install Ubuntu from the boot menu.
3. When Ubuntu starts, work through the usual questions and prompts until you reach the partitioning stage. Then select Guided - use entire disk and click the radio button alongside your USB key stick. You should be able to identify it by brand and model, as well as its capacity, which will be a lot less than the hard disks installed in your computer (or it might simply be identified as USB DISK). If you've disconnected your hard disks for the duration of the installation then there will only be one option here. Once done, click the Forward button.
4. Again, follow through the installation procedure, creating your new user account when prompted, until you reach Ready to install summary screen. If you've disconnected your hard disks then simply click the Install button to start the installation. If the hard disks are still connected, click the Advanced button. In the dialog that appears, click the dropdown list under the Device for boot loader installation heading and again look for the entry referring to your USB key stick. However, select the entry beneath it in the list—it will be identical to the entry for the key stick but have a 1 after it (in other words, the first partition on the memory stick). For example, on my computer the memory stick was identified as /dev/sdb Easy Disk (7.5GB), and I therefore selected the entry under this— /dev/sdb1. See Figure 3.59, on the next page for an example. Once done, click the OK button, and then the Install button in the parent dialog.
5. If you installed Ubuntu without the hard disks connected, once installation has finished you can now shutdown the computer, reconnect the drives, and then boot the computer from the USB stick to test everything. Don't forget that some computers have to be manually configured to boot from USB—this can normally be done by hitting the [Esc] during initial self-testing to see a boot device menu, or by changing a setting in the computer's BIOS setup screen.
6. If you installed Ubuntu to a USB disk with the hard disks connected, one more step is necessary before you can boot from the USB stick. Reboot the computer using the Ubuntu installation CD and select the Try Ubuntu option. Once the desktop appears, click the USB stick's entry on the Places menu to ensure it's mounted and that its files are available—you should be able to identify it on
the Places menu by its size.
7. You now need to ensure that the USB stick's boot menu correctly refers to the USB key drive and this involves editing the boot menu file. You will need to repeat this step whenever Update Manager installs a new kernel update because the update process will rewrite the boot menu. Open a terminal window and type the following to open the menu.lst file on the USB key stick:
$ gksu gedit /media/disk/boot/grub/menu.lst
Look for the line that reads ## ## End Default Options ## and look almost immediately underneath for a line beneath it for the first line that reads root (hd1,0) (or similar—the first number might be different on your computer if you have more than one hard disk installed). Change it to read root (hd0,0). Although not essential, you might want to change the two other identical lines in the boot menu entries beneath so they say the same thing (ie root (hd0,0)). These refer to the Ubuntu rescue boot option and memtest86+. You might also want to delete everything that appears beneath the line that reads ### END DEBIAN AUTOMAGIC KERNELS LIST, so that it then becomes the last line, because these are effectively useless boot menu entries added by the Ubuntu installer that refer specifically to the PC configuration used to create the USB Ubuntu installation. Once done, save the file and close Gedit.
Following this you should be able to reboot from the USB key stick. Again, keep in mind that some computers have to be manually configured to boot from USB—this can normally be done by hitting the (Esc) during initial self-testing to see a boot device menu, or by changing a setting in the computer's BIOS setup screen.
Was this article helpful?