How to set up smartphones and PCs. Informational portal

APFS is a new file system from Apple. Apple File System (APFS)

At yesterday's WWDC 2016 presentation, Apple showed new versions of macOS (Sierra) 10.12, iOS 10, tvOS 10, watchOS 3, Swift Playgrounds, an app for teaching children to code, and new emoji.

It would seem that nothing interesting. However, Apple still rolled out something fundamental. The most significant development of all mentioned at the presentation is the next generation Apple File System (APFS) file system in the macOS (Sierra) 10.12 operating system.

Shortly after the presentation, the developer site published documentation with the main characteristics and description of the file system, which repeats certain functions of the powerful free ZFS file system.

Apple computers now use the HFS+ file system, an extended version of HFS (Hierarchical File System), created over 30 years ago. Like its predecessor, HFS+ uses a tree structure called a B* tree to store most of its metadata. Hence the name "hierarchical file system".

The official introduction of HFS + took place on January 19, 1998, along with MacOS 8.1. Since 2002, logging has been implemented in the system to improve the reliability of information storage. Starting with OS X 10.3, logging is enabled by default, and it is now possible to work in case-sensitive mode.

Until OS X 10.7, developers continued to refine HFS+ and implement new features for OS X at the file system level. But the fact remains: HFS was originally developed in the days of floppy disks and spinning hard drives, when file sizes were measured in kilobytes or megabytes. Today, many people work with SSD drives, where millions of files are stored - gigabytes or terabytes of data. The requirements for the file system are completely different. Instead of refining the old code, Apple decided to finally write a new file system from scratch.

The new generation APFS file system is still at the stage developer preview, that is, it is not planned to roll out to mass use in the near future. An APFS volume cannot currently be used as a boot drive, nor can it be used in a Time Machine backup system, in Fusion Drive, or with File Vault encryption. But you can for a regular non-boot volume.

There is still a long refinement and testing ahead, but only then APFS will become the main Apple file system for decades to come.

APFS, unlike HFS +, initially distinguishes the case of characters in the names of files and folders, and this feature cannot be disabled. This should be kept in mind by anyone who decides to use APFS.

Main characteristics

The official documentation lists the general characteristics of the APFS file system in comparison with HFS+.

Containers and volumes

Container is the main object for storing data in APFS. Containers are usually exactly the same as GUID Partition Table (GPT) entries, and have their own crash protection and disk space allocation scheme. Each container contains one or more volumes or file systems, each with its own namespace, that is, a set of files and directories.

APFS does not directly support software RAID, but it can be used with Apple RAID volumes to support Striping (RAID 0), Mirroring (RAID 1), and Concatenation (JBOD).

64-bit inodes

64-bit inodes significantly increase the namespace compared to 32-bit inodes in HFS+. The 64-bit APFS file system supports over 9 quintillion files per volume. This should be enough for everyone, as Bill Gates said.

Nanosecond timestamps

In APFS, the accuracy of timestamps (timestamps) has been significantly increased. APFS supports timestamping with nanosecond precision. For comparison, in HFS + timestamps were set with an accuracy of up to a second.

Nanosecond timestamps are very important in modern file systems because they help to implement atomicity and atomic transactions - one of the main ACID requirements for a transactional system (for example, for a DBMS). Atomicity ensures that no transaction is partially committed to the system. Either all of its sub-operations will be executed, or none of them will be executed.

Failure protection

APFS implements an innovative copy-on-write metadata scheme that Apple calls "Crash Protection". It ensures that changes to the file system and journal writes remain in sync if something happens during the write, such as a power outage.

ZFS copy-on-write scheme

Sparse files

A file with the "sparse" attribute assumes the content of blocks of zero bytes, not stored on the drive, but implied. HFS+ did not have support for sparse files.

Extended Attributes

APFS has built-in support for extended file attributes, which in HFS+ was implemented through the Attributes file, that is, through the B-tree.

Encryption

Apple states that encryption is a fundamental feature that is built into APFS at the file system level. For each volume in the APFS container, one of the encryption models is installed: no encryption, single key encryption, multi-key encryption. In the latter case, separate keys are used to encrypt files and metadata. Depending on the hardware, APFS uses the AES-XTS or AES-CBC encryption mode.

Cloning files and directories

Cloning - almost instantaneous copying of a file or directory, which does not require additional storage space. When a clone is modified, the file system only records the data change. Thus, the new file system can store many versions of large files while taking up less disk space.

Snapshots

