This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Linux

Run GNU/Linux from a USB pen drive

By Juan Marcelo Rodríguez on July 20, 2005 (8:00:00 AM)

Share    Print    Comments   

You can carry GNU/Linux in your pocket with a functional, quick, and useful USB pen drive distribution. Pen drives are faster than CDs, and the small distros that fit on them don't require huge amounts of memory for the operating system and applications.

Slax is a powerful and complete bootable distro based on Slackware, equipped with kernel 2.6, ALSA sound drivers, Wi-Fi card support, X11-6.8.2 with support for many GFX cards and wheel mice, and KDE 3.4. Slax uses the Unification File System (also known as unionfs), which enables you to write whatever you want into the pen drive. Bundled software includes KDE, the KOffice office suite, GAIM for chat, the Thunderbird email client, and the Firefox Web browser.

Slax comes in a variety of versions. You can get a minimal version of Slax called Frodo, without big applications, that fits in 41MB, or choose among the 200MB standard editions such as Killbill (which I use) or PopCorn.

Configuration files

Slax allows you to modify your environment and save the changes to a single file with the configurations. The list of directories saved and restored include /etc, /root, /home, and /var. After saving your session, you can later run it and use the same environment configuration as before, without having to reconfigure every detail.

Slax even lets you upload configuration files to the Web. With this option, the next time you boot Slax from wherever you are, you can get the file from the Web. To use this feature, boot Slax with the parameters boot: slax webconfig=YourPassPhrase where YourPassPhrase is the secret passphrase you will use to protect your data. There are some limitations with this system. You can save only 8MB in each session, and the list of saved directories does not include every directory of the operating system.

Ready to give Slax a try? Download an ISO image file and Syslinux, which you need to make the USB stick bootable.

Before you install Slax to your pen drive, I suggest you partition your pen drive in two -- one portion for the operating system and the other for data. You can set the partitions as you wish, using cfdisk or another partitioning utility. You need to set up a partition for the operating system in the pen drive, with FAT16 as the filesystem. Plug the pen drive in the machine but don't mount it. If you don't know where your pen drive is, type dmesg and check its output for the mentioned USB device. Then run cfdisk /dev/sda where /dev/sda is the pen drive. Create a new partition, give it FAT16 format, and write the changes. Unplug the pen drive, plug it in again, and try cfdisk /dev/sda again to check that the partition exists and has the correct settings.

Installing Slax in the pen drive

Now you choose between two options. You can mount the downloaded ISO image of Slax and follow a few steps, or you can burn the ISO image file to a CD-ROM and use the Slax Installer application. I suggest the first approach, because are some little things you must do to get Slax in the pen drive ready. To do so, create a directory -- say /slaxUSB -- on which to mount the ISO image file of Slax, then mount the ISO image:

mount -o loop slax-killbill-5.0.5.iso /slaxUSB/

Now, as root, mount the formated USB device:

mount -t vfat /dev/sda /mnt/sda/

Note that /mnt/sda/ can be any directory you want to use. Copy the entire contents of the directory mounted with the ISO image to the place where you have mounted the pen drive:

