Linux on a Stick: Portable Linux
Install Linux on a USB flash drive, thumb drive, stick, pendrive, key, or whatchamacallit.
Purpose
To install a nice GNU/Linux desktop operating system to a bootable USB flash drive (“stick”). This is not a live-CD-type install with a compressed filesystem. This is a full install just as one would do on a hard drive partition, but smaller. By “full install” I mean a normal uncompressed filesystem, not necessarily an “everything” install. In fact, installing Debian on a 2 gig stick is what we might call a “slim full install,” which is the purpose of my experiments, and these articles.
Most of the current crop of stick-installs involve using a live-CD-type compressed filesystem. That arrangement does give the system a place to write a persistence file, but what I want is a regular, uncompressed Gnu/Linux install to a stick. Why? To have the ability to edit and modify every aspect thereof; to begin with a text-console-only Linux and learn how to use it, then later, add a custom selection of graphical components and applications, one thing at a time, making a tidy, portable installation. It’s an experiment to see if it may be done, and determine if it has practical applications.
Note: This series of articles is not related to LoaS (linuxonastick.com). They are apparently doing live-CD-to-ram-type installs, while I am doing conventional uncompressed installs. One isn’t better than another, but they are different.
Other options: One may certainly install a compressed live-CD-type system to a stick, make a persistence file, and use it that way. See pendrivelinux.com, linuxonastick.com, etc., for many options. One may also try the netinst version of Fedora and perhaps others. One may dive into building Linux From Scratch or Gentoo on a stick. All should be fun and educational.
Background
A few years ago, Klaus Knopper developed a new kind of Linux install: The auto-detecting Live CD. This allowed users to boot a CD with a complete Linux distro on it. The first was, and is, called Knoppix. Since then, almost all distros have developed a Live CD version, and most will also install from there to a hard drive. Try it then install it, or dump it and try something else. Wonderful!
Then, along comes the USB stick, first in megabyte sizes, then hundreds of megs, then a gig or two, and now (late 2008), 8 gigs for under $20! Our two-gig sticks of only a few months ago are now spares, and the old 256 meg sticks are pretty much relegated to the dust-bin.
Now we see a bunch of online instructions for turning Live CDs into Live USB sticks. Fine, but the stick is writable and gigs are now cheap, so (I asked myself) why put a read-only CD-type compressed filesystem on it? After a lot of searching, I found little or no instructions for creating a full (uncompressed) installs on sticks. The distro developers just haven’t caught up with the sudden price-drop of large-capacity sticks.
My Experiments
I determined to locate the best starting point and make it work to my satisfaction. Yes, I could go get a 4-gig stick (and I already have an 8 but use it for other things), but I wanted to assemble a small installation on my spare 2-gig stick. I spent a couple weeks (several 16-32-hour days!) experimenting.
Installing a whole distro to a 2-gig stick won’t fly: They’re all much larger than that when installed. However, now that 4 gig sticks are $11, get one and give it a go! No, get an 8 for $18 and put in the whole kitchen. The big stick should last longer, too, thanks to wear-leveling.
I played with both DSL and Puppy. Nice, but not what I want. Next, I tried building Linux From Scratch (LFS), and then Gentoo, on a stick, and found the 2-gig stick too small for all the build files. Also, they would not boot a stick without an initrd (initial ram-disk filesystem), and I didn’t know how to build one.
Suddenly, I discovered the Debian Netinst version: Download a 165 meg ISO, burn it, boot it, then installs it to a drive. Boot the basic Debian system, set up networking, get online, and start adding selected packages. Oh, delight! Finally, a distro that doesn’t give you the whole kitchen sink in one go! But will it install to a USB stick? Yes, it will, and it gives you a nice text-console-based Debian in about 400 megs, to which you can add your favorite window manager and apps. That’s the way to go if what you want is a Linux-on-a-stick that’s less than the whole kitchen, but more than DSL or Puppy, and easier than LFS or Gentoo.
What I ended up with is: Debian core plus xorg, Gnome, audio, video, CD/DVD burning, Nautilus, Gnome Commander, Synaptic, Evolution, Iceweasel (Firefox), AbiWord, etc.—in other words, nearly a full Debian Etch install. I left out the desktop manager (graphical log-in), because it eats a lot of stick, and it’s no problem to log in at the command prompt then type “startx.” The current installation is using about 1 gig, and leaving about 750 megs free. I’m using one partition (plus a small swap). The whole stick is easy to back up to my main Ubuntu system (on a hard drive), so there’s really no point in making a bunch of separate partitions on the stick. If I mess up the stick, I just boot to Ubuntu and copy over the backed-up bin, boot, usr, and var directories, which puts the stick back like it was, so I can try again, this time with a slightly different set of packages.
The Down-sides of Sticks
1 First, not all computers will boot a USB stick, but most will, if newer than about 2002 or so. Still, it’s not a problem: One can put various bootloaders (like Grub, Lilo, etc.) on the local hard drive, or a CD, or even a floppy, and boot the stick with that. Ah, but there’s a catch: We want portability, i.e., the ability to plug it in to nearly any compatible computer, boot it, and run a full writable Linux distro, without carrying around another boot media.
The best solution is to have a Grub on your hard drive and boot the stick locally with that one. Also, have a Grub on the stick, for booting elsewhere, and as a recovery booter. Very handy.
2 Next is the possible problem of the stick’s life: They tend to wear out at something like 100,000 write cycles. Solution: Build your stick, then back it up to a hard drive. Also, take steps to stop unnecessary writing, like turning off logging and disabling temp and backup files where possible. Also, get the whole system installed right the first time, then leave it alone. Don’t keep installing and uninstalling big packages. Keep the browser cache off, and reject cookies. Either that, or just don’t worry about it: Sticks are now cheap enough to be disposable—just keep it backed up.
3 Another issue is that of speed: All but the newest BIOSes start the stick up in low speed (1.0) compatibility mode, causing about a 2-3 minute delay while the kernel and initrd are slowly grinding into memory. Once the kernel gets control of the stick, it tosses out the BIOS and handles the stick directly at USB 2.0 speed (limited by the stick). Then it’s reasonably fast, although not nearly as fast as a hard drive. Most cheap sticks have read/write speeds of around 20/7 (megs per second), but that’s only on large files. They are much slower, particularly writing, with small files, and Linux systems use jillions of small files. The fastest sticks are really only about 30/20, and again, that’s only with large files, and surprisingly, some of the fastest rated sticks are some of the slowest on 4k files. They all level out and reach their peak at 64k and larger files. A couple of the (currently) fastest-writing sticks are the Corsair Voyager GT and the Kingston DT HyperX—but consult online benchmark tests, as these things change often.
In operation, the speed of the stick is noticeably slower than a hard drive (as expected), but not annoyingly so. For example, when you first fire up Gnome and open a menu, you wait a few seconds for the icons to appear. When opening a big app, you wait a few seconds longer than a hard drive. It’s just an acceptable compromise for having a full operating system on 4 grams! The main annoyance is the 2-3-minute boot delay, and that’s a BIOS issue with some (many) mainboards.
What’s Next?
Disclaimer
The installation instructions described in these articles are to be considered experimental. They may or may not work for you, nor turn out as described or expected. The author bears no liability for your actions or any direct or indirect consequences thereof. If you are not experienced in partitioning drives and installing operating systems, you should not do so.

