Choosing a Filesystem for Removable Media

To use a removable disk to its fullest, you must use it in conjunction with a filesystem. Chapter 12 describes filesystems in more detail, including information on the advantages and disadvantages of specific filesystems. Some removable media have unusual features that make using some filesystems necessary and using others inadvisable, though, and these issues deserve attention.

Note Tapes are an exception to the filesystem rule; tapes are normally accessed "raw." Typically, you send a tar or similar archive file directly to the tape device, and then you read it back through the same or a companion program. Floppies are occasionally used in the same way, particularly when transferring data between different Unix-like systems that may not share a common filesystem.

Aside from tapes, the most unusual removable media formats, from a filesystem requirement perspective, are CD-R, CD-RW, and recordable DVD media. (From now on, I will refer to all three as CD-R media for simplicity's sake.) Most removable media enable random reading or writing of individual sectors of the disk. Although it's possible to randomly read individual CD-R sectors, randomly writing them is tricky at best, and it is frequently impossible. Instead, these media are normally written all at once; you write an entire filesystem to the disk, complete with all the data that filesystem will ever contain. Subsequent accesses are read-only. In the case of CD-RW and some recordable DVD media, the disc can be erased and rewritten, but this operation wipes out all the existing data on the disc. Wth some filesystems, it's possible to append new data to an already-written disc.

The read-only nature of the created CD-R media means that many normal read/write filesystem features are unnecessary. Therefore, a special read-only filesystem exists for CD-R media: ISO-9660. The upcoming section, "Burning CD-Rs," describes how to create an ISO-9660 filesystem and write it to a CD-R. CD-RW and recordable DVD discs also often use another filesystem, Universal Disk Format (UDF), which supports more in the way of features useful for adding data to an already-created disk. Linux UDF support is not as mature as its ISO-9660 support, though. Two extensions to ISO-9660 are common: Rock Ridge, which adds support for Unix-style file ownership, permissions, and file types, as well as long filenames; and Joliet, which adds support for long filenames as used by Microsoft Windows. Linux supports both Rock Ridge and Joliet, and depending upon your specific needs, you may want to create CD-Rs that use neither, one, or both of these ISO-9660 extensions.

On more conventional removable-media disks, you can theoretically use any of the standard Linux filesystems you might use on a hard disk. One important concern with many media, though, is their limited capacity. Journaling filesystems require the creation of a journal file, which may be quite large. Therefore, most people don't use journaling filesystems on low-capacity removable media. Instead, the four most popular filesystems for non-CD-R removable media are as follows:

FAT The File Allocation Table (FAT) filesystem is the primary filesystem for DOS and Windows 9x/Me. It's also supported by Windows NT/2000/XP and most other OSs. Therefore, FAT makes an excellent choice as a lowest-common-denominator filesystem. FAT is low in overhead, so you can often squeeze more files onto a FAT disk. Typically, you'll mount a FAT disk using the vfat filesystem type code, which enables support for long filenames. This usage doesn't support Linux ownership or permission information, though, so you shouldn't use FAT if preserving this information is important. (The umsdos FAT extension can preserve this information, but its use is rare.)

HFS Apple's Hierarchical File System (HFS) is the Macintosh equivalent to FAT. If you need to exchange files with Mac OS users, HFS is a good choice. Linux's HFS support is not as mature as is its support for many other filesystems, though. Most Macintoshes include FAT support, so you may prefer to use FAT even when exchanging disks with Macintosh users.

The Minix Filesystem Linux's first filesystem was borrowed from the Minix OS, and in Linux bears its name (minix). This filesystem has severe limitations on partition size (64MB) and filename length (30 characters), so it's a poor choice for use on Linux hard disks. It's useful for floppies, though. Because the Minix filesystem imposes very low overhead, you may be able to fit a few more files on a Minix-filesystem floppy than on an ext2fs floppy.

Ext2fs The Second Extended Filesystem (ext2fs) has long been the standard Linux filesystem, and it can be a good choice for use on removable media when they'll be accessed only from Linux systems. By using ext2fs, you preserve all file attributes, including long filenames, ownership, and permissions. Most other OSs have limited support for ext2fs, though, so this filesystem isn't the best choice if you need to exchange files with other OSs.

Tip When creating an ext2 filesystem with the mke2fs command, the-m option specifies the percentage of disk space that's to be reserved for use by root. The default value is5, meaning 5 percent of disk space. This feature is an important safety measure on certain hard disk partitions, but it's unimportant on removable disks. Thus, passing the -mO parameter tornke2fs will increase the amount of disk space accessible to ordinary users of a removable disk.

As a general rule, FAT and ext2fs are the best choices for removable media—FAT is the best when you're exchanging data with non-Linux systems, and ext2fs is best when you're sure the data will be read only by Linux systems. On rare occasions, you might want to use the Minix filesystem, HFS, tar, or even something more exotic.

0 0

Post a comment