[TriLUG] Live Linux on USB Flash Drive

Brian Phelps brphelps at ieee.org
Sat May 17 08:37:30 EDT 2008


On Fri, 2008-05-16 at 22:04 -0400, Scott G. Hall wrote:
> Can somebody point me to some boiler-plate instructions for creating
> a bootable USB flash drive of a live Linux from an CD ISO file of the
> same?  I have run across several on the web, and none of the
> instructions seem to work.  I have confirmed that my test system will
> boot to an external USB drive (an external USB IDE drive with Linux,
> and a bootable USB flash drive with MS-DOS).  I suspect that I may be
> running into a filesystem type issue, but I am not sure.
You can use the ISO in that you can use the root filesystem.   Using the
actual ISO may be a bit impractical unless...  

You could create an initrd to mount the ISO and chroot to that ISO's
root directory.  Yes you will have to have grub and a /boot directory in
addition to the ISO file installed on the USB drive.

I create my own embedded read-only flash installs using these
instructions:
http://electronjunkie.wordpress.com/2007/10/11/31/

This has some explanations on how to use squashfs and unionfs (with a
ramdisk) to run a debian setup.

The CD's use a different bootloader I believe.  

It is really easy to do this if you don't need to use a read-only flash
file system.  Read-only makes it neccessary to modify the initrd to use
unionfs with the ramdisk.

With flash also make sure to not create a swap partition.

Either way you need to familiarize yourself with initrd's commands:

Copy a working initrd into an empty directory, cd to the directory and:
# z/cat initrd.img-name | cpio -i
# rm initrd.img-name

Modify scripts in the ./scripts directory.  These scripts are executed
on boot depending on which boot= option is passed to the kernel.

When you're done modifying scripts:

# find ./ -print | cpio -H newc -o | gzip | > ../initrd.img-new-name

Don't forget to modify grub's menu.lst to use your new initrd
Omit the gzip if you want.  cpio is a way of making a concatenated file
archive similar to the tar command.  For some reason, cpio is supported
by the kernel, tar is not (its probably a simpler algorithm).
> 
> -- 
> Scott G. Hall
> Raleigh, NC, USA
> ScottGHall at BellSouth.Net





More information about the TriLUG mailing list