Some readers are probably familiar with using a virtual machine to run Linux on top of another operating system -- usually as a way to try out a given Linux distribution within Windows without creating a dual-boot scenario.
The same thing can be accomplished with a flash-drive edition of Linux, courtesy of an open source machine emulation package named QEMU.
It's small enough to fit on most flash drives along with whatever distribution you're using and can be started by executing a simple batch file. You'll even have networking support courtesy of whatever network is running on the host. Here's how to do this.
MokaFive lets you create bootable Flash drives that run any OS in emulation.
|(click for image gallery)|
- Format the flash drive as FAT or FAT32 (for the sake of compatibility).
- Copy the .ISO file you want to use to the root directory of the flash drive.
- Unpack the QEMU executable into a directory named \QEMU.
- Use the following command line to run QEMU from the root of the drive (you can turn this into a batch file):
.\qemu\qemu.exe -L .\qemu -cdrom <name_of_ISO>
There are a number of other options that can be passed. If you run QEMU without any command-line switches you'll see the full range of options available, so you can tune it to your needs.
- Run QEMU from within Windows. The emulated machine will appear in a Window and you can free the cursor by pressing the left Ctrl+Alt keys.
Keep in mind you're not going to see the kind of performance you'd get if you booted the system natively. QEMU does have a Windows-specific driver to allow some performance acceleration, but you can run it without that as well if speed isn't a priority.
If you want to create persistent storage on the flash drive, there are a couple of ways to do this. QEMU lets you mount any file as a hard drive, so one possible trick is just to create a large file on the flash drive that will hold your user data, use the -hd QEMU option to mount it as a hard drive, format the drive from within your live Linux session, and store your user data there between sessions.
The second option is more or less the same as the first, except that instead of just storing data on that drive, you actually install Linux on it and then set QEMU to boot the hard disk image instead of the .ISO. Note that the best way to do this would probably be to prep all the files on your PC first, then copy the hard disk image and the QEMU executables to the flash drive.
Finally, the folks at PenDriveLinux have created a package that you can use which contains QEMU and a batch file with some common options. The batch file can be customized with the command-line options you want to use, and you can make any other changes you see fit as described above.
Yet another way to run a Linux installation -- or, in fact, most any operating system -- from a flash drive is through MokaFive. This is a commercial application that lets you package virtual machines for redistribution across a network or -- you guessed it -- a flash drive. MokaFive uses VMware to perform machine emulation, which generally runs better than QEMU out of the box, and also allows for some fairly sophisticated lockdown techniques as well. The basic edition of MokaFive is free (although not open source), but will do nicely for this kind of work. You can even access hardware devices on the host computer, like scanners and printers (provided you have permission to do so).
The MokaFive toolkit includes the BareMetal player, a tool which lets you install a MokaFive VM to a flash drive, boot from it, and run it natively. A device with at least 2 GB of storage has to be available to make this work. Note that because the BareMetal player is protected against tampering, the only way to get a virtual machine into it is by loading one in through the BareMetal player's own interface.
Buy Linux Pre-Loaded
There's been speculation that you might eventually buy music on flash drives, and while that hasn't panned out the way conventional MP3 downloads have (barring the odd Nine Inch Nails flash drive left somewhere surreptitiously!), some Linux distributions have started to turn up on flash drives as preloads. Dragon Technology offers Ubuntu on a 4-GB flash drive for £21.95 (about U.S. $43), and the LinuxUK site has a range of USB Linux products at various prices. I've gone back and forth about whether or not we'll see software products routinely provided on flash drives -- the raw cost versus plain old CDs or DVDs is a lot higher, but in my mind the added versatility of the flash drive makes up for it.