Snapshots are read-only snapshots of the file system on a volume. The operating system can use snapshots for a more efficient backup procedure. That is, finally, Time Machine will work normally (quickly).

Of course, APFS is significantly inferior in its capabilities to the 128-bit ZFS file system that Linux, FreeBSD and other free operating systems support, but this is a step in the right direction on Apple's part.

It is strange that the preliminary documentation does not mention the compression function, which HFS +, by the way, supports.

Apple tried to port ZFS to OS X for a long time, there was an active discussion on the ZFS mailing lists, preliminary snapshots were published for the next version of OS X. Later, an OpenZFS implementation was made for OS X (O3X) and MacZFX.

The ZFS file system is open source, and Apple may well have borrowed some of the ideas for the APFS file system. The open source implementation for APFS is not ready yet, Apple plans to document and publish the APFS format in 2017.

The first formal session of WWDC will take place tonight, where developers will be shown in more detail the new features of APFS.

iOS 10.3 and macOS Sierra 10.12.4, on Monday, run on the new Apple File System, or APFS. At first glance, there is nothing special about this - the main thing is that the devices after the update do not turn into “bricks”.But there is more to the transition to the new system than you think..

What is Apple File System

Apple File System is a new file system thatwhich will be used on all devices from Apple Watch to Mac. It is “sharpened” for flash memory and has replaced the outdated HFS +. The main innovations of APFS: improved encryption algorithms, memory optimization, crash protection, file and folder cloning functions, andsmart use of space. In practice, this will provide more stable operation of the OS, increase the speed of reading / writing data, and further protect user information.

Why Apple is moving to APFS

The 30-year-old HFS+, on which the file systems of modern Apple gadgets are based, was created for computers with multiple drives that handled large amounts of files. On mobile devices like the iPhone or Apple Watch, the priorities are different - users need applications to open quickly, and the OS to respond to requests in time. To do this, APFS uses features such as cloning (instant copying of a file or directory, which does not require additional storage space) and sparse (data compression, which saves disk space and increases write speed). And due to the use of "snapshots" (read-only "casts" of the file system in the volume), backups will be accelerated, namely the creation of backups using Time Machine.

APFS is designed to expand further. Unlike HFS+, which uses a 32-bit write directory, APFS uses a 64-bit inode (this is such a data structure in file systems). In other words, APFS will be able to store 9 quintillion (million trillion!) files, which is not so important for iOS devices, but will be more than enough for the next ten years for macOS and external drives.

What are the benefits for users

In addition to a faster and more stable operation of the operating system, users will have access to reliable data encryption tools on the disk. Thanks to APFS, iPhones will no longer turn into "bricks" after unsuccessful updates - Apple will protect the data on the drive from damage caused by failures. Finally, using the Space Sharing feature, all disk volumes will be able to "share" free space.

UiPservice engineer Vladislav Yudchenko gave a comment to the UiP editors:

“APFS will enable OSes to crash less, it copies files quickly and optimizes space. So far, the difference will not be so noticeable, but in new updates it will become noticeable. We’ll get used to it soon, we won’t even notice the transition of all devices to APFS ”

For example, the second system (via Bootcamp) you have Windows installed and youallocated 100 GB for it. With the Apple File System, you no longer have to manually reallocate your allocated storage space. If 100 GB is not enough, the system itself will “take away” the required amount of free disk space. At the same time, the function of cloning files and folders will allow you to quickly copy and move data.

Limitations of the Apple File System

You can't format system drives in APFS right now. Hybrid Fusion Drive, FileVault and Time Machine functions do not support the new file system.

How to start using APFS

If you have updated your iPhone or iPad to iOS 10.3, the device is already using the Apple File System. With a Mac, it's more complicated, here APFS is something of a beta version. You can format an external drive, SD card or flash drive, and even then only using the Terminal. In a word, it is better not to experiment yet.

Denotes Apple's new file system and will eventually be used across all of the company's major platforms. But why is Apple using it? What is so special about her? This article is dedicated to this topic.

Apple File System

The abbreviation APFS stands for Apple File System. It replaces the file system, and over time, this file system will become an integral part of iOS, tvOS, and watchOS - that is, it will be used in the entire line of devices: from computers, iPhone, iPad, Apple TV to the Apple Watch device.

Currently, iOS 10.3 is the only platform available to everyone that uses the APFS file system.

APFS can be integrated on all platformsApple.

