Apple’s APFS System

By on Sep 14, 2016 in Technology

ApfsIt’s not easy to believe that tech-savvy Apple uses a file system that was developed more than 30 years ago. That’s right, 30 years ago, when floppy disks and spinning hard drives were considered cutting-edge technology. The good news is that this cycle is coming to an end. Apple announced that 2017 comes with the new Apple File System or APFS. What does it mean?

The current file systems used by Apple are HFS & HFS+. These were never actually built for storage devices storing data measuring Gigabytes. HFS was introduced in 1985 when the Mac 512K (yes, that represents memory storage) was the company’s flagship. HFS+, shipped in 1998 on the G3 PowerMacs with 4GB hard drives, represented a serious iteration. However, since 1998, the typical storage capacity of a home computer has increased by a factor of over 1,000. Something needed to change.

APFS has been developed from scratch to scale uniformity across all their devices. From the Apple Watch to the Mac, all Apple devices will use APFS as their default file system in the coming years.

Encryption

One of the most important and useful features is encryption. The new file system will offer three options for how to encrypt their data:

  1. Unencrypted—a user can choose to not encrypt their data at all. Of course, this is not at all advisable, especially if you have any sensitive data on your laptop;
  2. Single Key Encryption—has the exact same functionality as the FileVault does on a Mac at the moment. It will encrypt the data, requiring a key to access it.
  3. Multi-Key Encryption—is a thing of beauty. This feature will enable users to create multiple keys for different files, or even parts of files. In other words, your entire disk will be encrypted, but you can create additional keys to reveal even more data. This option will also allow encryption on a “per-file” basis, thus different files can have different encryption keys.

Snapshots

A snapshot lets the user freeze the state of a file system at a particular moment in time and continue to edit it while preserving the old data. Changes are tracked by the file system and only the new data takes up additional space. Snapshots are also faster that typical file saves—a typical one saves the entire data of the file every time the user “saves” the file, thus it takes time proportional to the size of the file. Contrarily, a snapshot only saves the changes every time the user saves the file, enabling backups to use less disk space than on the file systems not supporting snapshot. Consequently, TimeMachine backups will become faster, more efficient and will occupy less space.

Sparse Files

Sparse files allow memory to be allocated to a file only when needed—a large file (let’s say 1GB) will only be allocated the entire 1GB space on the storage when the actual data in the file is 1GB in size. For instance, when you’re downloading a 1GB file, the file system won’t allocate 1GB of space to the file from the very beginning (as HFS+ does), instead it will be allocated disk space as it grows.

Nanosecond Timestamp Granularity

The HFS+ file system has support for 1 second timestamp granularity—the timestamps (“file created on” and “last modified on” on the user’s files are accurate to a second). Back when HFS+ was designed for storage devices that were slow, 1 second timestamps were sufficient to manage the atomicity of the file system. These days, the storage devices used in the current generation of devices are capable of I/O operations at the nanosecond level, so the change was essential.

Space Sharing

This new feature will allow multiple volumes to logically share memory space on a storage device. Let’s say you own a MacBook Air with 256GB SSD, APFS will allow you to partition it in such a manner that each of the partitions will show the entire 356GB (or whatever size you choose) as available for use and will expand or shrink in physical size when files are added or removed from the partitions.

Space Efficiency

APFS deals with space efficiency by using “Clones.” When you copy a file within the same file system, instead of creating a duplicate copy of the data, APFS simply shares the same on-disk data with the new file. This means that multiple copies of the same file will stop using additional space “per-file.”

Performance

APFS is optimized for Flash storage and uses “TRIM”—a command used by the OS to inform the SSD which blocks of data are no longer in use and can be cleared. Furthermore, TRIM also allows the SSD to mark the blocks of memory that no longer contain valid data and when new data is needed to be written, the SSD can use the marked blocks. This leads to a higher write speed.

APFS will improve stability for Apple users on every device. Once it becomes available, the process of switching to the new file system will be simple—there won’t be the need to back up the existing data and start again with a fresh OS install, but there will be an option to seamlessly transition all devices without fear of losing any files.