Apple File System (APFS) is a proprietary file system developed and deployed by Apple Inc. for macOS Sierra (10.12.4) and later, iOS 10.3, tvOS 10.2, watchOS 3.2, and all versions of iPadOS. It aims to fix core problems of HFS+ (also called Mac OS Extended), APFS's predecessor, which had been in use since 1998. APFS is optimized for solid-state drive storage and supports encryption, snapshots, and improved handling of metadata integrity.
History Apple File System was announced at Apple's developers’ conference (WWDC) in June 2016 as a replacement for HFS+, which had been in use since 1998. APFS was released for 64-bit iOS devices on March 27, 2017, with the release of iOS 10.3, and for macOS devices on September 25, 2017, with the release of macOS 10.13. Apple released a partial specification for APFS in September 2018 that supported read-only access to Apple File Systems on unencrypted, non-Fusion storage devices. The specification for software encryption was documented later.
Design The file system can be used on devices with relatively small or large amounts of storage. It uses 64-bit inode numbers, and allows for more secure storage by using a technology called Data Protection. The APFS code, like the HFS+ code, uses the TRIM command for better space management and performance. It may increase read-write speeds on iOS and macOS, as well as space on iOS devices, due to the way APFS calculates available data.
Partition scheme APFS uses the GPT partition scheme. Within the GPT scheme are one or more APFS containers (partition type GUID is 7C3457EF-0000-11AA-AA11-00306543ECAC). Within each container there are one or more APFS volumes, all of which share the allocated space of the container, and each volume may have APFS volume roles. macOS Catalina (macOS 10.15) introduced the APFS volume group, which are groups of volumes that Finder displays as one volume. APFS firmlinks lie between hard links and soft links, and link between volumes. In macOS Catalina the System volume role (usually named "Macintosh HD") became read-only, and in macOS Big Sur (macOS 11) it became a signed system volume (SSV) and only volume snapshots are mounted. The Data volume role (usually named "Macintosh HD - Data") is used as an overlay or shadow of the System volume, and both the System and Data volumes are part of the same volume group and shown as one in Finder.
Clones Clones allow the operating system to make efficient file copies on the same volume without occupying additional storage space. Changes to a cloned file are saved as delta extents, reducing storage space required for document revisions and copies. There is, however, no interface to mark two copies of the same file as clones of the other, or for other types of data deduplication. The feature is automatically available when a user copies any files using the Finder application, which is macOS's default file manager, but not when using the cp command. To do that on the command-line, the cp utility on macOS has a -c parameter that allows it to use the clonefile system call.
Snapshots APFS volumes support snapshots for creating a point-in-time, read-only instance of the file system.
Encryption Apple File System natively supports full disk encryption, and file encryption with the following options:
no encryption single-key encryption multi-key encryption, where each file is encrypted with a separate key, and metadata is encrypted with a different key.
Increased maximum number of files APFS supports 64-bit inode numbers, supporting over 9 quintillion files (263) on a single volume.
Data integrity Apple File System uses checksums to ensure data integrity for metadata but not for the actual user data, relying instead on error-correcting code (ECC) mechanisms in the storage hardware.
Crash protection Apple File System is designed to avoid metadata corruption caused by system crashes. Instead of overwriting existing metadata records in place, it writes entirely new records, points to the new ones and then releases the old ones, an approach known as redirect-on-write. This avoids corrupted records containing partial old and partial new data caused by a crash that occurs during an update. It also avoids having to write the change twice, as happens with an HFS+ journaled file system, where changes are written first to the journal and then to the catalog file.
Compression APFS supports transparent compression on individual files using Deflate (Zlib), LZVN (libFastCompression), and LZFSE. All three are Lempel-Ziv-type algorithms. This feature is inherited from HFS+, and is implemented with the same AppleFSCompression / decmpfs system using resource forks or extended attributes. As with HFS+, the transparency is broken for tools that do not use decmpfs-wrapped routines.
Space sharing APFS adds the ability to have multiple logical drives (referred to as volumes) in the same container where free space is available to all volumes in that container (block device).
Limitations While APFS includes numerous improvements relative to its predecessor, HFS+, a number of limitations have been noted.
Limited integrity checks for user data APFS does not provide checksums for user data. It also does not take advantage of byte-addressable non-volatile random-access memory.
Performance on hard disk drives Enumerating files, and any inode metadata in general, is much slower on APFS when it is located on a hard disk drive (HDD). This is because instead of storing metadata at a fixed location like HFS+ does, APFS stores them alongside the actual file data. On SSDs, this fragmentation of metadata is inconsequential due to their lack of moving parts, but on HDDs, it leads to substantial performance degradation as the drive's read/write heads must physically seek out scattered data fragments. Besides that, a key feature of APFS is "copy-on-write," which allows for rapid file duplication by creating references to the original data rather than copying it outright. This feature enables functionalities like snapshots and quick file copies. When files are modified after being copied, APFS creates new extents (data blocks) for the changes, leading to more fragmentation over time. This issue is exacerbated with applications like Time Machine, which creates multiple versions of files, further increasing fragmentation and slowing performance. As a result, APFS is generally not recommended for use on HDDs, particularly for workloads involving frequent file modifications, copying, or snapshot usage.
… excerpt ends here. Continue reading the full article.