The HFS+ file system appeared in 1998 and is now almost 20 years old. It has become a relic of a bygone era. Designed in the Mac era, it has been refined for use on the iPhone, Apple Watch, and Apple TV.

But a lot has changed in the last 20 years. We have moved from hard drives to SSDs, the software is no longer distributed on CDs, but simply downloaded. Our device backups are now stored in cloud services.

Optimized for flash drives

Almost every new device that Apple sells runs on a flash drive these days, including most Macs. And APFS was designed to work with flash-based storage devices. Therefore, we will see an improvement in parameters such as read and write speed, and an increase in overall reliability when it comes to storing and transferring information.

main feature: System snapshots and cloning

The two main features of APFS are the ability to take "snapshots" of the system and the ability to clone data.

A snapshot is a one-time, read-only state of a file system.

Using clones, APFS will be able to create quick copies of the same partition without using additional disk space.

Minimum waiting time

APFS has a minimum latency. And this means that operations such as launching applications and loading data will be noticeably faster. Which, in turn, will lead to a reduction in waiting time - we will see less of the spinning waiting wheel in iOS and the beach ball icon in Mac OS.

Freeoverflowing disksections

If you use disk partitions on your Mac, then APFS can make your life a little easier. If you run out of free disk space on one partition, then APFS can automatically use the free space of another partition, because APFS creates special containers around each disk partition.

Encryption is everything

APFS was primarily designed for strong encryption. It supports both single key and multiple encryption keys.

Developments for the future

HFS+ supports 32-bit metadata file. APFS supports 64-bit inode numbers. APFS was designed to work in the future and will work even better over time with the release of appropriate updates.

FirmwareiOS 10.3 gives you back disk space

Switching to APFS has one distinct advantage. You get disk space at your disposal - the amount of space saved will depend on how full your disk is. Some managed to return a couple of gigabytes after the update.

APFS for Mac OS is still in beta

iOS is already using the new file system, and for Mac OS the new file system is only in very early beta. And Apple will have to make a lot of effort to convert Mac computers to use APFS. Access to the file system in iOS is closed to outsiders, while Mac OS uses an open, editable file system. In other words, APFS in practice may encounter various edge cases that Apple is not even aware of yet. We hope that all these problems will be resolved during the beta testing period. You can try the beta version in action. True, it is not quite ready for everyday use. APFS does not support boot disks, Time Machine, FileVault encryption, or Disk Fusion mode.

Yes, you need to updateiOS 10.3

Currently, iOS 10.3 is the only way to try APFS in action. And despite the fact that this is a completely new file system, it is nevertheless worth switching to. This update has been tested for several weeks by a large number of beta testers and everything speaks in favor of switching to the updated version. The transition itself is quite smooth, fast and without data loss. However, before updating, we recommend that you back up your data using the appropriate services of the iTunes application or iCloud cloud storage (which is recommended anyway), just in case.

How about youAPFS?

At the last WWDC, Apple introduced a new file system - the Apple File System, or APFS. Although HFS+ is used on all Apple products (and will be used for at least another year, APFS is scheduled for release in 2017), HFS+ does not meet the requirements of modern file systems. She is over 30 years old, she was created for a time when floppy disks and hard drives were considered the latest technology. To use HFS+ on iOS, tvOS, and watchOS, Apple had to add completely third-party functionality not supported on macOS, such as file-by-file encryption.

So many features have been added to the new APFS that it is dizzying: optimization for Flash and SSD, protection against data loss during a crash by increasing the number of atomic operations, built-in support for several types of encryption, greatly reduced response time, fast estimation of the size of files and folders - the list goes on and on. In this article, we will look at four, in our opinion, the most interesting features of the new file system.

Secure copy-on-write

To begin with, we have to deal with a few key terms. Atomic operations- These are operations that are performed in a file system or database inseparably, and it is impossible to simplify them. An atomic operation cannot remain unfinished if it is interrupted. Such an operation is either performed completely or not performed at all. POSIX Compliant Secure Atomic File Saving is performed as follows - when we work with the application and save the file, the data from memory is unloaded into a temporary file on disk. When the application is sure that the data was uploaded completely and without errors, the application queries the file system for renaming. The rename operation is atomic, it will either be completed completely or not performed at all. When renaming, the following happens: the file system moves the temporary file to a save location (say, from /var/tmp/Batcave_shopping.pages to ~fedor/Documents/Batcave_shopping.pages) and then deletes the old file.

