APFS (Apple File System) Key Features

APFS (Apple File System) is a next-generation file system developed by Apple to meet the needs of today’s realms. It was introduced at Apple’s developers conference (WWDC) in June 2016 and presented with iOS 10.3 a year later, on March 27 2017.

APFS (Apple File System): Key Features with Examples in Simple Words

Since the sensational iPhone 7 (PRODUCT)RED captured all attention, we didn’t notice all features and benefits the new file system brings. APFS supports a range of firmwares, including tvOS, watchOS and replaces a nearly 30 years old HFS (Hierarchical File System) and HFS+ (Journaled Extended) file systems. It comes with 10.3 version of iOS and later (for iPhone/iPod/iPad), and with macOS High Sierra 10.13 and later (for desktops, but currently in beta version). Besides listing the main innovations with comments, we would like to make a point on evident benefits for common users, without all that numbers and geek-specifications. Just “what we will get” in couple words.

By the way, on i-device you will get additional free space on your iPhone/iPad after installing iOS 10.3:

apfs 10

In this article we would like to focus on macOS side of APFS instead of iOS. Today we use to operate tens and hundreds of gigabytes of private data, photos, HD media and store it on high speed flash drives. That’s why Apple File System is primary focused on optimization, speed and low latency for flash (NAND flash in i-devices) and solid-state drives (SSD in Mac), but still can be used with HDD. Due to 64-bit instead of 32-bit, APFS supports large files. And, as we supposed, a lot of security improvements, date resolution in nanosecond, faster animations and possibility to recover data immediately from previous points in past.

You may pick up a quick volumes comparison, published at developers library:

apfs 07

As we said before, APFS is optimized for SSD and will not bring huge difference in speed with common HDD. Here some speed tests with old HDD:

apfs 08

Key features (in no particular order):

Clones

First feature we would like to tell is called “Clones”. It makes copy of a file or directory on the same volume without occupying additional space for it. You may notice similar technology in ZFS file system of Solaris OS from Oracle back in 2005. When you make a copy of a file in HFS/HFS+, system read metadata first and then write it on a free space. Such algorithm overloads main processor and hard drive as well. In APFS system only make a copy of a link to a file (it is called hard link) without duplication of a data. By the way, such cloning (or copying) happens immediately. When you modify the clone or make some changes for it, the file system writes only the data change – therefore new file system can operate with more amounts and variants of “big and heavy” files and demands less space on SSD at the same time.

cloning files

Snapshots

Another innovation around fast data recovery is developed to make operation system work more efficiently and stable. Snapshot is just like “photo of volume” that proceeds in real-time. It is a read-only instance of the file system, offers to revert changes to given point in time. For example, you’ve got a volume on external drive with 2 files: install.dmg and welcome.key presentation. A “snapshot” of this volume will only contain names of the files and the data blocks respond them, so there is no physical information of files in the snapshot. It only contains the names and blocks respond them “in the moment”. Blocks that have been written into the snapshot are closed, so you don’t have a possibility to move, rewrite or delete them anyhow. And if we delete, for example, install.dmg and make some changes to our presentation – original data blocks will not be affected. This mechanism do occupy some additional space, yes – but it offers APFS instantly go back and recover a volume to a point in time a snapshot was created.

file system snapshots

Space Sharing

Imagine you’ve got iMac with 1TB drive and need to install a OS X El Capitan and a beta version of a new macOS High Sierra. Right now (in beta macOS High Sierra with APFS) you can not boot from a APFS-volume or use it for a Time Machine, so you have to create two HFS+ volumes (for example in half, 500GB each). With “Space Sharing” you don’t have to manually set volume sizes with the help of Disk Utility. Inside the logical part of the drive with APFS-volume builds a container that consist all volumes. Those volumes can easily increase or decrease within a container with no action from the user and necessity to manual select volume sizes. Now let’s back to our iMac: if we will have two APFS volumes instead of two HFS+ volumes on iMac’s drive – both operation systems (El Capitan and beta High Sierra, as we spoke) will offer 1TB of free space each. And the free space or rather just space used by the “first” operation system El Capitan will be unavailable to our “second” operation system High Sierra. This solution helps to operate and manage with the amount of volumes more easily, fast and efficient at the same time.

