APFS is Apple’s current file system for macOS (since 10.13), iOS, iPadOS, watchOS and tvOS. It is a copy-on-write container design with space sharing, snapshots, clones and native encryption, and it is also used on Fusion Drives. Apple has published a reference but not every feature is documented.
Overview
An APFS container has a container superblock (NXSB) whose checkpoint area points to the container object map; each volume is a separate volume superblock (APSB) with its own object map, root tree and extent tree. Almost everything is a B-tree object with a Fletcher-64 checksum, identified by object ID and transaction ID. Features include snapshots, clones, space sharing, encryption and sparse files.
History
Announced at WWDC 2016.
Shipped on iOS 10.3 (2017) and macOS High Sierra (2017), where it replaced HFS+ on flash storage.
Structures
Offsets are in bytes from the start of the structure named in each heading. Field names are descriptive and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.
Key
Offset
Size
Type
Field
Notes
_toc + index * 8 + 2
2
u16 LE/BE
Length
_toc + index * 4
2
u16 LE/BE
Offset
_toc + index * 8
2
u16 LE/BE
Offset
Parse
Offset
Size
Type
Field
Notes
0x18
4
u32 LE/BE
Type
0x20
2
u16 LE/BE
Flags
0x22
2
u16 LE/BE
Level
0x24
4
u32 LE/BE
Count
0x28
2
u16 LE/BE
Table Offset
0x2A
2
u16 LE/BE
Table Length
info
4
u32 LE/BE
Tree Flags
info + 8
4
u32 LE/BE
Tree Key Size
info + 12
4
u32 LE/BE
Tree Value Size
Value
Offset
Size
Type
Field
Notes
_toc + index * 4 + 2
2
u16 LE/BE
Offset
_toc + index * 8 + 4
2
u16 LE/BE
Offset
_toc + index * 8 + 6
2
u16 LE/BE
Length
Lookup Uncached
Offset
Size
Type
Field
Notes
0x0
8
u64 LE/BE
Key Oid
0x8
8
u64 LE/BE
Key Xid
Lookup Uncached
Offset
Size
Type
Field
Notes
0x0
4
u32 LE/BE
Flags
0x4
4
u32 LE/BE
–
0x8
8
u64 LE/BE
–
Apfs Record
Offset
Size
Type
Field
Notes
0x0
8
u64 LE/BE
Object Id
0x0
8
u64 LE/BE
Record Type
Is Valid Superblock
Offset
Size
Type
Field
Notes
0x18
4
u32 LE/BE
–
0x20
4
u32 LE/BE
–
List Snapshots
Offset
Size
Type
Field
Notes
0x8
8
u64 LE/BE
Superblock Address
0x10
8
u64 LE/BE
Created
0x30
2
u16 LE/BE
Name Length
Load
Offset
Size
Type
Field
Notes
0x10
8
u64 LE/BE
Xid
NxBlockCount
8
u64 LE/BE
Block Count
NxBlockSize
4
u32 LE/BE
–
NxFusionMtOid
8
u64 LE/BE
Fusion Middle Tree Address
NxFusionWbcBase
8
u64 LE/BE
Fusion Write Back Cache
NxFusionWbcBlocks
8
u64 LE/BE
Fusion Write Back Cache
NxIncompatFeatures
8
u64 LE/BE
Incompatible Features
NxMaxFileSystems
4
u32 LE/BE
Ax Volumes
NxOmapOid
8
u64 LE/BE
Omap
NxFsOid + i * 8
8
u64 LE/BE
Oid
Open
Offset
Size
Type
Field
Notes
0x10
8
u64 LE/BE
–
NxXpDescBase
8
u64 LE/BE
Descriptor Base
NxXpDescBlocks
4
u32 LE/BE
Descriptor Blocks
Read Block Size
Offset
Size
Type
Field
Notes
0x20
4
u32 LE/BE
–
NxBlockSize
4
u32 LE/BE
Block Size
Read Object
Offset
Size
Type
Field
Notes
0x8
8
u64 LE/BE
–
0x18
4
u32 LE/BE
Type
Parse
Offset
Size
Type
Field
Notes
0x10
8
u64 LE/BE
Xid
0x20
4
u32 LE/BE
–
ApfsFextTreeOid
8
u64 LE/BE
Fext Tree Oid
ApfsFextTreeType
4
u32 LE/BE
Fext Tree Type
ApfsFsAllocCount
8
u64 LE/BE
Allocated Blocks
ApfsFsFlags
8
u64 LE/BE
Fs Flags
ApfsFsIndex
4
u32 LE/BE
Index
ApfsIncompatFeatures
8
u64 LE/BE
Incompatible Features
ApfsLastModTime
8
u64 LE/BE
Last Modified
ApfsNumDirectories
8
u64 LE/BE
Directory Count
ApfsNumFiles
8
u64 LE/BE
File Count
ApfsNumSnapshots
8
u64 LE/BE
Snapshot Count
ApfsNumSymlinks
8
u64 LE/BE
Symlink Count
ApfsOmapOid
8
u64 LE/BE
Omap Oid
ApfsRole
2
u16 LE/BE
Role
ApfsRootTreeOid
8
u64 LE/BE
Root Tree Oid
ApfsRootTreeType
4
u32 LE/BE
Root Tree Type
ApfsSnapMetaTreeOid
8
u64 LE/BE
Snap Meta Tree Oid
ApfsSnapMetaTreeType
4
u32 LE/BE
Snap Meta Tree Type
Extents For
Offset
Size
Type
Field
Notes
0x0
8
u64 LE/BE
–
0x8
8
u64 LE/BE
–
Load Inode
Offset
Size
Type
Field
Notes
0x0
8
u64 LE/BE
Parent Id
0x8
8
u64 LE/BE
Private Id
0x10
8
u64 LE/BE
Created
0x18
8
u64 LE/BE
Odified
0x20
8
u64 LE/BE
Changed
0x28
8
u64 LE/BE
Accessed
0x30
8
u64 LE/BE
Internal Flags
0x38
4
u32 LE/BE
Links Or Children
0x44
4
u32 LE/BE
Bsd Flags
0x48
4
u32 LE/BE
Owner
0x4C
4
u32 LE/BE
Group
0x50
2
u16 LE/BE
Ode
Parse Inode Fields
Offset
Size
Type
Field
Notes
0x0
2
u16 LE/BE
Count
4 + i * 4 + 2
2
u16 LE/BE
Size
Parse Inode Fields
Offset
Size
Type
Field
Notes
0x0
8
u64 LE/BE
Data Size
0x8
8
u64 LE/BE
Allocated Size
Try Parse Directory Entry
Offset
Size
Type
Field
Notes
0x8
4
u32 LE/BE
–
0x8
2
u16 LE/BE
–
Try Parse Directory Entry
Offset
Size
Type
Field
Notes
0x0
8
u64 LE/BE
File Id
0x8
8
u64 LE/BE
Date Added
0x10
2
u16 LE/BE
Entry Type
Try Parse Xattr
Offset
Size
Type
Field
Notes
0x0
8
u64 LE/BE
Stream Id
0x8
8
u64 LE/BE
Stream Size
Try Parse Xattr
Offset
Size
Type
Field
Notes
0x0
2
u16 LE/BE
Flags
0x2
2
u16 LE/BE
Data Length
Probe
Offset
Size
Type
Field
Notes
0x18
4
u32 LE/BE
Valid
NxBlockCount
8
u64 LE/BE
Block Count
Other fields read
Read in
Offset
Size
Type
Field
Notes
Key Id
0x0
8
u64 LE/BE
Value
Value
0x0
8
u64 LE/BE
–
Apfs Object Map
0x30
8
u64 LE/BE
Tree Address
om_tree_oid (physical)
Lookup Uncached
0x0
8
u64 LE/BE
–
Open
0x10
8
u64 LE/BE
–
Extents For
0x8
8
u64 LE/BE
–
Try Parse Xattr
0x8
2
u16 LE/BE
Name Length
Probe
0x20
4
u32 LE/BE
–
Verify
i
4
u32 LE
–
Constants
Apfs Const
Name
Value
Type
Notes
NxMagic
0x4253584E
uint
“NXSB”
ApfsMagic
0x42535041
uint
“APSB”
obj_phys_t
Name
Value
Type
Notes
ObjHeaderSize
32
int
ObjTypeMask
0x0000FFFF
uint
ObjStorageTypeMask
0xC0000000
uint
ObjPhysical
0x40000000
uint
TypeNxSuperblock
0x01
uint
TypeBTree
0x02
uint
TypeBTreeNode
0x03
uint
TypeOmap
0x0B
uint
TypeFs
0x0D
uint
Container superblock (nx_superblock_t) offsets
Name
Value
Type
Notes
NxBlockSize
36
int
NxBlockCount
40
int
NxIncompatFeatures
64
int
NxUuid
72
int
NxXpDescBlocks
104
int
NxXpDescBase
112
int
NxOmapOid
160
int
NxMaxFileSystems
180
int
NxFsOid
184
int
NxMaxVolumes
100
int
NxIncompatFusion
0x100
ulong
Fusion fields of nx_superblock_t
Name
Value
Type
Notes
NxFusionUuid
1280
int
NxFusionMtOid
1352
int
NxFusionWbcBase
1368
int
NxFusionWbcBlocks
1376
int
FusionTier2ByteAddress
0x4000000000000000
ulong
fusion_mt_val_t flags
Name
Value
Type
Notes
FusionMtDirty
0x1
uint
btree_node_phys_t
Name
Value
Type
Notes
BTreeNodeDataOffset
56
int
BTreeInfoSize
40
int
BtnRoot
0x1
ushort
BtnLeaf
0x2
ushort
BtnFixedKvSize
0x4
ushort
BTreePhysical
0x10
uint
NoOffset
0xFFFF
ushort
omap_val_t flags
Name
Value
Type
Notes
OmapValDeleted
0x1
uint
OmapValEncrypted
0x4
uint
File-system records (j_key_t)
Name
Value
Type
Notes
ObjIdMask
0x0FFFFFFFFFFFFFFF
ulong
ObjTypeShift
60
int
JTypeSnapMetadata
1
int
JTypeInode
3
int
JTypeXattr
4
int
JTypeSiblingLink
5
int
JTypeFileExtent
8
int
JTypeDirRec
9
int
RootDirInode
2
ulong
j_inode_val_t
Name
Value
Type
Notes
InodeFixedSize
92
int
InoExtTypeName
4
byte
InoExtTypeDstream
8
byte
InoExtTypeSparseBytes
13
byte
ModeTypeMask
0xF000
ushort
ModeFifo
0x1000
ushort
ModeCharDevice
0x2000
ushort
ModeDirectory
0x4000
ushort
ModeBlockDevice
0x6000
ushort
ModeRegular
0x8000
ushort
ModeSymlink
0xA000
ushort
ModeSocket
0xC000
ushort
BsdImmutable
0x2
uint
BsdCompressed
0x20
uint
BsdHidden
0x8000
uint
InodeIsSparse
0x200
ulong
j_drec_val_t
Name
Value
Type
Notes
DrecTypeMask
0xF
int
DtDirectory
4
int
DrecHashedLengthMask
0x3FF
uint
j_xattr_val_t
Name
Value
Type
Notes
XattrDataStream
0x1
ushort
XattrDataEmbedded
0x2
ushort
XattrSymlink
“com.apple.fs.symlink”
string
XattrDecmpfs
“com.apple.decmpfs”
string
XattrResourceFork
“com.apple.ResourceFork”
string
ResourceForkStreamName
“rsrc”
string
j_file_extent_val_t
Name
Value
Type
Notes
FileExtentLengthMask
0x00FFFFFFFFFFFFFF
ulong
apfs_superblock_t offsets
Name
Value
Type
Notes
ApfsFsIndex
36
int
ApfsIncompatFeatures
56
int
ApfsFsAllocCount
88
int
ApfsRootTreeType
116
int
ApfsSnapMetaTreeType
124
int
ApfsOmapOid
128
int
ApfsRootTreeOid
136
int
ApfsSnapMetaTreeOid
152
int
ApfsNumFiles
184
int
ApfsNumDirectories
192
int
ApfsNumSymlinks
200
int
ApfsNumSnapshots
216
int
ApfsVolUuid
240
int
ApfsLastModTime
256
int
ApfsFsFlags
264
int
ApfsFormattedBy
272
int
ApfsVolName
704
int
ApfsVolNameSize
256
int
ApfsRole
964
int
ApfsFextTreeOid
1032
int
ApfsFextTreeType
1040
int
FsUnencrypted
0x1
ulong
IncompatCaseInsensitive
0x1
ulong
IncompatNormalizationInsensitive
0x8
ulong
IncompatSealedVolume
0x20
ulong
Apfs Checksum
Name
Value
Type
Notes
Modulus
0xFFFFFFFF
ulong
Implementation limits
Class
Name
Value
Notes
Apfs B Tree
MaxDepth
16
Apfs Object Map
MaxDepth
16
Apfs Object Map
MaxCacheEntries
65536
Apfs Container
MaxCachedNodes
8192
Apfs Container
MaxDescriptorBlocks
1 << 16
Apfs Fusion Device
MaxChunk
1024 * 1024
Apfs Fusion Middle Tree
MaxRecords
8_000_000
Apfs Const
MinBlockSize
4096
Apfs Const
MaxBlockSize
65536
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.