Skip to content

Instantly share code, notes, and snippets.

Last active February 7, 2020 23:06
What would you like to do?
apfs tools in Sierra
➜ ~ sw_vers
ProductName: Mac OS X
ProductVersion: 10.12.1
BuildVersion: 16B2333a
➜ ~ ls -l /System/Library/Filesystems/apfs.fs/Contents/Resources
total 2088
-rwxr-xr-x 1 root wheel 349760 22 Sep 03:48 apfs.util
-rwxr-xr-x 1 root wheel 352880 22 Sep 03:48 apfs_invert
-rwxr-xr-x 1 root wheel 23632 22 Sep 03:48 apfs_snapshot
-rwxr-xr-x 1 root wheel 426608 22 Sep 03:48 fsck_apfs
-rwxr-xr-x 1 root wheel 423216 22 Sep 03:48 hfs_convert
-rwxr-xr-x 1 root wheel 24352 22 Sep 03:48 mount_apfs
-rwxr-xr-x 1 root wheel 387936 22 Sep 03:48 newfs_apfs
➜ ~ /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util
Usage: apfs.util [[-p][-k] /dev/diskXsYsZ]|[-s /dev/diskXsY]|[-R SNAPSHOT][-M dir][-S dir]
-p : probe for volume name
-k : get volume UUID
-s : set volume UUID(s) and container UUID to new random values
-R SNAPSHOT : set the volume to revert to the snapshot named by SNAPSHOT on next mount.
-M dir : flag the named directory as "maintain-dir-stats". Note: dir must be empty.
-S dir : get the directory stats from dir (if it has been flagged as "maintain-dir-stats"
-O path [optional fs name] : override the fstypename for apfs to be "hfs" (or the optional name given)
➜ ~ /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs_invert
apfs_invert -d <device> -s <slice> -n <image-name> [-S image-slice]
-d: The path to the APFS device. This should be the container's device,
not an APFS filesystem device published by IOKit.
-s: The slice number of the filesystem to be inverted in the given device.
-n: The name of the image file in the filesystem's root directory.
-S: The slice number of the filesystem to be inverted in the image.
(Optional. If unspecified, defaults to the first filesystem found.)
➜ ~ /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs_snapshot
WARNING: You are using apfs_snapshot utility on pre-release version of the
Apple File System called APFS which is meant for evaluation and development
purposes only. Please note that apfs_snapshot may be removed in a future
release and should only be used for testing.
apfs_snapshot [-l]|[-c <snapshot name>]|[-d <snapshot name>]|[-b <revert to snapshot>]|[-r <old snapshot name> -n <new snapshot name> ] volumePath
apfs_snapshot -l /Volumes/apfs
apfs_snapshot -c SnapshotName /Volumes/apfs
apfs_snapshot -r OldSnapshotName -n NewSnapshotName /Volumes/apfs
apfs_snapshot -b RevertSnapshot /Volumes/apfs
apfs_snapshot -d SnapshotName /Volumes/apfs
➜ ~ /System/Library/Filesystems/apfs.fs/Contents/Resources/fsck_apfs
usage: fsck_apfs [options] <device_path>
-f (IGNORED) force checking if volume was unmounted cleanly
-q quick check if the superblock and checkpoint superblock are valid.
-y always repair (answer "yes" to questions)
-n verify only (answer "no" to questions)
➜ ~ /System/Library/Filesystems/apfs.fs/Contents/Resources/hfs_convert
Usage: apfs_hfs_convert [-e] [-v] [-S <path>] [-n] [-F n] [-M <mount_path>] [-o <option>] [--no-warning] <device_path>
-e Estimate apfs metadata size.
-v Enable verbose output.
-S <path>
Print statistics and information about the converson to the given <path>.
-n Don't finalize conversion (dry run). Volume remains HFS.
-f Force conversion if volume is dirty.
-F n Slice #n (0-based) should be fixed size.
-M <mount_path>
Use the given path to mount APFS during conversion.
-o <nx_or_apfs_format_options>
Format options passed through to nx_format and apfs_newfs.
Do not warn about APFS being pre-release technology, nor wait for user acknowledgement.
Conversion will abort after <seconds> seconds. Default is 600 seconds for dry run, unlimited otherwise.
➜ ~ /System/Library/Filesystems/apfs.fs/Contents/Resources/mount_apfs
mount_apfs: missing argument
mount_apfs: [-o options] [-u UID] [-g GID] <-C device | -s snapshot volume device> <directory>
➜ ~ /System/Library/Filesystems/apfs.fs/Contents/Resources/newfs_apfs
newfs_apfs: missing argument
newfs_apfs: [-o options] [-b block-size] [-s volume-size] [-v volume-name] [-E | -P] [-A | -C] device
Copy link

Some notes on using apfs.util

The "-k" option is to be used with a partition, such as /dev/disk0s1
The "-s" option is to be used with a disk, such as /dev/disk0, and must be run as root, i.e. with the "sudo " prefix command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment