APFS clone

Also known as: clonefile

On this page 7

An APFS clone is a file copy created by the Apple File System that shares the original data blocks instead of duplicating them, so the copy appears instantly and consumes almost no additional space at creation. In macOS storage and backup, cloning is the default behavior when the Finder duplicates a file on the same APFS volume, and developers reach the same mechanism through the clonefile system call.

The clone and its source are fully independent files from the user’s point of view. Each has its own name, metadata and permissions, and editing one never changes the other, because APFS applies copy-on-write only to the blocks that actually change.

How copy-on-write cloning works in APFS

Cloning works by creating a new file record that points to the same extents on disk as the source file. APFS tracks how many files reference each extent through a reference count, so the shared blocks stay allocated as long as at least one file still uses them.

When an application writes to a cloned file, APFS does not overwrite the shared block in place. It writes the new data to free space, updates the metadata of the modified file to point there, and lowers the reference count of the old block. The untouched blocks remain shared, which is why a clone of a 20 GB video that receives a small edit still costs only the size of the changed blocks.

The table below follows one file through the typical stages of its life as a clone.

StageWhat APFS doesExtra space used
Clone createdNew inode references existing extentsMetadata only, a few kilobytes
Clone readData is served from the shared blocksNone
Part of clone editedChanged blocks written to new locationsSize of the changed blocks
Original deletedReference counts drop, shared blocks stayUsually none freed
Both copies deletedReference count reaches zeroAll blocks released
Life cycle of a cloned file

Ways to create an APFS clone

macOS creates clones through several interfaces, and all of them require the source and the copy to sit on the same APFS volume. A copy to another volume, even one in the same APFS container, is always a full physical copy.

MethodTypical userNotes
Finder DuplicateEveryday usersCommand-D or copy and paste within one volume
cp -c in TerminalAdministrators and scriptersFails with an error if cloning is impossible
clonefile system callDevelopersSynonym clonefile names the low-level API
copyfile with clone flagDevelopersCan fall back to a normal copy automatically
Backup and sync toolsBackup softwareSome use clones for fast versioned copies
Common methods that produce a clone

The clonefile call is atomic and fast regardless of file size, because it copies only metadata. It returns an error such as EXDEV when the destination lies on a different file system, which lets software detect the situation and fall back to a byte-by-byte copy.

How clones affect reported disk space

Clones make storage accounting on the Mac harder to read, because tools that report the size of a file show its logical size, not the blocks it owns exclusively. Get Info on a cloned 10 GB file says 10 GB, yet the free space of the volume did not drop by that amount.

The practical consequence is that adding up file sizes overstates real usage, and deleting one copy of a cloned pair frees almost nothing. Users who clean up a full disk by removing duplicates are often surprised when free space barely changes.

FigureWhere it appearsWhat it reflects for clones
Logical sizeGet Info, ls -lFull file length, shared blocks included
Volume free spaceDisk Utility, Storage settingsTrue free blocks after sharing
Folder totalsFinder, duSum of logical sizes, overstated
Purgeable spaceStorage settingsUnrelated to clones, mostly caches and snapshots
Size figures and what they actually measure

A clone is one of several space-saving mechanisms in APFS, and it is easy to confuse with an APFS snapshot or a hard link. The key distinction is that a clone is an independent, writable file, a hard link is a second name for the same file, and a snapshot is a read-only image of a whole volume.

MechanismScopeWritable copyEdits shared with source
APFS cloneSingle file or folderYesNo
Hard linkSingle fileSame fileYes
APFS snapshotEntire volumeNoNot applicable
Plain copySingle file or folderYesNo, fully duplicated
Clone and related mechanisms

Snapshots and clones rely on the same copy-on-write foundation, which is why Time Machine can keep local snapshots cheaply. Clones, however, are created per file and are visible in the file system as ordinary items.

Practical use and limitations of cloning

Cloning is most valuable where large files are copied often but changed little: versions of video projects, virtual machine disk images, sample libraries, and build artifacts. It also makes instant working copies safe, because the original stays untouched no matter what happens to the clone.

  • A clone is not a backup. Both files depend on the same physical blocks, so disk failure or corruption of a shared block damages both copies.
  • Cross-volume copies are never clones, including copies to an external drive, a network share or a second APFS volume in the same container.
  • Some applications rewrite whole files when saving, which converts a cheap clone into a full copy at the first save.
  • Encrypted APFS volumes support clones in the same way, because encryption works below the level of file extents.
  • HFS+ volumes cannot clone, so a Finder duplicate on an older Mac OS Extended disk is always a full copy.

Backup software must treat clones with care. Copying a volume file by file to another drive expands every clone into a full copy, so the destination can need far more space than the source volume reports as used.

In simple terms

An APFS clone is a copy that does not really copy anything at first. The Mac simply makes a second label that points to the same data. That is why duplicating a huge file takes no time and no extra space.

Only when one of the two files is changed does the Mac store the new pieces separately. Think of two people sharing one printed book and writing their own notes on separate sticky pages. The shared book counts once, and only the notes take up extra room.

A practical example

A video editor keeps a 120 GB project on the internal SSD of a MacBook Pro with 160 GB of free space. Before trying a risky new color grade, the editor selects the project folder and presses Command-D. The duplicate appears in about a second, and free space stays at roughly 160 GB instead of falling to 40 GB.

After a day of experiments, the edited copy has changed about 6 GB of media caches and project data, so the volume now shows about 154 GB free. The editor deletes the original folder expecting to recover 120 GB, but free space rises only slightly, because most blocks are still shared with the surviving copy. When the editor later copies the project to an external archive drive, the full 126 GB is written, since clones cannot cross volumes.