space sharing

Crash Protection (Copy-On-Write metadata) and Atomic Operations (Linearizability)

First, we need to say about this term in concurrent programming. Such operations proceeds in database or operation system uninterruptedly, indivisibly and can not be simplified or divided farther. Atomic operation can not remain “undone” if it interrupted or else: it can only be in a state of “done” or “undone”. POSIX-certifiedsecure file saving take place with next steps: when we save a file in the application, memory data uploads to temporary file on a drive. Then, after the application make sure all data from memory uploaded fully and with no errors, it requests the operation system to make a “rename”. Current renaming operation (or process) is atomic and, as we mentioned above, can only be just completed or uncompleted. To make this, operation system moves a temporary file to a saving place (a file keynote-presentation “MakeMoneyFast.key” or, for another example, pages-document file “Meeting_report.pages” from /var/tmp/meeting_report.pages to ~JohnAppleseed/Documents/meeting_report.pages) and removes old previous one.

atomic safe

But, what happens if we want to save a folder or a bundle (.rtfd or .app)? For example, we’ve got a bundle ~JohnAppleseed/Documents/JohnSarahWedding.rtfd, which contains simple text and a few photos? When we made changes and save them, the application fully overwrites the bundle (and not the only text and photos with changes). But POSIX-saving is not allowed to the place where the data have already exists, so operation proceeds the next way: first, the document moves away from ~JohnAppleseed/Documents/ and gains free space at the same time. After that, the temporary file /var/tmp/JohnSarahWedding.rtfd get saved as an empty space. Such kind of operation is not belongs to atomic and unsecured at all. You will lost the document either operation system errors happens during the saving or you get lost the power source.

non atomic safe

Obviously, you don’t want to loose a document or give a chance that happens. That’s why in APFS we got new, no POSIX-compatibility operation of saving folders that is atomic and secure. When the application proceed to save a folder, a temporary and a regular files changes their own places each other. This operation is atomic and secure, made by file system it shows up the crucial feature of the APFS called Copy-On-Write.

Another demonstration the way COPY-ON-WRITE scheme works:

apfs 4

Encryption

Now, you don’t have to manually use File Vault (that supports only single-key encryption) to protect your data. Apple File System offers new build-in encryption that you can apply to a separate APFS-volumes on your own. You can use different types of encryption to the volume at the same time: no encryption, single-key for user data and metadata and mutli-key for metadata, user data and sections of a file. Depending on type, APFS uses AES-XTS or AES-CBC encryption.

MacOS 10.13 High Sierra beta-version constraints

While iOS 10.3 has got full support of the APFS on board, you don’t have full abilities of the new file system with macOS 10.13 High Sierra (at the moment of July 8, 2017) yet due to a beta-version of it. Here the list of them:

  • You temporary can not use the APFS-volumes as boot volumes on your devices
  • The file system is still case-sensitive. For example, the operation system will distinguish “DOCUMENTS.pages” and “Document.pages” as two separate files that may cause “File Not Found” errors. It sounds not that good, but Apple claimed case-sensitive and case-insensitive variants in final release of macOS
  • You can not use APFS-volumes with Time Machine backups
  • You can not use File Vault encryption for volumes with APFS
  • Fusion Drive technology doesn’t work with APFS right now
  • Apple File System doesn’t directly supports RAID but you still can use APFS-formatted volumes combined with an Apple RAID to support Striped (RAID 0), Mirrored (RAID 1), and Concatenated (JBOD). APFS-formatted volumes can also be used with direct-attached hardware RAID solutions

apfs raid

Well, sounds promising. Apple engineers also work hard in the question of migration from HFS+ to APFS for common users and claimed that the process of migration to the new file system will not take more than 15 minutes. Official and stable release of macOS 10.13 is coming in 2017 – so we are waiting…

What Is APFS? [Video]

Published by macmostvideo on Jun 19, 2017

Comments

So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar