Software // Operating Systems
News
5/15/2008
04:21 PM
Connect Directly
Google+
Twitter
RSS
E-Mail
50%
50%

How To Run Linux From A USB Flash Drive

Want to run Linux any time, any place? Here's what to do with popular distributions like Puppy Linux, Ubuntu, and Fedora, so you can boot up directly from your thumb drive.

From Installation CD To Bootable Flash Drive

Most Linux distributions, such as Ubuntu, are capable of installing directly to a USB drive as if it were just another hard drive, but some distributions treat USB flash drives as a slightly special case. DSL, for instance, has an installer specifically for creating a USB-drive installation of the OS. Puppy can also install itself directly to a flash drive through the built-in Universal Installer utility. However, the default options did not work in my case; I had to explicitly use the "SysLinux" option in its installer menu to make the flash drive bootable.

In all cases, a USB flash drive will be mounted and recognized as a virtual SCSI device, such as /dev/sda or /dev/sdb. If you're performing the installation on a system that already has a hard drive present, pay close attention to the devices listed in the partition manager, and make sure you're installing to the right device. Otherwise you might accidentally wipe the hard drive -- although the device size should be a big tipoff! Also make sure that the installer makes the target device bootable and writes a proper master boot record to the drive, although most of the time this should happen automatically.

From Live .ISO To Bootable Flash Drive




Open source QEMU lets you run Linux in a virtual machine on top of another OS.
(click for image gallery)

If the edition of Linux you're eyeing has a live CD distribution (and most of them do), it's also possible to mount the .ISO for the live CD on a flash drive and run it from there. The advantages of doing this should be plain: it's a lot faster to run a live distribution from a flash drive than from a CD, and almost any machine that can boot from a CD can also boot from a flash drive as well.

The disadvantage of this type of setup is that, by default, a live CD distribution is generally not persistent. Any changes made to the system will be lost the next time you reboot, unless you make specific provisions to save user data. Some live distributions allow this, but it's not always guaranteed. On the plus side, if you want a live distribution that doesn't leave behind any traces -- for instance, for secure browsing or system recovery -- this is a perfect choice.

The folks at PenDriveLinux have created scripts to automate the process for a number of popular distributions such as Ubuntu 8.04 and PCLinuxOS. Their trick (and it's a clever one!) is to use the open-source 7-Zip archiving application to browse the .ISO and extract key files from it to allow SysLinux to make the drive bootable.

The same basic techniques can be applied to any Linux that runs from the ISOLINUX live file system. To that end, if you want to make a bootable flash drive from a live CD distribution's .ISO, follow these steps:

  1. Format your flash drive. You may need to first use DISKPART CLEAN as described above. For the sake of compatibility, use FAT or FAT32 as the file system. (FAT seems to work best.)

  2. Use 7-Zip or another .ISO reading tool to unpack the entire contents of the .ISO onto the flash drive. Make sure the root directory of the .ISO corresponds to the root directory of the flash drive; don't unpack the contents into a subfolder on the flash drive.

  3. Use SYSLINUX -ma <driveletter>: (in an admin console, if you're using Vista) to write the system files, with <driveletter> being the drive letter for the flash drive. If you're running SysLinux from something other than Windows, the -ma switches aren't needed.

  4. With many live distributions, there will be a file in the root directory of the drive labeled ISOLINUX.CFG. This may need to be renamed to SYSLINUX.CFG to make things work correctly.

  5. Unmount the flash drive and try to boot it on your target system.

Some live Linux distributions will have a \boot directory off the root directory in the .ISO, usually with an \isolinux directory in it as well. For such distributions, you'll need to move the contents of \boot\isolinux to the root directory of the flash drive before renaming files and then applying SysLinux. The order of the events is crucial.

Previous
3 of 4
Next
Comment  | 
Print  | 
More Insights
Comments
Newest First  |  Oldest First  |  Threaded View
pkohler01
50%
50%
pkohler01,
User Rank: Apprentice
11/15/2012 | 9:56:04 PM
re: How To Run Linux From A USB Flash Drive
Geez, talk about giving away all the tricks...

Something that should be considered are the security implications, as well as the data recovery opportunities, that having a USB flash drive that you can boot Linux up from introduces.

I created my first Linux Flash Drive a few years ago and have successfully used it in many instances to bypass security on boxes (all white-hat stuff, mind you) and to recover files from systems that would no longer boot before re-imaging them. That made a tool of this nature invaluable to me.
Register for InformationWeek Newsletters
White Papers
Current Issue
InformationWeek Tech Digest September 23, 2014
Intrigued by the concept of a converged infrastructure but worry you lack the expertise to DIY? Dell, HP, IBM, VMware, and other vendors want to help.
Flash Poll
Video
Slideshows
Twitter Feed
InformationWeek Radio
Sponsored Live Streaming Video
Everything You've Been Told About Mobility Is Wrong
Attend this video symposium with Sean Wisdom, Global Director of Mobility Solutions, and learn about how you can harness powerful new products to mobilize your business potential.