BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News A Look at APFS, Apple’s New File System for iOS and macOS

A Look at APFS, Apple’s New File System for iOS and macOS

This item in japanese

Among the announcements Apple made at WWDC 2016, its new file system, called APFS, raised a lot of developer interest. According to the preliminary developer documentation that Apple made available, APFS:

is optimized for Flash/SSD storage and features strong encryption, copy-on-write metadata, space sharing, cloning for files and directories, snapshots, fast directory sizing, atomic safe-save primitives, and improved file system fundamentals.

Brief Comparison to HFS+

According to Apple, APFS supports all of HFS+ features and improves them in several ways:

  • Contrary to HFS+, which uses 32-bit file IDs, APFS will support 64-bit inode numbers, which will allow to store over 9 quintillion files on a single volume.
  • Whereas HFS+ is bound to initialize the entire storage of a file system at once, APFS sports an extensible block allocator that enables lazy initialization of its data structure, thus hugely improving performance with large volumes.
  • APFS supports three models of encryption: no encryption, single-key encryption, and multi-key encryption to manage per-file keys and a metadata key.

Additional APFS features that improve on HFS+ are support for sparse files, improved TRIM operations, built-in support for extended attributes.

New Features in APFS

APFS also provides a few advanced features that put it in the same category as modern file systems such as ZFS, which Apple tried to port to OS X a few years ago, and HAMMER:

  • APFS uses a new copy-on-write mechanism aimed to make updates crash-safe.
  • Space sharing allows multiple file systems to flexibly grow on a shared physical volume, without requiring a rigid partitioning.
  • Cloning allows to create copies of files and directories that do no take any additional space until they are modified, in which case only the modified blocks are stored on disk. This behavior is transparently enforced by NSFileManager methods such as copyItemAtURL:toURL:error: and copyItemAtPath:toPath:error:.
  • Snapshots are read-only instances of an entire file system which provide the base for efficient backups. However, no API is available yet for developers to manage snapshots.
  • Atomic saves are able to rename bundles or directories in a single transaction that either succeeds or fails. This new behavior is transparently enforced by NSFileManager methods such as moveItemAtURL:toURL:error: and moveItemAtPath:toPath:error:.

Using APFS

APFS is currently released as a Developer Preview in macOS 10.12, which provides an updated hdutil command able to work with the new file system. This is how you create an APFS partition:

$ hdiutil create -fs APFS -size 1GB foo.sparseimage

Being a developer preview, Apple warns developers of the possibility of malfunctions and data loss when using APFS. Additionally, it has a few limitations, such as:

  • It cannot be used on a startup disk.
  • It is case-sensitive.
  • It does not work with Time Machine, FileVault, or Fusion Drives.

For a detailed introduction to APFS, please refer to this collection of posts by Adam Leventhal.

APFS is scheduled to ship in 2017 and will eventually replace Apple’s almost 20 years old HFS+ file system. 

Rate this Article

Adoption
Style

BT