Home

How To Run Linux From A USB Flash Drive

Comments | Serdar Yegulalp, InformationWeek | May 20, 2008 11:10 AM


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.



Related Reading


More Insights




Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

BYTE encourages readers to engage in spirited, healthy debate, including taking us to task. However, BYTE moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing/SPAM. BYTE further reserves the right to disable the profile of any commenter participating in said activities.

COMMENTS

Tune In to BYTE
Facebook Twitter LinkedIn Newsletter RSS
Whitepapers
whitepaper
In this paper you will learn the five trends shaping the future of enterprise mobility. Learn how the rise of social media as a business application, the lurring between work and home, the emergence of new mobile devices, the demand for tech savvy employees and changing expectations of corporate IT will fundamentally change the workplace.
whitepaper
In a survey of more than 1,700 information workers (iWorkers) in North America, notebooks, desktops, and smartphones were found to be “must-have” devices, while tablets, slates, and netbooks were relegated to “nice-to-have” status, according to a commissioned study conducted by Forrester Consulting on behalf of Dell and Intel.
Sponsored by: Dell
Upcoming Events