cp -ra /slaxUSB/* /mnt/sda/

The -r argument specifies a recursive copy including every directory, and the -a preserves as much as possible the structure of the data in the USB.

Now you need to copy some files in the folder /boot/ of the mounted pen drive to the root of the pen drive so you can boot from it:

cd /mnt/sda/boot/
cp vmlinuz /mnt/sda/
cp initrd.gz /mnt/sda/

Move to the directory where the memory stick is mounted -- in this case /mnt/sda/ -- and change the name of the file isolinux.cfg to syslinux.cfg. Edit the just-renamed syslinux.cfg and delete /boot/ or boot/ from the lines that contain vmlinuz and initrd.gz -- for example, /boot/vmlinuz and /boot/initrd.gz. This changes the location of the files vmlinuz and initrd.gz, making them visible to the bootloader at the time of boot.

Finally, use whereis to check whether you have Syslinux installed. If not, download and extract it to a directory, then run:

syslinux -s /dev/sda

Where /dev/sda is the location of your recent modified Slax with all the files.

Now, reboot your computer, enter the BIOS, and change the boot order. Set USB-ZIP as the first one, then the hard drive, and so on. If your machine is old it's possible that it won't let you boot from USB, in which case you can use a boot diskette or CD, or use Slax as a live CD.

Other USB distros

In addition to Slax, you might care to try Damn Small Linux, Puppy Linux, or Feather Linux, all distros that take up less than 60MB of disk space.

Personally, I'm happy having Slax on my pen drive. It's both functional and fun.

Share    Print    Comments   

Comments

on Run GNU/Linux from a USB pen drive

Note: Comments are owned by the poster. We are not responsible for their content.

interesting

Posted by: Anonymous Coward on July 20, 2005 07:16 PM
good article, but c'mon editors: the link to Damn Small Linux is broken because of a typo..

I'm very interested in running sessions from usb and saving my work on the stick, moving from machine to machine, although I have heard the lifetime of the sticks is quite limited.

#

Re:interesting

Posted by: Anonymous Coward on July 21, 2005 03:55 AM
Puppy Linux is better than DSL and it also runs of a USB stick. BTW, don't worry about the lifetime of a USB stick. You'll lose it years before it burns out.

#

Flash Linux

Posted by: Anonymous Coward on July 20, 2005 07:20 PM
or you could try <a href="http://www.flashlinux.org.uk/" title="flashlinux.org.uk">http://www.flashlinux.org.uk/</a flashlinux.org.uk>

#

Re: Missing details.

Posted by: Anonymous Coward on July 21, 2005 01:44 AM
In fact, you dont need to do it. If you want to umount you can, too, but try it, and tell me if you have problems do it in the way I wrote. Im using Slackware GNU/Linux and it worked finely, every contrution could help,so tell me about your problems, also all the information about your distro, your usb controller, and stuff.

Cheers

#

Missing details

Posted by: Anonymous Coward on July 21, 2005 12:33 AM
There should be a umount<nobr> <wbr></nobr>/mnt/sda in there somewhere, probably before the syslinux. I have never used syslinux, don't know what it does, and this RedHat 9 system tells me nothing useful, but I think it would be better to umount the drive before passing the raw device name to some other program.

The "cp -ra" is redundant; -a includes -r.

#

Re:Missing details

Posted by: Anonymous Coward on July 22, 2005 01:14 AM
<a href="http://syslinux.zytor.com/" title="zytor.com">Syslinux</a zytor.com> is a bootloader, it's job is to load the Linux kernel into memory and transfer control to it. That's why there is no need to dismount anything, the next program is the Linux kernel.

Red Hat uses GRUB to boot from disk, it only uses Syslinux to boot the CD (or from boot floppy, if you create some from thier images).

#

Re(1):Missing details

Posted by: Anonymous [ip: 213.238.125.222] on September 14, 2007 04:38 PM
> Syslinux is a bootloader, it's job is to load the Linux kernel into memory and transfer control to it.

It's job is to install this bootloader first! So umount is useful here.

Btw. cp -a is useless -- how can you copy attributes from linux FS to FAT16 FS.

Besides that, great article! THANK YOU. I've just created my first pendrive custom (with additional Gqview and some images) Slax Popcorn on 128MB pendrive.

#

Useful article. Thanks!

Posted by: Jason Wallwork on July 21, 2005 02:31 AM
I have one of those systems that doesn't boot from USB though so I need to make a boot floppy. I remember how to make one that will boot a cdrom from a floppy but not a usb stick. I'll have to google it.

Btw, after the partitions are made, they *have* to be formatted. I use mkfs.vfat<nobr> <wbr></nobr>/dev/sda1 but use whatever you like.

#

cfidk ?

Posted by: Anonymous Coward on July 22, 2005 12:30 AM
Shouldn't "cfidk<nobr> <wbr></nobr>/dev/sda" be "cfdisk<nobr> <wbr></nobr>/dev/sda"?

#

Re:cfidk ?

Posted by: Anonymous Coward on July 22, 2005 07:40 AM
Yes. An error of typing.

Cheers

#

Solution for our College

Posted by: Anonymous Coward on July 22, 2005 03:25 AM
Our college's central IT organization would use only Microsoft products. But the students in the School of Engineering need to use Linux.

In a student project we created <a href="http://zhwinux.berlios.de/" title="berlios.de">http://zhwinux.berlios.de/</a berlios.de>, a complete Linux-System on a USB-Memory-Stick.

You boot a computer with the Live-CD, stick the USB-Memory, run a script and you have created the Live-USB!

#

Why create a custom distro?

Posted by: Anonymous Coward on August 19, 2005 01:44 AM
Its easy enough to make the small changes necessary to an existing distro to boot and run from USB.

For example, this howto describes how to install a bootable debian gnu/linux onto a USB stick with everything but<nobr> <wbr></nobr>/boot encrypted.

<a href="http://www.debian-administration.org/articles/179" title="debian-adm...ration.org">http://www.debian-administration.org/articles/179</a debian-adm...ration.org>

#

Re:Why create a custom distro?

Posted by: Anonymous Coward on February 26, 2006 03:38 PM
Because those distros are optimized to work with memory sticks.

#

boot failed (and fixed)

Posted by: Anonymous Coward on September 02, 2005 04:37 PM
I was getting a boot failed message when trying to run from either sda, or sda1. After reading through the README.usbkey that comes with syslinux 3.10, it gives specific instructions on specially formating the key beforehand. You end up using the USB-ZIP mode, which uses sda4 by default. If you're having this same problem, check out the README.usbkey file, and it should help you out. -- sithender

#

Images to the root of the pen drive?

Posted by: Anonymous Coward on February 11, 2006 04:02 AM
Thanks for the article, just what I was looking for. Question tho, why is it we have to move the images to the root of the drive? When I skip this setup, syslinux is unable to find the images under<nobr> <wbr></nobr>/boot? But if I follow your steps it ofcourse works.

#

Re:Images to the root of the pen drive?

Posted by: Anonymous Coward on February 23, 2006 02:14 AM
There is a forum available called pendrivelinux.com that describes in detail how to install linux to a usb stick. Covering all major live versions with a step by step walkthrough for each. If anyone is interested you can find it here:

<a href="http://pendrivelinux.com/pdlforum/" title="pendrivelinux.com">http://pendrivelinux.com/pdlforum/</a pendrivelinux.com>

#

How To's...

Posted by: Anonymous Coward on March 06, 2006 10:49 PM
It'd be nice to see a howto like this from Windows.

I get the impression that Live OS's are great for demoing that Linux ain't so scary to newbies like me, but I can't figure out what I need to do to make one.

#

Re:How To's...

Posted by: Anonymous Coward on June 08, 2006 10:09 AM
I've found plenty of good Linux Pendrive install tutorials over at <a href="http://www.pendrivelinux.com/" title="pendrivelinux.com">http://www.pendrivelinux.com/</a pendrivelinux.com> for those who are looking to install through windows.

#

Windows Linux pendrive install methods

Posted by: Anonymous Coward on June 08, 2006 12:02 PM
I've used the Slax and Knoppix windows install methods at <a href="http://www.pendrivelinux.com/" title="pendrivelinux.com">http://www.pendrivelinux.com/</a pendrivelinux.com> and they seem to work fine.

#

Re:Windows Linux pendrive install methods

Posted by: Anonymous Coward on June 09, 2006 04:29 AM
Nice, thanks!!

#

Screenshots???

Posted by: Anonymous [ip: 82.99.36.103] on July 25, 2007 10:35 AM
A picture is worth a thousand words

#

Re: Screenshots???

Posted by: Anonymous [ip: 85.218.48.215] on January 06, 2008 03:10 PM
But weighs like a million words!

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya