Floppies for the New Millennium

Keep crypto keys, scripts and frequently used documents ready for travel on an inexpensive, rugged USB device.
Configuring USB on Linux

Some of us old-fogy x86 Linux users have been slow to warm to USB. In the 2.2 kernel days, we initially heard of people needing to solve driver problems to benefit their fancy digital cameras and thought “better them than us”. Linux USB support was first pioneered by Inaky Perez Gonzalez, and then rewritten by Linus Torvalds, Greg Kroah-Hartman and others, and was initially rough going.

Then, USB scanners, printers, mice, video cameras, ISDN and xDSL devices, modems, floppy drives, loudspeakers, joysticks, digital tablets, MP3 players, wireless devices, PDAs, sundry mass-storage devices and just about everything else hit the market—USB started looking a whole lot less like the Useless Serial Bus we used to joke about. Fortunately, the kernel's driver support caught up in the interim, but its architecture may be a bit unfamiliar to many. If you're lucky, your distribution will have made the messy details fade to background, but in case it hasn't, read on.

Linux's USB support starts with the kernel needing to recognise your motherboard's USB chipset, which will be a UHCI (Intel) or OHCI-class (Compaq and others) device, requiring the usb-uhci or usb-ohci kernel driver, respectively. (Both also will need the usbcore driver.) If lspci -v returns USB information that includes I/O ports at, then you have a UHCI controller. If the returned USB-controller text includes Memory at, then it's OHCI.

When you're done tweaking module loading (if necessary), the output of lsmod should include all three required drivers. For example, my laptop machine lists:

Module              Size  Used by    Not tainted
usb-uhci           20676   0  (unused)
usb-storage        97120   1
usbcore            48000   1  [usb-uhci usb-storage]

The usb-storage driver is a translator that lets random-access-type USB devices be addressed using SCSI block-device names—we'll return to that later. Without it, you'd need some other intermediary to access files from the USB layers, such as the gPhoto2 application.

If you're running a 2.3.38 or later kernel (and you should really upgrade to 2.4.x or later, at this point), you also should add the following line to /etc/fstab to enable USB device tracking:

none  /proc/bus/usb  usbdevfs  defaults  0  0

After this, type mount -a. Now, you're all done except for mounting the actual mass-storage device. The above step does not mount the device—usbdevfs is strictly an abstract support filesystem similar to /proc, used by the USB subsystem.

All of the above USB-configuration details should be taken care of automatically by modern Linux installer programs, but it is covered here in case it's not. If you're reasonably lucky, all you need to do is plug the drive in to a USB port or hub and mount it.

Mounting and Managing the Flash Drive

I created a mountpoint directory of /mnt/fob from which to hang the flash drive. That name owes to the drive being about the same size as a key fob or an old pocket watch (fob watch), lurking in one's trouser pockets in roughly the same fashion.

That was the easy part. Next was a wild ride trying to chase down how to mount it properly. My browsing of on-line materials suggested that USB flash drives, as with Iomega Zip disks, would be treated as SCSI. A glance at /proc/scsi/scsi after plugging in the Easy Disk clarifies that it's recognised as the first SCSI device and moreover that it's a rebranded DiskOnKey unit OEMed from M-Systems, Inc. Intuition therefore suggested mounting /dev/sda1 (on an otherwise IDE-based system), but intuition turned out to be dead wrong in the Easy Disk's case. Making the attempt resulted in this puzzling error:

guido:~# mount -t vfat /dev/sda1 /mnt/fob
mount: block device /dev/sda1 is write-protected,
mounting read-only
mount: /dev/sda1 is not a valid block device

Some other USB flash drives reportedly do mount precisely in that way, whereas I found out that the Easy Disk mounts as /dev/sda, not /dev/sda1 or any other partition number—that is, it treats the drive as a device lacking the ability to house a partition table. The explanation of this curiosity turns out to lie in the ATAPI Removable Media Device (ARMD) BIOS Specification, laid down by Compaq and Phoenix in 1997 to generalise how a floppy-like drive should behave on the ATA bus in anticipation of traditional floppy drives going the way of the dodo. ARMD devices are basically big floppy disks, which per the spec have no partition table. Thus, the Easy Disk happens to be an ARMD (floppy-like) device. Apparently, many other USB flash disks are, by contrast, treated as regular ATAPI drives.

Like most flash devices, the Easy Disk came preformatted with the MS-DOS FAT filesystem. That raises, of course, the question of whether it might be rewritten to use less antique disk formats instead. I never tested that, partly because FAT, for all its faults, is supported by almost all UNIX workstations, Macs and MS Windows boxes. Partly, I shied away from attempting other filesystems in order to reduce device fatigue.

Now, some further elaboration of the mount command:

# mount -o uid=1000,gid=1000,noatime -t vfat \
/dev/sda /mnt/fob/

______________________

Comments

Comment viewing options

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

hi

daviddanish's picture

Thanx for sharing this with all of us. Of course, what a great site and informative posts, I will bookmark this site. keep doing your great job and always gain my support. Thank you for sharing this beautiful articles. Legal Funding

Re: Floppies for the New Millennium

Anonymous's picture

Hello,

I'm running Fedora Core 2 (test3) Kernel 2.6:
[root@neo root]# mount -all
mount: none already mounted or /proc/bus/usb busy
mount: according to mtab, usbdevfs is already mounted on /proc/bus/usb

[root@neo root]# mount -t vfat /dev/sda1 /mnt/usb
mount: /dev/sda1 already mounted or /mnt/usb busy

However,
[root@neo root]# cat /proc/scsi/usb-storage/2
Host scsi2: usb-storage
Vendor: LEXAR MEDIA
Product: CF CARD
Serial Number: 1115321335949
Protocol: Transparent SCSI
Transport: Bulk
Quirks:

What am I missing? I'd appreciate any help.

Thx,

Erasmo

Re: Device to Device Wireless Floppies

Anonymous's picture

see www.memsen.com ultra wideband

Re: Floppies for the New Millennium

Anonymous's picture

Wireless USB at memsen.com
Wireless Memory Disks for P2P file sharing
Ultra Wideband enabled USB Drives
see www.memsen.com
Memsen
David Buzzelli

Wireless USB Wireless USB

Anonymous's picture

Wireless USB see www.memsen.com founded by David Buzzelli

Re: Floppies for the New Millennium

Anonymous's picture

ok, I just realized one mistake I made. I should have used /dev/sda2:
[root@neo root]# mount /dev/sda2 /mnt/usb
/dev/sda2 looks like swapspace - not mounted
mount: you must specify the filesystem type

But when I try:
[root@neo root]# mount -t vfat /dev/sda2 /mnt/usb
mount: /dev/sda2 already mounted or /mnt/usb busy

I continue to be clueless....

Use devlabel

Anonymous's picture

If you have more than 1 device, the scsi you get will depend on the order you plug in devices. You should look at devlabel, which comes with fedora. This will not only give consistent labels for devices, but can also automount them.

Re: Floppies for the New Millennium

Anonymous's picture

I'm reading a thread on the gentoo forums that says you should mount with sync and dirsync to prevent delayed buffer writes and data corruption. Care to comment?

Thanks for the noatime tip also!

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