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 the 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 its beta version). Besides listing the main innovations and commenting on them, we would like to make a point of highlighting evident benefits for common users, without all that numbers and geek-specifications. Just “what we will get” in a couple of 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 the macOS side of APFS instead of iOS. Today we use it 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 primarily focused on optimisation, 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 nanoseconds, faster animations and the possibility to recover data immediately from previous points in the past.

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

apfs 07

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

apfs 08

Key features (in no particular order):

Clones

The first feature we would like to talk about is called “Clones”. It makes a 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+, the system reads metadata first and then writes it on free space. Such an algorithm overloads the main processor and hard drive as well. In APFS the system only makes a copy of a link to a file (it is called hard link) without duplication of data. By the way, such cloning (or copying) happens immediately. When you modify the clone or make some changes to it, the file system writes only the data change – therefore the 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 the operation system work more efficiently and stably. 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 have 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 that respond to them, so there is no physical information of files in the snapshot. It only contains the names and blocks that respond to them “in the moment”. Blocks that have been written into the snapshot are closed, so you do not 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 does occupy some additional space, yes – but it offers APFS instantly going back and recovering a volume to the point in time a snapshot was created.

file system snapshots

Space Sharing

Imagine you have got iMac with 1TB drive and need to install the OS X El Capitan and a beta version of a new macOS High Sierra. Right now (in beta macOS High Sierra with APFS) you cannot 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 do not 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 get 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 discussed) 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 the amount of volumes more easily, faster and in more efficient ways at the same time.

space sharing

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

First, we need to talk about this term in concurrent programming. Such operations proceed in databases or operation systems uninterruptedly, indivisibly and cannot be simplified or divided further. The atomic operation cannot remain “undone” if it is interrupted or else: it can only be in a state of “done” or “undone”. POSIX-certifiedsecure file saving takes place with the next steps: when we save a file in the application, memory data uploads to a temporary file on a drive. Then, after the application makes sure all data from memory uploaded fully and with no errors, it requests the operation system to make a “rename”. The current renaming operation (or process) is atomic and, as we mentioned above, can only be just completed or uncompleted. To achieve this, the 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 the 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 make 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 existed, so the operation proceeds the following 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 gets saved as an empty space. Such kind of operation does not belong to the atomic group of operations and remains completely unsecured. You will lose the document through either operation system errors which happened during the saving or you if you lose the power source..

non atomic safe

Obviously, you do not want to lose a document or give a chance to it to happen. That is why in APFS we got a new, no POSIX-compatibility operation of saving folders that is atomic and secure. When the application proceeds to save a folder, a temporary and a regular file trade their places with each other. This operation is atomic and secure, made by the file system, it shows up as the crucial feature of the APFS called Copy-On-Write..

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

apfs 4

Encryption

Now, you do not have to manually use File Vault (that supports only single-key encryption) to protect your data. Apple File System offers new built-in encryption that you can apply to separate APFS-volumes on your own. You can use different types of encryption of 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 do not 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 is 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 the final release of macOS
  • You cannot use APFS-volumes with Time Machine backups
  • You cannot use File Vault encryption for volumes with APFS
  • Fusion Drive technology does not work with APFS right now
  • Apple File System does not directly support 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 on 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