# Apple File System

**Apple File System（APFS）** 是 Apple 为其设备开发的一种专有文件系统，以加密为核心设计要求，并针对闪存和固态硬盘存储进行了优化。它取代 [HFS Plus](https://www.edgepedia.org/zh/hfs-plus)，成为 iOS 10.3 及更高版本、macOS High Sierra 及更高版本、watchOS 4.0 及更高版本以及 tvOS 10.2 及更高版本的默认文件系统，并运行于 Apple 的所有平台：iPad、iPhone、Mac、Apple TV、Apple Vision Pro 和 [Apple Watch](https://www.edgepedia.org/zh/apple-watch)。<sup>[1](https://support.apple.com/en-gb/guide/security/seca6147599e/web)</sup><sup> • </sup><sup>[2](https://developer.apple.com/documentation/foundation/about-apple-file-system?changes=_7)</sup><sup> • </sup><sup>[3](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemDetails/FileSystemDetails.html?trk=public_post_comment-text)</sup>

| 关键事实 | 详情 |
|---|---|
| 状态 | 专有文件系统；存在开源的 APFS 实现，包括只读实现 apfs-fuse，不过 Apple 表示其计划公布卷格式规范<sup>[4](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html)</sup><sup> • </sup><sup>[17](https://github.com/sgan81/apfs-fuse/blob/master/ApfsLib/ApfsContainer.cpp)</sup> |
| 默认启用自 | macOS High Sierra（2017 年 9 月 25 日发布）、iOS 10.3、watchOS 4.0、tvOS 10.2<sup>[2](https://developer.apple.com/documentation/foundation/about-apple-file-system?changes=_7)</sup><sup> • </sup><sup>[5](https://www.apple.com/newsroom/2017/09/macos-high-sierra-now-available-as-a-free-update/)</sup> |
| 核心设计 | 对文件数据和元数据采用写时复制，取代日志式记录；无需写两次的开销即可提供崩溃保护<sup>[4](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html)</sup> |
| 完整性 | 元数据操作使用 Fletcher 校验和算法；Apple 硬盘在硬件层面使用 ECC<sup>[4](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html)</sup> |
| 加密 | 密钥包、文件系统元数据和内容数据使用 AES-XTS；在数据保护设备上使用按文件、按区段的密钥<sup>[6](https://github.com/libyal/libfsapfs/blob/main/documentation/Apple%20File%20System%20%28APFS%29.asciidoc)</sup><sup> • </sup><sup>[7](https://support.apple.com/en-mide/guide/security/sece8608431d/web)</sup> |
| 时间戳 | 1 纳秒粒度，而 HFS+ 为 1 秒<sup>[8](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/VolumeFormatComparison/VolumeFormatComparison.html)</sup> |
| 不支持 | 数据去重和目录硬链接<sup>[4](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html)</sup> |

## 设计目标

APFS 主要针对固态存储开发，从 Mac 的固态硬盘一直到最早 Apple Watch 的 8 GB 存储。其宣传的能力包括稳健的加密、写时复制的元数据处理、共享空间、克隆文件和目录、快照支持、快速目录大小计算、原子安全保存原语，以及一种写时复制架构——它合并 I/O 以提升性能，同时不损害数据可靠性。<sup>[1](https://support.apple.com/en-gb/guide/security/seca6147599e/web)</sup> 2017 年 9 月 Apple 随 macOS High Sierra 发布它时，将其描述为一种支持高容量设备的可扩展存储架构，复制文件和目录等常见操作几乎瞬间完成。<sup>[5](https://www.apple.com/newsroom/2017/09/macos-high-sierra-now-available-as-a-free-update/)</sup>

在推出时，APFS 仅支持配备全闪存内部存储的 Mac；对 Fusion 和 HDD Mac 系统的支持推迟到后续更新。<sup>[5](https://www.apple.com/newsroom/2017/09/macos-high-sierra-now-available-as-a-free-update/)</sup>

## 写时复制与克隆

APFS 避免就地修改数据。当某个存储块的内容发生变化时，更改后的块会被写入新位置，而不是覆盖旧块。在固态硬盘上这很快，因为目标区域通常已在后台整理过程中被擦除；而且更安全：如果写入过程中出现任何问题，文件系统可以回退到先前的状态，这正是 APFS 在崩溃或断电时防止数据丢失的方式，且无需日志式记录写两次的开销。<sup>[9](https://eclecticlight.co/2023/05/04/cow-and-clones-how-they-save-space-and-ssd-wear/)</sup><sup> • </sup><sup>[4](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html)</sup>

克隆是文件或目录的副本，最初不占用磁盘上的额外空间。创建克隆时，两个文件共享相同的数据块；当其中任一个被修改时，只有更改的块会在写时复制机制下写入别处，两个文件继续共享未修改的块。`FileManager` 的 `copyItem(at:to:)` 和 `copyItem(atPath:toPath:)` 方法会在 APFS 卷上自动创建克隆。<sup>[2](https://developer.apple.com/documentation/foundation/about-apple-file-system?changes=_7)</sup> 随着编辑累积，克隆对会逐块分化，因此克隆占用的空间会随时间增长；APFS 报告某一时刻实际使用的空间，无法预测这种增长。<sup>[9](https://eclecticlight.co/2023/05/04/cow-and-clones-how-they-save-space-and-ssd-wear/)</sup> 克隆仅在单个 APFS 卷内有效，不能跨卷，即使在同一容器内也不行。<sup>[10](https://www.macinternals.app/en/blog/apfs-clones-and-snapshots)</sup>

APFS 不执行数据去重。由于各个区段可以加密，文件系统无法检查文件内容以查找重复；克隆文件转而用于尽量减少存储占用和重复。<sup>[4](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html)</sup>

## 容器、卷与空间共享

APFS 中的顶层存储单元是容器，它包含一个或多个卷。APFS 按需分配存储空间：当容器包含多个卷时，其可用空间是共享的，可按需分配给任何卷，因此可用空间等于容器总大小减去其所有卷已使用的空间。<sup>[1](https://support.apple.com/en-gb/guide/security/seca6147599e/web)</sup>

在 macOS 10.15 或更高版本中，用于启动 Mac 的 APFS 容器必须至少包含五个卷，前三个对用户隐藏：一个未加密的 Preboot 卷，存放启动每个系统卷所需的数据；一个未加密的 VM 卷，用于加密交换文件；以及一个未加密的 Recovery 卷，必须无需解锁系统卷即可使用，以启动 recoveryOS。System 卷存放启动 Mac 所需的文件以及 macOS 原生安装的应用，默认情况下任何进程（包括 Apple 自己的进程）都不能写入其中。Data 卷存放所有可能变化的内容，例如用户文件和用户安装的应用。Preboot、VM 和 Recovery 卷是共享的，而不是为每个系统卷重复创建。<sup>[1](https://support.apple.com/en-gb/guide/security/seca6147599e/web)</sup>

在 iOS、iPadOS 和 visionOS 设备上，存储至少分为两个 APFS 卷：一个 System 卷和一个 Data 卷。<sup>[1](https://support.apple.com/en-gb/guide/security/seca6147599e/web)</sup>

## 快照与密封系统卷

APFS 快照是其父卷在特定时刻的只读副本；一个卷可以有零个或多个快照，可在“磁盘工具”中查看和删除。<sup>[11](https://support.apple.com/en-euro/guide/disk-utility/dskuf82354dc/mac)</sup> 在装有 macOS 11 或更高版本的设备上，系统卷被捕获在一个快照中，操作系统从该快照启动，而不是从可变系统卷的只读挂载点启动。<sup>[1](https://support.apple.com/en-gb/guide/security/seca6147599e/web)</sup>

快照也是签名系统卷（SSV）的基础。自推出以来，APFS 一直使用非密码学校验和提供文件系统元数据完整性；SSV 通过为文件数据的每个字节添加密码学哈希来强化这一点，并在读取路径中对照文件系统元数据中的预期值进行验证。每个 SHA-256 哈希存储在元数据树中，元数据树本身又递归哈希，使得一个根值——即封印——覆盖整个系统卷；封印在每次启动时都会验证。由于 SSV 使用 APFS 快照，失败的 macOS 更新可以回滚到旧系统版本而无需重新安装。<sup>[12](https://support.apple.com/guide/security/signed-system-volume-security-secd698747c9/web)</sup>

Time Machine 也依赖 APFS 快照：本地快照每小时创建一次，存储在与原始文件相同的磁盘上，保留最多 24 小时或直到需要空间为止，且仅在 APFS 磁盘上创建。<sup>[13](https://support.apple.com/en-gb/guide/mac-help/mh35860/26/mac/26)</sup>

## 加密与数据保护

APFS 对密钥包、文件系统元数据和内容数据使用 AES-XTS 加密方法，密码块大小为 128 字节。<sup>[6](https://github.com/libyal/libfsapfs/blob/main/documentation/Apple%20File%20System%20%28APFS%29.asciidoc)</sup> 在支持数据保护的 Apple 设备上，每个文件都受唯一的按文件或按区段密钥保护，并根据文件的访问方式用类密钥进行封装。APFS 允许文件系统将密钥细分到按区段级别，因此文件的不同部分可以有不同的密钥。当文件被克隆时，原文件和克隆副本都会为后续写入获得新密钥，因此新数据以新密钥到达介质，而文件的所有区段仍受同一类密钥保护。<sup>[7](https://support.apple.com/en-mide/guide/security/sece8608431d/web)</sup>

## 兼容性与限制

若干行为与 HFS Plus 不同，会影响用户和开发者：

- **不支持目录硬链接**；在 macOS 上将 HFS+ 卷转换为 APFS 时，所有目录硬链接都会转换为符号链接或替身。<sup>[4](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html)</sup>
- **索引节点号为 64 位**，而旧版 `FSRef` 结构是为 32 位索引节点号设计的，因此使用 `FSRef` 值的 API 在 APFS 上可能性能不佳。<sup>[14](https://developer.apple.com/documentation/coreservices/fsref)</sup>
- 虽然 APFS 缺少内置 RAID 功能，但用它格式化的卷可以加入 Apple RAID 卷，从而支持条带化（RAID 0）、镜像（RAID 1）和拼接（JBOD），也支持直接连接的硬件 RAID。<sup>[4](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html)</sup>
- **支持 TRIM** 操作，并在文件删除或可用空间回收后异步发出，因此只有在相应的元数据更改持久化到稳定存储后才会发生。<sup>[4](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html)</sup>

Time Machine 与 APFS 的关系随时间而变化。早期 APFS 版本不支持目录硬链接，而 Time Machine 在 HFS+ 时代的备份依赖于此；从 macOS 11 [Big Sur](https://www.edgepedia.org/zh/macos-big-sur) 开始，APFS 成为新 Time Machine 备份的默认文件系统，现有 HFS+ 格式的备份驱动器仍受支持。<sup>[15](https://samsclass.info/152/lec16/ch13.pdf)</sup> Apple 现在将 APFS 或 APFS 加密磁盘描述为 Time Machine 备份磁盘的首选格式，同时仍支持 Mac OS 扩展（日志式）和 Xsan 格式。<sup>[16](https://support.apple.com/en-gb/guide/mac-help/mh15139/26/mac/26)</sup>

## 格式细节

libfsapfs 项目的独立格式文档将 APFS 描述为一种小端格式，时间戳存储为自 POSIX 纪元起的纳秒计数，字符串使用 UTF-8，并指出一处差异：一些 Apple 来源声称 APFS 使用 Unicode 9.0 版本，而实践中已观察到对更新 Unicode 版本的支持。<sup>[6](https://github.com/libyal/libfsapfs/blob/main/documentation/Apple%20File%20System%20%28APFS%29.asciidoc)</sup> 同一文档记载 APFS 接替分层文件系统（HFS）和 Core Storage（CS）。<sup>[6](https://github.com/libyal/libfsapfs/blob/main/documentation/Apple%20File%20System%20%28APFS%29.asciidoc)</sup>

## References

1. [Role of Apple File System, Apple Platform Security guide](https://support.apple.com/en-gb/guide/security/seca6147599e/web)
2. [About Apple File System, Apple Developer Documentation](https://developer.apple.com/documentation/foundation/about-apple-file-system?changes=_7)
3. [File System Programming Guide: File System Details, Apple Developer Documentation Archive](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemDetails/FileSystemDetails.html?trk=public_post_comment-text)
4. [Apple File System Guide: FAQ, Apple Developer Documentation Archive](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html)
5. [macOS High Sierra now available as a free update, Apple Newsroom (September 25, 2017)](https://www.apple.com/newsroom/2017/09/macos-high-sierra-now-available-as-a-free-update/)
6. [Apple File System (APFS) format specification, libfsapfs documentation (Joachim Metz)](https://github.com/libyal/libfsapfs/blob/main/documentation/Apple%20File%20System%20%28APFS%29.asciidoc)
7. [Data Protection in Apple devices, Apple Platform Security guide](https://support.apple.com/en-mide/guide/security/sece8608431d/web)
8. [Apple File System Guide: Volume Format Comparison, Apple Developer Documentation Archive](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/VolumeFormatComparison/VolumeFormatComparison.html)
9. [COW and clones: how they save space and SSD wear, The Eclectic Light Company (2023)](https://eclecticlight.co/2023/05/04/cow-and-clones-how-they-save-space-and-ssd-wear/)
10. [APFS clones and snapshots: the kernel calls that make them work, Mac Internals](https://www.macinternals.app/en/blog/apfs-clones-and-snapshots)
11. [View APFS snapshots in Disk Utility on Mac, Apple Support](https://support.apple.com/en-euro/guide/disk-utility/dskuf82354dc/mac)
12. [Signed system volume security, Apple Platform Security guide](https://support.apple.com/guide/security/signed-system-volume-security-secd698747c9/web)
13. [Back up your files with Time Machine on Mac, Apple Support](https://support.apple.com/en-gb/guide/mac-help/mh35860/26/mac/26)
14. [FSRef, Apple Developer Documentation](https://developer.apple.com/documentation/coreservices/fsref)
15. [Chapter 13: File systems (APFS and Time Machine compatibility), samclass.info course notes](https://samsclass.info/152/lec16/ch13.pdf)
16. [Types of disks you can use with Time Machine on Mac, Apple Support](https://support.apple.com/en-gb/guide/mac-help/mh15139/26/mac/26)
17. [apfs-fuse/ApfsLib/ApfsContainer.cpp at master · sgan81/apfs-fuse](https://github.com/sgan81/apfs-fuse/blob/master/ApfsLib/ApfsContainer.cpp)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Operating systems

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/apple-file-system

English original: https://www.edgepedia.org/apple-file-system
