USB Pen Drives: Large, Portable Storage in a Tiny Package
The conscientious, hard-working network admin can often be sighted striding purposefully about, laden with large binders and bags of disks. Documentation is everything in this business — device configurations, system configurations, network settings and diagrams, hardware and software inventories, deli delivery menus and numbers — it all has to be recorded.
Some of us even keep logbooks to document procedures — especially the successful ones. This is no joke on Linux systems, which typically run trouble-free for months and months, making it all too easy to forget just what it was we initially did that worked so well.
I'm a big believer in paper documentation. I can scribble notes on it and read it easily with my elderly eyeballs, it can't break if accidentally dropped, and best of all, I don't need a machine to read it, so I can take it anywhere. Hey, it's no joke crawling underneath desks with a little Maglite and a paper notebook — the thought of having to lug a computer around in those circumstances would be nuts.
But digital storage also has its place, for all the obvious reasons I shan't bore you with by enumerating. In the past I would typically carry a jumble of floppy disks and CDs containing documentation, software, configuration files, rescue disks, and miscellaneous "you never know when this will be useful" stuff. Lately, though, I've been able to weed down most of it, keeping only a few bootable rescue disks and my new super-important nifty gadget – a USB pen drive (also called "thumb" drives).
The Well-Equipped Geek
We’re in a rather interesting transitional time where we have to deal with all manner of methods for doing data transfer with portable media: 3.5" diskettes, CD-R/RWs, and now USB drives. Diskettes have the obvious disadvantages of being a vulnerable magnetic medium and also being limited to capacities far too small for today's world. Still, they are the lowest common denominator on older systems.
CDs, on the other hand, are great, with plenty of capacity, but they are cumbersome and often too time-consuming for recording data. This leads us to USB storage drives, which fill a new niche by offering fast and easy data transfer in a small, sturdy, portable device.
That's not to say USB storage devices aren't without their own disadvantages. First, older machines don't have USB ports, and second, USB devices aren’t always bootable. Booting from USB depends on your system BIOS, so if it already recognizes USB boot devices, you're in business.
But from a network administration standpoint, I don't much care if I can boot from USB — I have my faithful Tom's Root Boot on diskette, Peter Anvin's SuperRescue CD, and a Knoppix CD to handle any system recovery chores.
As a network admin, I want my sleek little USB device to carry system data, software, and documentation. Plus I want to be able to quickly and easily dump new data into it, such as logfiles and other diagnostic outputs.
16- to 256-megabyte drive sizes are common, and are relatively inexpensive, with street prices ranging from around $30 to $125.00. You'll see USB 2.0 devices now as well; they're the high-speed, next-generation USB technology that promises data transfer speeds of 480 megabits per second. USB 1.1 tops out at 12 megabits per second. Yep, quite a difference!
It's most likely that your systems will support USB 1.1, as 2.0 is still quite fresh and new. USB 2.0, however, is backwards-compatible to 1.1, so aside from the cost difference, it doesn't matter which version you purchase.
Making It Work on Linux
On modern Linux distributions, it should Just Work. USB support first appeared in the 2.2 kernels, and hotplug support appeared in 2.4 (and has been backported as far as 2.2.18). But really, use a modern kernel — sheesh, it doesn't cost anything but a few minutes of your time to update it. And hotplugging is what really makes USB devices worth having.
If you have a reasonably modern Linux, chances are a fully-functioning hotplug subsystem is already in place, so all you need to do is plug in your kewl new pen drive and go to work. No need to mess with mounting and unmounting, which can be ever so tedious. Typically, the pen drives are factory-formatted in some form of FAT, which Linux handles just fine. Of course, you can partition and format it any way you like.
To find out what the file format is, use this command:
#fdisk -l /dev/sda
or whatever the drive designation is.
If you have other SCSI drives, it will be sdb or sdc or something similar. fdisk -l shows all mounted partitions. Linux mounts USB in the SCSI subsystem. Yes, it's fake SCSI, just like ide-scsi for CD writers.
To format a pen drive, or more precisely, to create a FAT32 filesystem:
# mkfs -t vfat /dev/sda1
To create a DOS filesystem:
# mkfs -t msdos /dev/sda1
etc., you know what to do.
Note that on a pen drive, it doesn't matter what filesystem you use. Use FAT32 or FAT16 if you want both Windows and Linux to read the files. You can use ext2, ext3, Reiser — any of them. (Please note that for devices like flash cards for cameras, you shouldn't monkey with the filesystem — you could render the card unreadable for the device.)
The Hard Way
If hotplugging is not enabled, which is very sad, you can add it. There are several steps to follow. Before leaping in and doing any of these things, check the home page of your distribution or the documentation for your installation disks to see if there is an easy way to add hotplug support. It's a good thing to have, not only for USB devices, but for Cardbus, Firewire, docking stations — any device that can report state changes.
If after all that, there’s still no easy way to add it:
1. Make sure you have an up-to-date kernel. See Red Hat's manuals for the online versions of the Red Hat manuals; kernel upgrading and configuration is in the "Customization Guide."
Debian users have two excellent guides available to them:
Creating Custom Kernels With Debian's Kernel-Package System
Compiling Kernels the Debian Way
2. Configure all the kernel USB bits as modular. There really aren't any good reasons to compile them statically — that defeats the whole notion of hotplugging. The following are needed:
ECHI HCD CONFIG_USB_EHCI_HCD, usb-ehci-hcd.o
UHCI CONFIG_USB_UHCI, usb-uhci.o
OHCI CONFIG_USB_OHCI, usb-ohci.o
The Bottom Line
I support mixed Windows and Linux networks, and this little gadget has made a huge difference for me. It's much faster than a CD, and data transfers are so easy — I don't cuss nearly as much as I used to.
One surprising use is at "Big Company," where I do some occasional work. Engineers who use the big color plotters now use their own pen drives to transfer the files directly to the printer servers, instead of over the network. They can monitor and troubleshoot the print job locally, plus they like to poach on other department's plotters so it doesn't count against their own quotas. This probably doesn't count as a win in some people's books, but it sure does keep them happy and entertained.