APFS: What you need to know

Every computing device made by Apple uses a file system to read and write data. Currently, most Mac users are familiar with the term HFS+, where the HFS stands for Hierarchical File System. That file system has been around for almost 30 years in both Unix and OS X, so it's not particularly engineered for today's devices -- from Apple Watch to Mac Pro. So Apple has announced a new file system -- Apple File System or APFS -- that will be part of all devices in the future, shipping on all starting in 2017. macOS Sierra will provide most Mac users with their first close-up look at APFS.

If any Apple World Today readers are considering being macOS Sierra public beta testers, let's get a few caveats out of the way. Currently, APFS volumes can't be used as startup disks, Time Machine volumes, or part of a Fusion Drive. To top it all off, you can't use File Vault encryption on APFS volumes as it has its own encryption scheme. But even more scary at the present time is that the early version of APFS is case-sensitive and that cannot be disabled. HFS+ is different from the majority of Unix file systems in that it can be configured to be case-insensitive, and in fact running OS X with case-sensitive HFS+ can cause issues. So be forewarned -- only try APFS from your beta version of macOS Sierra on an external volume that doesn't contain anything important.

So what are some of the "big deals" about APFS?

It's based on inodes with 64-bit inode number support. What's an inode? From Wikipedia, "In a Unix-style file system, the inode is a data structure used to represent a filesystem object, which can be one of various things including a file or a directory. Each inode stores the attributes and disk block location(s) of the filesystem object's data. Filesystem object attributes may include manipulation metadata (e.g. change, access, modify time), as well as owner and permission data (e.g. group-id, user-id, permissions)"

APFS supports nanosecond time stamp granularity. That means that a record of file system writes can be tracked with granularity of a nanosecond -- one billionth of a second. Current HFS+ timestamps have a granularity of one second.

Crash Protection. When APFS is writing data to a hard disk or SSD, it copies metadata that describes the file or folder attributes. If something happens while the file system is writing to a disk -- like losing power or a severe crash -- Crash Protection ensures that what APFS writes to the drive and writes to the file system journal are completely in sync.

Sparse File Support. In layman's terms, a sparse file is a type of computer file that tries to use file system space more efficiently when the file is mostly empty. The advantage of sparse files is that storage is only allocated when it's needed, and large files can be created even if there's insufficient free space.

Trim Support. Trim allows an operating system to tell a solid-state drive (SSD) which blocks of data are no longer considered "in use" and can be wiped internally. OS X only supported Trim for Apple SSDs; it's expected that macOS Sierra and APFS will allow Trim support on both Apple and third-party SSDs without the need for special utilities. 

Mandatory Use of SMB for Sharing APFS Volumes on a Network. Apple's used a proprietary network protocol called Apple Filing Protocol or AFP as long ago as Mac OS System 6 for file sharing over networks. OS X -- and presumably macOS Sierra -- supports AFP as well as SMB, NFS, FTP and WebDAV for file sharing. Well, it appears that any APFS volume shared on a network will need to use SMB. Goodbye, AFP.

Improvements in Encryption. At the present time, if you wish to encrypt data on a Mac you need to use File Vault and encrypt the full disk. APFS is going to allow native encryption that can be scaled to individual files depending on how secure you need them to be. There will be three possible modes; no encryption, single-key encryption, and something known as multi-key encryption with per-key files and another key for sensitive metadata. That latest cat GIF can be unencrypted, while sensitive documents can receive the highest level of encryption. All Apple devices - not just the Mac - will have the option of having encryption applied to files. 

Fast Directory Sizing. You know how it can take several minutes on a Mac to find out how much space is being used in a directory or on a volume when you do a "Get Info"? That becomes a thing of the past with fast directory sizing in APFS, as it gives macOS a way to query the size of a directory and its child objects quickly, instead of waiting for stat calls to provide the answers as in the current file system.

Snapshots. At any point in time, APFS can be asked to throw off a read-only instance of the file system, and as the state of the file system becomes differentiated from the snapshot, the changed blocks become part of the snapshot. Microsoft currently uses something similar called "shadow copies". There is speculation that this will have a huge effect on how Time Machine works. Currently, it uses a rather old-fashioned system of hard links that the Time Machine software builds and maintains. A future (possibly in macOS Sierra) version of Time Machine could just capture snapshots instead.

Clones. Clones are different from snapshots in that they can be written to. APFS is able to create file or directory clones instantly without needing to wait for data to be copied. A directory or file clone stores all changes made between it and the original object, so you have a writable, editable copy of a file or directory at any point in time. This is a great way for developers and users to capture document revisions or versioning of any other projects in progress.

Write Coalescing. This is something that's been available on enterprise disk arrays for a long time, and it gives a file system some freedom in how it commits data to a disk. It can take a number of short and potentially totally unrelated writes, then combine them into one long write that uses the physical storage much more efficiently.

Space Sharing. From what I understand, this allows multiple volumes to be created out of the same physical space. Rather than needing to size a partition before using it, a volume can be created and then it grows as space is added to it. This means that additional physical storage can be added later to keep up with the growth of the volume without having to resize the logical volume. 

It's still the early days of both macOS Sierra and APFS, with both only announced in the last 24 hours. The first WWDC session on APFS occurred just hours ago. As those of us here at Apple World Today have a chance to play with both macOS Sierra and APFS, we'll have more information on how the new next-generation file system affects your life.