The file systems of macOS
As noted in the article on Filesystem basics, an operating system is one of the key factors that impacts the choice of an appropriate storage format. And when it comes to macOS, the available options are restricted by the closed nature of the Apple ecosystem. All modern Macs running macOS 10.14 and later employ APFS by default, which is also shared with the rest of the Apple’s product line – the devices based on iOS, iPadOS, tvOS, and watchOS. At the same time, HFS+, the previous de facto standard, is still supported to preserve compatibility with older machines. Here you can familiarize yourself with these two FS types and their organizational principles.
Please note: Though macOS allows formatting removable media in FAT/FAT32 or exFAT and offers their read-write support, these filesystems are described in another article in view of their direct relevance to Microsoft Windows.
APFS (Apple File System) was introduced in 2017 alongside the launch of macOS High Sierra 10.13 and designed exclusively for usage with Apple products, including Macs, iPhones, iPads, Apple Watches and Apple TV.
The new-generation format aims to work efficiently with flash memory and solid-state drives. And this comes as no surprise, since the vast majority of modern Apple devices employ SSDs as their primary storage. In addition, APFS addresses the fundamental issues of HFS+, its predecessor on the aforementioned appliances, and offers a lot of data integrity and space-saving features.
The filesystem makes use of the Copy-on-Write (CoW) technique, which minimizes the risk for its corruption. Prior to APFS, the changes were written straight to the storage blocks occupied by the existing objects. By contrast, APFS never overwrites them in place – it creates their copies and performs the necessary changes onto a new location on the storage, ensuring that all modifications are protected from possible crashes.
APFS relies on the Container as a principal element for storing data. A single Container can hold multiple volumes (filesystems) that share the storage space available in it. The information about the number of blocks in the Container, the block size, etc. is stored in the Container Superblock, which also acts as an entry point into each volume. The allocation of blocks in the entire Container is tracked with the help of one common Bitmap.
At the same time, volumes have their own Volume Superblocks and independent structures for storing data and metadata. All files and folders in them are managed using binary search tree structures, referred to as File and Folder B-Trees. The nodes in such trees store keys and values.
The content of any file is represented by at least one extent, which keeps the information about its starting location and length in blocks. All extents in the volume a handled by a dedicated B-tree.
Nonetheless, in spite of its optimized structure and other apparent benefits, APFS has been developed with flash storage in mind and might not be the best alternative for mechanical hard disk drives. On top of that, it may cause their excessive fragmentation and thus degraded performance. Also, it is impossible to access an APFS volume under previous versions of macOS – macOS Sierra 10.12 or earlier, which may become an obstacle in certain usage scenarios.
HFS+ (Hierarchical File System Plus), also known as Mac OS Extended, was released in 1998 with Mac OS 8.1 and served as a default filesystem for Mac computers, as well as for iPod and Xserve products, before it was replaced by APFS in macOS High Sierra 10.13. Originally, it was just an extension to the legacy HFS format, which is now almost forty years old.
HFS+ implements the journaling mechanism to prevent corruption of its structures. All modifications are documented in the Journal area, which makes it possible to restore them promptly in case of unexpected events, like power failures.
One of the core structures of HFS+ is called the Volume Header, which is available at the beginning of an HFS+ volume. It contains the general FS parameters along with the locations of other crucial elements. Most of the other service information is organized into special files that can be found in different parts of the volume and are mainly represented by B-trees.
The whole storage space in HFS+ is split up into equal allocation blocks. The state of each allocation block is recorded in the bitmap-like Allocation File. As a rule, such blocks are assigned to files in continuous groups, which helps to reduce their fragmentation.
Files may have two sets of data associated with them. The actual file’s content is referred to as a data fork, while the additional information about it is stored as a resource fork. A contiguous sequence of blocks belonging to a fork is called an extent, which is represented by its starting position and number of blocks in it.
The Catalog File has records for every file and directory in the filesystem. Such records contain the majority of metadata and also the first eight extents of each fork. Further extents, if available, are kept in the Extents Overflow File. And, finally, additional attributes related to files and folders are stored in the Attributes File.
Among other things, HFS+ supports multiple references to the same file’s content, known as hard links. Unlike regular files, hard links do not require any extra storage space – they exist in the Catalog File as pointers to the original file, which is itself moved to the hidden root directory.
Although HFS+ has already become outdated, it provides the benefit of reverse compatibility, allowing to preserve access to computers with older versions of macOS. Therefore, it is not likely to fall out of use very quickly.
Hint: The details related to the possibility of data recovery from these FS types can be found in the articles about the peculiarities of data recovery depending on the operating system and chances for data recovery. If you’re interested in the practical side of the procedure, please, refer to the guide on data recovery from macOS.
In case you want to learn more about the native formats of other popular operating systems, please refer to the following articles:
The filesystems of Windows: FAT/FAT32, exFAT, NTFS, ReFS, HPFS
The filesystems of Linux: Ext2, Ext3, Ext4, XFS, Btrfs, F2FS, JFS, ReiserFS
Last update: April 19, 2023