| 1 |
=========================== |
| 2 |
Apple File System for Linux |
| 3 |
=========================== |
| 4 |
|
| 5 |
The Apple File System (APFS) is the copy-on-write filesystem currently used on |
| 6 |
all Apple devices. This module provides a degree of experimental support on |
| 7 |
Linux. It's intended to work with all kernel versions since 4.12, but testing |
| 8 |
is focused on 5.18 and above. |
| 9 |
|
| 10 |
To help test write support, a set of userland tools is also under development. |
| 11 |
The git tree can be retrieved from https://github.com/eafer/apfsprogs.git. |
| 12 |
|
| 13 |
Known limitations |
| 14 |
================= |
| 15 |
|
| 16 |
This module is the result of reverse engineering and testing has been limited. |
| 17 |
If you make use of the write support, there is a real risk of data corruption, |
| 18 |
so mounts are read-only by default. Please report any issues that you find. |
| 19 |
|
| 20 |
Writes to fusion drives will likely never be supported, though I might |
| 21 |
reconsider this if people actually need it. Encryption is not yet implemented |
| 22 |
even in read-only mode. |
| 23 |
|
| 24 |
Reporting bugs |
| 25 |
============== |
| 26 |
|
| 27 |
If you encounter any problem, the first thing you should do is run (as root):: |
| 28 |
|
| 29 |
dmesg | grep -i apfs |
| 30 |
|
| 31 |
to see all the error messages. If that doesn't help you, please file a github |
| 32 |
issue at https://github.com/eafer/linux-apfs-rw/issues. Or send me an email if |
| 33 |
you prefer. |
| 34 |
|
| 35 |
Build |
| 36 |
===== |
| 37 |
|
| 38 |
Note that at this point the driver has been packaged for several distros, so |
| 39 |
it may be more convenient to install it from there instead of building it |
| 40 |
yourself. The distro packages are often outdated though, so be sure to check |
| 41 |
the version. |
| 42 |
|
| 43 |
In order to build a module out-of-tree, you will first need the Linux kernel |
| 44 |
headers. Depending on your distro, you can get them by running (as root):: |
| 45 |
|
| 46 |
# Debian/Ubuntu |
| 47 |
apt-get install linux-headers-$(uname -r) |
| 48 |
|
| 49 |
# Arch/Manjaro |
| 50 |
pacman -Sy linux-headers |
| 51 |
|
| 52 |
# RHEL/Rocky/CentOS/Fedora |
| 53 |
yum install kernel-headers kernel-devel |
| 54 |
|
| 55 |
Now you can just cd to the linux-apfs-rw directory and run:: |
| 56 |
|
| 57 |
make |
| 58 |
|
| 59 |
The resulting module is the apfs.ko file. Before you can use it you must insert |
| 60 |
it into the kernel. Again as root:: |
| 61 |
|
| 62 |
insmod apfs.ko |
| 63 |
|
| 64 |
If you get an "unknown symbol in module" error, run:: |
| 65 |
|
| 66 |
modprobe libcrc32c |
| 67 |
|
| 68 |
and then try the insmod command again. |
| 69 |
|
| 70 |
Mount |
| 71 |
===== |
| 72 |
|
| 73 |
Like all filesystems, apfs is mounted with:: |
| 74 |
|
| 75 |
mount [-o options] device dir |
| 76 |
|
| 77 |
where ``device`` is the path to your device file or filesystem image, and |
| 78 |
``dir`` is the mount point. The following options are accepted: |
| 79 |
|
| 80 |
============ ================================================================= |
| 81 |
vol=n Volume number to mount. The default is volume 0. |
| 82 |
|
| 83 |
snap=label Volume snapshot to mount (in read-only mode). |
| 84 |
|
| 85 |
tier2=path Path to the tier 2 device. For fusion drives only. |
| 86 |
|
| 87 |
uid=n, gid=n Override on-disk inode ownership data with given uid/gid. |
| 88 |
|
| 89 |
cknodes Verify the checksum on all metadata nodes. Right now this has a |
| 90 |
severe performance cost, so it's not recommended. |
| 91 |
|
| 92 |
readwrite Enable the experimental write support. This may corrupt your |
| 93 |
container. |
| 94 |
============ ================================================================= |
| 95 |
|
| 96 |
So for instance, if you want to mount volume number 2, and you want the metadata |
| 97 |
to be checked, you should run (as root):: |
| 98 |
|
| 99 |
mount -o cknodes,vol=2 device dir |
| 100 |
|
| 101 |
To unmount it, run:: |
| 102 |
|
| 103 |
umount dir |
| 104 |
|
| 105 |
Credits |
| 106 |
======= |
| 107 |
|
| 108 |
Originally written by Ernesto A. Fernández <[email protected]>, with |
| 109 |
several contributions from Gabriel Krisman Bertazi <[email protected]>, |
| 110 |
Arnaud Ferraris <[email protected]> and Stan Skowronek |
| 111 |
<[email protected]>. For attribution details see the historical |
| 112 |
git tree at https://github.com/eafer/linux-apfs.git. |
| 113 |
|
| 114 |
Work was first based on reverse engineering done by others [1]_ [2]_, and later |
| 115 |
on the (very incomplete) official specification [3]_. Some parts of the code |
| 116 |
imitate the ext2 module, and to a lesser degree xfs, udf, gfs2 and hfsplus. |
| 117 |
|
| 118 |
.. [1] Hansen, K.H., Toolan, F., Decoding the APFS file system, Digital |
| 119 |
Investigation (2017), https://dx.doi.org/10.1016/j.diin.2017.07.003 |
| 120 |
.. [2] https://github.com/sgan81/apfs-fuse |
| 121 |
.. [3] https://developer.apple.com/support/apple-file-system/Apple-File-System-Reference.pdf |