However, what if we save not a file, but a folder or a Bundle (for example, .rtfd or .app, also, in essence, folders)? Suppose we are working with the document ~fedor/Documents/AlfredHappyBirthday.rtfd. This is a Bundle, we have text and some images in it. When we make changes and save them, the application overwrites the entire Bundle, not just the changed text or image. POSIX requirements don't allow you to rename a folder to somewhere where the data already exists, so you have to resort to tricks. The document is moved out of ~fedor/Documents/ to free up space, then the temporary file in /var/tmp/AlfredHappyBirthday.rtfd is renamed to empty space. Such an operation is non-atomic and unsafe. If a system error occurs or the computer loses power during an operation, the document will be lost.

Obviously, such a solution is undesirable. Therefore, a new, POSIX-incompatible, atomic safe folder save operation was introduced in APFS. When an application asks to save a folder, the temporary and permanent files are swapped. This is done by the file system, and such an operation is atomic.

This is the function of secure Copy-on-write - one of the most important innovations in APFS.

Cloning and snapshots

If you need a copy of a file or folder, you right-click on it and select Duplicate. In HFS+, this means that the file system reads all data and then writes it to free space. This approach wastes space inefficiently and wastes the disk and processor in vain. In APFS, when you duplicate data - via Duplicate or just ⌘C, ⌘V - the file system only copies the link to it (the so-called hard link), and the content is not duplicated. Such an operation is called cloning. Thanks to cloning, a duplicate data or folder appears almost instantly, and takes up a negligible amount of free space. If you make changes to the original or clone, the file system will write the changes and redirect the link accordingly, while the original part of the data will remain intact. In APFS, the clone operation is atomic.

Snapshots is a specific snapshot of a volume that stores information about the data on that volume at a particular point in time. The easiest way to understand how it works is with an example. Suppose we have a volume (let's say a flash drive) with two presentations. We create a Snapshot of this flash drive, it contains: two files Joker.key and Riddler.key, the following data blocks belong to the files. The Snapshot itself does not contain data from the flash drive - only what files were on it at the time the snapshot was created and which blocks belonged to them. The peculiarity of Snapshot is that the blocks written to it are closed. They cannot be deleted, moved or overwritten. Therefore, for example, if we make changes to Joker.key, and delete Riddler.key altogether, the original data blocks will remain untouched. Although this approach consumes additional free space, it allows APFS to revert the volume back in time to the point at which any snapshot is taken almost instantly.

space sharing

Space sharing is another very interesting feature of APFS. Once again, the easiest way to understand it is with an example. Let's say you have a laptop with a 256 GB SSD installed (it's very possible that you actually have one), and you want to install OS X El Capitan and the beta version of macOS Sierra on it. Alas, Apple doesn't yet allow you to boot the operating system from an APFS volume (or use it for Time Machine, for that matter), so you'll need to create two HFS+ partitions. You launch Disk Utility and are faced with a dilemma - how big should the partitions be? You can just split the drive in half, but what if you don't have enough space to work comfortably in El Capitan? Or, on the contrary, will you go too far and the applications you need in Sierra will not be able to fit?

APFS solves this problem with Space sharing. A container containing all volumes is created on a disk with APFS volumes at the level above. They can freely and dynamically grow or shrink within such a container without requiring the user to choose how large they should be. Let's go back to our hypothetical laptop. If APFS was used instead of HFS+ for both volumes, both operating systems would report that 256 GB of space is available for each. In this case, the space occupied by the files of one system would be inaccessible to another. This solution greatly simplifies the work with multiple volumes and allows you to get the maximum benefit from their use without great difficulties.

Migration from HFS+

Finally, how can we migrate to APFS? The process of migrating to a file system is usually hard, long, and not always safe. You have to backup data to external media, erase your computer's hard drive, write a new file system, install an OS, restore your data from a copy and hope that nothing has disappeared from its place.

Luckily, Apple has taken care of that. The company's engineers did a great job on the migration process. The process consists almost entirely of atomic operations, but the main thing is that data about the new file system is written only to empty space on the HFS+ volume. This means that even if something goes wrong, it will not damage your data or the structure of your already existing file system. And according to Apple engineers, the entire migration only takes a few minutes.

Here we come to the end. We have only talked about four features, but there are many more in APFS. If you want to dive into the details, the official documentation has all the details. The new file system, as we mentioned above, cannot be used for a boot drive or Time Machine, and will not be supported on OS X Yosemite and older. The official release of APFS is scheduled for 2017.

Top Related Articles