Linux on a Fingernail

 in

This issue of Linux Journal is all about how to get Linux in your pocket. In this article, I go one better and tell you how to get Linux on your fingernail. Now, before you get too excited, I won't be discussing some new nano-computer being used by James Bond, unfortunately. Instead, I discuss how to put Linux on a micro-SD card (or any other USB drive, for that matter). Using this, you can run Linux on any machine that can boot off a USB device.

One of the first utilities to receive widespread attention and use is UNetbootin (http://unetbootin.sourceforge.net). This application is available under both Linux and Windows. It has built-in support for downloading and installing several Linux distributions, including Ubuntu, Fedora, Debian, PCLinuxOS, Linux Mint, Sabayon Linux, openSUSE, Gentoo, Arch Linux, MEPIS and many others.

Figure 1. UNetbootin

UNetbootin also has the ability to load several different system utilities, such as the following:

  • Parted Magic: a partition manager that can resize, repair, back up and restore partitions.
  • SystemRescueCD: a system repair, backup and recovery tool.
  • Super Grub Disk: a boot utility to restore and repair GRUB installations.
  • Backtrack: a utility for network analysis and penetration testing.
  • Ophcrack: a utility to recover Windows passwords.
  • Smart Boot Manager: boots off of CD-ROM and floppy drives on machines with a faulty BIOS.
  • FreeDOS: an open-source DOS to allow you to run BIOS flash utilities or just plain-old DOS.

UNetbootin can download the correct ISO image for all of these distributions automatically, or you can download (or create) your own ISO image and hand the filename to UNetbootin. In either case, the next step is to extract all of the files from the image so they can be copied to the USB drive. The USB drive you want to use needs to be formatted with a filesystem already on it. Once the files all have been extracted, UNetbootin uses some heuristics to figure out where the kernel and initrd files are hiding and places them into /ubnkern and /ubninit. It then goes through the boot configuration files from the ISO to try to figure out what boot options need to be set on the USB drive. Once it figures that out, it puts those options into the configuration file /syslinux.cfg. Then, UNetbootin uses Syslinux to make the USB drive bootable, and you should be good to go.

Another utility that has started garnering a lot of attention is usb-creator (https://launchpad.net/usb-creator). This program is the official tool to create live USB versions of Ubuntu live CDs. This utility started with version 8.04 of Ubuntu. A KDE front end showed up in version 8.10, and a Windows version currently is in the works. This utility can do the same sort of work as UNetbootin. It has the built-in ability to create an Ubuntu live USB, but that's not all. Like UNetbootin, usb-creator can take an arbitrary ISO image and copy that onto your USB drive. It even can take a CD-ROM from your CD drive and copy its contents over to your USB drive. It's a simple matter of selecting the source and the destination, and then running.

Figure 2. usb-creator

One big advantage of usb-creator is its ability to create a persistent live USB for you very easily. Any extra space on your USB drive, above and beyond what is required for the OS files, can be used as writable space for persistent files. This means any changes you make to your system will be written to the USB drive. You even have the option of clearing the persistent space on shutdown. That way, you can use your USB drive as a complete operating system, exactly as if it were on your hard drive. And, there you go, Linux on a thumbnail.

All of these techniques require you to have either a live CD or an ISO image of a live CD. But what if you want to go a bit more low-level, a bit more from scratch? One of the tools available to you is Syslinux (). Syslinux actually is a suite of different programs that provide for booting from many different media, including:

  • syslinux: booting from FAT filesystems.
  • pxelinux: network booting.
  • isolinux: bootable "El Torito" CD-ROMs.
  • extlinux: booting from ext2/ext3/ext4 or btrfs filesystems.
  • memdisk: a tool to boot legacy OSes from nontraditional media.

Syslinux installs into the boot sector of your device and puts a copy of the file LDLINUX.SYS into the root directory. It then loads the kernel and other OS files from the actual filesystem. Because the filesystem is just a simple FAT filesystem, all the files, including the kernel, can be manipulated using standard DOS tools. By default, Syslinux assumes the kernel is in the file named LINUX on the boot disk. This default can be changed in the config file. If you hold down the Shift or Alt keys during bootup, Syslinux displays a LILO-style "boot:" prompt where you can enter a kernel filename and options.

Syslinux searches for its configuration file in the following order: /boot/syslinux/syslinux.cfg, /syslinux/syslinux.cfg, /syslinux.cfg.

In this file, you can set parameters to change all the default settings. Any filenames in the configuration file are relative to the directory that syslinux.cfg is in, unless it is a full path. A basic example looks like this:

DEFAULT linux
LABEL linux
  SAY Now booting the kernel from SYSLINUX...
  KERNEL vmlinuz.img
  APPEND ro root=/dev/sda1 initrd=initrd.img

The kernel types that Syslinux supports don't need to be a regular Linux kernel image. They can be a PXE bootstrap program, a boot sector or a COMBOOT image.

These techniques and utilities should give you a good start at putting your USB drives to their best use. You now can carry around your whole OS in your pocket. This is essentially what I've done for my old Eee PC. With Linux on USB, I can keep the same system there, and on my MacBook through Parallels. You also can use the same system on basically any machine that you can get to boot off of USB. Have fun and be creative.

______________________

Joey Bernard has a background in both physics and computer science. This serves him well in his day job as a computational research consultant at the University of New Brunswick. He also teaches computational physics and parallel programming.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

good program

PatriciaMoore's picture

I used it to install an iso of linux on my 2G USB flash drive. It worked flawlessly. It is a simple interface. You tell it what iso to install and what drive to install it onto and it does the work.
- Patricia

Linux-Fingernail LiLi Linux Live USB

gvnmcknz's picture

LiLi is excellent, (ironically it's Windows only !!).
It's just about the only time I use Windows these days

http://www.linuxliveusb.com/

Many Distros, often with persistence, and a built-in VirtualBox.
Other ISO's and Img files dealt with automatically usually.

Fabulous for DistroHoppers.
TRY!!

Regards
gvnmcknz

--- http://uugy.com/77962

Anonymous's picture

--- http://uugy.com/77962 ------
14USD e d har dy T-shirts,C00gi T-shirts,Christian Audigier T-shirts,Gucci T-shirts,Polo T-shirts.
25USD c0ach handbag,gucci handbag,prada handbag,chanel handbag,
12USD sunglasses,9USD caps.
Please visit---- http://uugy.com/77962 ------
---- http://uugy.com/77962 ------

I use puppy linux. It's my

Anonymous's picture

I use puppy linux. It's my favorite linux distro yet and it makes things so easy for me. I love the portability and ability to use any computer I have boot access to.

Me too!

EBScotty's picture

I've used a few other distros, and I like Puppy best. It has everything I want, and I can carry it with me on a very small usb stick.

linux on usb

Milty's picture

I use Multisystem to run about 8 distros on one usb thumb drive. Just take your pick at boot.

Split the drive - you can use it as a jump drive or boot linux

Anonymous's picture

I have a 16Gb usb stick that is split. So if I insert my stick in a PC that is already booted, then it shows up as a data jump drive (FAT). While if I want to boot my linux os, I would just reboot the machine from the same USB stick. Great way to have Linux AND ability to quickly copy files. Also a have Antivirus installed in Linux side so if I need to clean scan a windows machine I simply boot to linux and run commandline scan of the mounted windows drive!

Got to love linux.

Mandriva Seed

Anonymous's picture

Another program for putting a Linux distribution on USB which isn't mentioned in this article is Mandriva Seed. While ymmv, I've found it more reliable than either unetbootin or usb creator, though I haven't tried to use it for distributions other than Mandriva.

b

I bought a class 6 micro SDHC

Robert Maroon's picture

I bought a class 6 micro SDHC card and a reader that is almost flush with my notebook for the exac reason to have Linux on a fingernail.

Even if the performance are really good with large files (22MB read/6.5MB write), the system with slow files is awfully slow (I also did a full install on a Toshiba branded microSDHC card and the installation took 6 hours).

I would reccommend a Cosair Voyager GT for this kind of "experiments".

Universal USB Installer

vibrantlee's picture

I have been using Universal USB Installer from pendrivelinux.com for as long as they've first pulished it. I've been running Linux from a couple (4GB and 8GB just recently) microSD cards for a few months now. April 28th they released version 1.8.4.4 to include the new Ubuntu 11.04 releases. They have a large selection of distros to download and put onto your USB device. One thing about the Universal Installer is that it tends to keep the original syslinux config intact as opposed to the modification that UNetbootin has done in the past for me. All in all, great article! Thanks for the last little bit on syslinux.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix