9.1. FilesystemsEach device stores data in a form that makes sense for that device. A hard drive usually writes data to the platters using a series of sectors and tracks. A CD writes data in one continuous track that spirals from the inside of the disk out. A compact flash card simply holds data in a matrix of memory cells on the chip. For efficiency reasons, the data that makes up a file may be scattered across various sectors of a hard drive instead of being nicely organized in one lump. The role of a filesystem is to mediate between the world of the device where data resides and the world of the Finder where data shows up in an organized form as files and folders. 9.1.1. The Mac OS Extended Filesystem (HFS+)The primary filesystem used by Mac OS X is the Mac OS Extended filesystem, also known as HFS+. Introduced in Mac OS 8.1 and upgraded for Panther with journaling features, HFS+ allows long filenames with up to 255 Unicode characters, scales up to 2 TB of data on a filesystem, can handle 2 billion files, and allows for files up to 2 GB in size. In addition, each folder in an HFS+ filesystem can handle a maximum of 32,767 files. When HFS+ was first introduced, the size of these figures was way beyond what the state-of-the-art filesystems of the time could handle.
One of the quirks of HFS+ is that it is a case-preserving and case-insensitive filesystem. This means you can't have files named Readme and README in the same directory. This is similar to the way the filesystems work on Windows, but is different from the traditional Unix case-preserving filesystems where you can have both a Readme and README file in the same directory. In most cases, this isn't a problem, because people don't tend to place two files with the same name into a directory. Another difference between the HFS+ filesystem and most others is that HFS+ supports the concept of resource forks . Resource forks were used on the old Mac OS to store all sorts of metadata for a file, such as icons. Although resource forks were a good idea, they didn't catch on with the rest of the world. Unix and Windows filesystems don't have an equivalent concept, so Apple adopted a similar policy and recommends that all applications that write files should avoid using resource forks. However, the filesystem still supports resource forks, mainly so older applications that rely on them can run just fine. In all likelihood, many applications will continue to use resource forks to some degree or another. You can read more about resource forks in Chapter 8. 9.1.1.1. JournalingIf something went wrong with the Mac OS X filesystem in earlier releases, a long and intensive fsck process would be run the next time the machine started up. For example, if the machine was powered off incorrectly or if the system crashed, it was pretty
common to wait a long time at the initial gray boot screen. And if the filesystem truly got itself into a bad state, manual intervention was necessary to fix the filesystem. Journaling, which was first introduced in Mac OS X Server 10.2.2 and has been the default filesystem type since Mac OS X Panther, implements a scheme that keeps the filesystem structure of your disk safe even in the face of an unexpected shutdown or system crash. When your Mac reboots, disk repairs are made as needed. The filesystem does this by keeping a continuous record of changes to the files on a disk in a journal file in a designated area of the disk. If a computer starts up and the disk is in an inconsistent state, the journal is used to quickly restore the disk to its previous known state. This record keeping does come with a slight performance overhead. It typically takes 10 to 15 percent longer to write small files with journaling than without it, but in most cases, the slight performance loss is well worth the safety gained. Journaling also allows other optimizations to be made in the disk I/O system, which more than makes up for the performance penalty. It is important to note that, in the face of unexpected shutdowns, journaling won't necessarily protect the data being written to disk. By protecting the filesystem, journaling protects all the data that is already on your disk from being lost. Any changes you may have made to a document after its last save, for example, are most likely lost. 9.1.1.2. FragmentationIn the past 20 years of personal computing, a common theme with hard disks has been the issue of file fragmentation . Early hard drive formats were extremely susceptible to performance problems manifested over time because file data was often split and scattered across the hard drive. As files grew larger than their original allocation, the filesystem was forced to put parts of those files onto different sectors of the disk. Even more modern formats such as HFS+ can exhibit performance slowdowns over time as a disk is used more. The following two optimizations to the HFS+ driver were introduced for Mac OS X Panther (v10.3) when using a journaled filesystem:
This meansat least for most files most of the timea separate defragmentation program isn't needed. It also means you should always enable journaling on your drives so you can take advantage of these features. Fortunately, when installing Tiger, the default filesystem type is Mac OS Extended (Journaled), so you should be set.
9.1.2. Other Supported FilesystemsIn addition to HFS+, Mac OS X supports several other types of filesystems, each of which has its own unique characteristics:
|