How to run Linux from a USB drive

Once you have your Linux installation, you can do with it as you please. But we'd recommend you make some or all of these simple changes to make it truly feel like home:

Add your own user. Running under the Live session user will get old sooner or later, so create your own user and home directory, and make sure you give it the "administer the system" privilege.

Set a strong password for yourself, and/or the root user. Lots of people hate the way Ubuntu insists on using sudo – if you're one of them, run sudo bash, enter your password, then type passwd to set the root password yourself. After that, su works fine.

Delete the 'Install' item from the desktop. If you want to use your stick to install custom Ubuntus around the office, you'll want to keep this; otherwise, bin it and don't look back.

Customise the software. Replace OpenOffice.org with AbiWord if you want to, or get your favourite coding tools in place.

Update, update, update: you have a real Linux system now, which means staying up to date with patches and other updates.

It's important to remember that as you make changes from the default installation, you are possibly straying away from what makes the Live CD so darn useful in the first place. For example, if you configure it to automatically use a specific X.org configuration your graphical display (perhaps to enable 3D hardware acceleration on Nvidia cards using a proprietary driver), it may mean that your flash drive Ubuntu won't work so well on other machines.

Yes, Ubuntu is supposed to have a failsafe X.org mode that switches to a standard VESA-compatible resolution when it encounters problems, but we find that rarely works when we need it!

Installing to USB

Although the Live USB method of installing Ubuntu is the easiest and safest, there is one good alternative: when you're installing Ubuntu from a CD-ROM, slot in your flash drive and choose that as the installation target. The problem, as mentioned earlier, is that it will wear down your flash drive with unnecessary writes, and the solution here is to edit your /etc/fstab file so that it uses tmpfs (otherwise known as a RAM disk) for the /tmp directory. For example:
tmpfs /tmp tmpfs nosuid,nodev 0 0

If you have enough RAM you should be able to do without swap entirely, which neatly sidesteps this problem.

Do it with Fedora

Fedora 9 introduced the first high-quality USB installation system, but the main advantage of it is that it has a special Windows version, so even non-Linux users can get it in on the act.

Ubuntu does have one advantage here, which is that it gives you the ability to choose any size for your documents area, whereas Fedora limits you to just 2GB regardless of the size of your flash drive. That is mitigated somewhat by the fact that your flash drive is still a normal flash drive – you can store files outside of the Linux area as you normally would, then read them in from there. It only really becomes an issue if you intend to install a great deal of software.

If you want to run the Live USB Creator from Windows XP, you'll need to have:

  • Windows XP
  • The Fedora Live USB Creator app
  • A Fedora 9 ISO image
  • A 2GB or larger flash drive

If you want to run it from Linux, you'll need:

  • EITHER: Fedora 9 and the Fedora Live USB Creator app.
  • OR: Fedora 10 with the liveusb-creator package installed.
  • A Fedora 9 ISO.
  • A 2GB or larger flash drive.

One of the nice features of the Fedora LiveUSB Creator is that it is non-destructive, meaning that any data on your flash drive is left intact. Fedora also uses Grub rather than ISOLinux as its bootloader, which means you can boot, test and work with your Fedora flash drive straight from a virtual machine using a command line like this:
qemu –hda /dev/sdb

You'll obviously need enough RAM to run both your host operating system and the guest Fedora flash install, and you'll probably want to have the KQemu kernel module installed to make Qemu run at an acceptable speed!

Installing Fedora from Linux

Because the Fedora Live USB Creator is written using Python and Qt, it's completely cross-platform – that Windows program runs just the same on Linux, albeit with a few dependencies that need to be sorted out first.

To get started, go to System > Add/Remove Software, then install both PyQt 4 (you don't need to the –devel packages), and SysLinux. Once that's done, pop in your LXF coverdisc from this issue and browse to the System folder, where you should find the Live USB Creator RPM file. Run this as root:
rpm –i liveusb-creator-2.7.1.fc9.noarch.rpm

Once that's done, the program will be available to run from under the Tools > liveusb-creator menu. You'll need to enter your root password, but otherwise it's the same look, feel and functionality as the Windows version, thanks to its Python/Qt base – make sure you have your Fedora ISO and USB drive ready.

-------------------------------------------------------------------------------------------------------

First published in Linux Format, Issue 114

Now read The 14 best Linux distros

Sign up for the free weekly TechRadar newsletter
Get tech news delivered straight to your inbox. Register for the free TechRadar newsletter and stay on top of the week's biggest stories and product releases. Sign up at http://www.techradar.com/register