E-Mail:
Get our new Windows 7 eBook (PDF) for $7 with 70+ Tips. Download Now!

Use VFAT for USB Keys

  • No Related Post

Here’s a quick tip related to using USB keys and similar devices on your Linux system, specifically dealing with direct mounting or using /etc/fstab for quick and easy access.

When I first started using my Lexar JumpDrive, I noticed file and directory names were getting truncated. This is no doubt because in the old DOS world, file names were limited to eight characters followed by a three-character extension. I tend to keep my file names short out of habit (mostly for troubleshooting Windows via a DOS boot disk), but sometimes that’s just not feasible for keeping accurate descriptions in file names, especially when Linux and even FAT are capable of doing so much better. Even more troublesome is correct filenames were preserved on the USB key despite what the ls tells me, but in copying the files back to the hard drive, only the truncated names are copied.

I dealt with it for a while as I had more pressing concerns, but finally the frustration got the better of me. The original fstab entry I created was as follows:

dev/sda1    /mnt/flash    auto    noauto,owner,user    0 0

The first field says the filesystem can be found on the SCSI device chain (if you are unsure where your Linux is putting the device, run “tail -f /var/log/messages” before plugging in your device and watch for the output when you make the connection), and the second is the mount point I created for my USB keys. “Auto” in the third field lets the system determine the filesystem format automatically. Previously this worked fine, but for some reason it started having trouble on my Slackware system.

After mounting the key (with “mount /mnt/flash”), I ran the mount command with no arguments to see what was listed. I saw the following for my USB key:

/dev/sda1 on /mnt/flash type umsdos

Aha! Most USB keys and CF cards come with FAT file systems. umsdos works, but obviously only accepts the 8.3 filename formats. I edited my fstab to read as follows:

dev/sda1    /mnt/flash    vfat    noauto,owner,user    0 0

Upon remounting the device, I noticed I once again had normal file names; previously truncated file names appeared in full. Running mount again, I verified the filesystem was moutned as vfat:

/dev/sda1 on /mnt/flash type vfat

Ahhh. Much better. I would prefer to leave it as auto in the event I mount a non-vfat device, but I can always run mount manually or simply create another fstab entry with a different mount point. I could also format the key with ext2 or other Linux filesystem, but then it wouldn’t do me any good in other systems, such as the WinXP machines at work.

Not rocket science by any means, but hopefully that will save at least a few of you a headache or two.

What Do You Think?

 
35 queries / 0.326 seconds.