Is there any way to mount APFS partition read only or read/write on Linux or Windows?
- 333
- 1
- 2
- 6
-
4Asked here https://superuser.com/questions/1157631/how-to-access-an-apfs-volume-on-windows-machine – spikey_richie Nov 10 '17 at 16:07
-
@spikey_richie, That answer is not correct. – Vahid Nov 10 '17 at 16:20
-
2Actually, the accepted answer not being correct doesn't prevent it from being a duplicate... nobody said the system was perfect :/ Ideally, someone would come along with the correct answer [which right now is "there is no way", though that will change over time] & the OP would accept that instead. – Tetsujin Nov 10 '17 at 17:24
-
For a read-only solution in Ubuntu, see [this answer](https://unix.stackexchange.com/a/515518/7286) – mivk Apr 25 '19 at 18:19
-
See also: [AskDifferent: unlock macOS encrypted Volume on linux](https://apple.stackexchange.com/q/356081/212953) – Gabriel Staples May 15 '23 at 20:01
-
And see: [Unix & Linux: Is an Apple File System (APFS) driver for linux available or in progress?](https://unix.stackexchange.com/q/481949/114401) – Gabriel Staples May 15 '23 at 20:03
6 Answers
Actually there is a free tool for Linux.
- https://github.com/sgan81/apfs-fuse for Linux (free)
- https://www.paragon-software.com/home/apfs-windows for Windows (not free)
These are my everyday use tools on my hackintosh.
- 306
- 2
- 4
-
4
-
-
Here's a discussion on running apfs-fuse on Windows (may work in the future): https://github.com/sgan81/apfs-fuse/issues/78 – divieira Jun 11 '20 at 07:25
-
Paragon also runs on Linux: For "APFS for Linux by Pargon Software": https://www.paragon-software.com/us/home/apfs-linux/ --> click "Buy Now" near top. It is currently $40. – Gabriel Staples May 15 '23 at 20:15
Install libfsapfs-utils (tested in Ubuntu 20.04)
Mount APFS partition 3 of
/dev/sddin a directory/mntfsapfsmount -f 1 /dev/sdd3 /mnt
where, -f file_system_index mounts a specific file system
Unmount APFS partition mounted in the directory
/mntfusermount -u /mnt
-
1This was successful on an 8TB Seagate drive with two partitions, however I was only able to mount the second partition, sadly this was not my partition of interest. I'll fiddle more with the -f # option. Could you explain that flag further? I'm still confused about it. Something to note, that package is only available for Ubuntu and Ubuntu derivatives if you have focal fossa, if you're using bionic still, then you'll be greeted with dependency hell. – Tmanok Nov 07 '20 at 11:49
-
I can get this to work on Linux Mint 20.10 (Ubuntu 20.04) the drive seems to mount but only can read only access files with `sudo` but guess that's better than nothing. – lacostenycoder May 25 '21 at 19:17
-
1Before any Raspberry Pi 2 users get excited as I did, fsapfsmount seems to only be available for 64 bit OSes. – ianrandmckenzie Sep 11 '21 at 08:33
-
For anyone wondering, I was able to install `libfsapfs-utils` on Ubuntu 20.04 as follows: `sudo apt update`, then `sudo apt install --fix-broken`, then `sudo apt install libfsapfs-utils`. – Gabriel Staples May 15 '23 at 20:08
-
This appears to be the GitHub page for `libfsapfs`: https://github.com/libyal/libfsapfs. And here's the Ubuntu package: https://packages.ubuntu.com/focal/libfsapfs-utils – Gabriel Staples May 15 '23 at 20:18
There is a dedicated linux-apfs driver, which even has experimental write support: https://github.com/linux-apfs
If you are on Arch Linux or a derivative, you can install it from the AUR.
-
1Do you have any suggestions regarding Debian based Linux OS's? I couldn't find a Linux Kernel version specific to this driver or an APT for it, only libfsapfs-utils and a couple others. Thanks! – Tmanok Nov 07 '20 at 11:52
-
2It seems that there are no debian packages for this module, but there are instructions to build on it at https://github.com/linux-apfs/linux-apfs-oot – Nov 07 '20 at 17:19
-
2That was legitimately easier than libapfs-utils, thank you for pointing that out, not sure how I had missed it. For Ubuntu and Linux Mint users, it means that plugging in the external APFS drive will auto-mount using Nautilus or Nemo, whereas libapfs-utils requires a manual mount command. Additionally, it's more native in that now tools like ncdu are able to scan the drive properly! – Tmanok Nov 09 '20 at 01:58
-
I just tested this. Works great for _read only_ on a _non_-encrypted APFS filesystem! The new tool is now called `linux-apfs-rw`, and is here: https://github.com/linux-apfs/linux-apfs-rw. I was able to even install and use it on an Ubuntu 20.04 live USB installation disk I just plugged into a 2015 MacBook to recover data. – Gabriel Staples May 16 '23 at 19:10
I didn't test it myself, but it seems that a commercial solution is available (currently read-only):
https://backstage.paragon-software.com/business/apfs-linux/
The page doesn't say much, not even the price, though.
- 177
- 1
- 8
How to mount Apple APFS filesystems
1. FOSS tools for Linux
I was able to get two really good tools to work:
linux-apfs-rwis by far the best I got working, but its current limitation is that "Encryption is not yet implemented, even in read-only mode". For my 2015 MacBook Air, that wasn't a big deal, but most if not all modern MacBooks come encrypted now I think, which would pose a problem. To install it on Linux Ubuntu (including on an Ubuntu 22.04 live USB), run the following script. It takes a couple minutes to run on a newly-booted Ubuntu 22.04 live USB, but surely beats retyping this every time you need it!:install_linux-apfs-rw.sh:
#!/usr/bin/env bash # Gabriel Staples # 20 May 2023 # Install a linux kernel APFS Apple Filesystem module to allow us # to mount and read Apple AFPS drives. # See my instructions online: # https://github.com/linux-apfs/linux-apfs-rw/issues/42#issuecomment-1556103266 install_apfs() { STARTING_DIR="$(pwd)" sudo add-apt-repository universe -y sudo apt update sudo DEBIAN_FRONTEND=noninteractive apt install -y \ linux-headers-$(uname -r) \ git \ gcc \ g++ \ cmake \ make \ ncdu mkdir -p ~/dev cd ~/dev git clone https://github.com/linux-apfs/linux-apfs-rw.git cd linux-apfs-rw time make sudo modprobe libcrc32c sudo insmod apfs.ko cd "$STARTING_DIR" echo "Done installing linux-apfs-rw kernel module"\ "to allow you to mount and read Apple APFS filesystems!" } install_all() { time install_apfs "$@" } # Determine if the script is being sourced or executed (run). # See: # 1. "eRCaGuy_hello_world/bash/if__name__==__main___check_if_sourced_or_executed_best.sh" # 1. My answer: https://stackoverflow.com/a/70662116/4561887 if [ "${BASH_SOURCE[0]}" = "$0" ]; then # This script is being run. __name__="__main__" else # This script is being sourced. __name__="__source__" fi # Only run `main` if this script is being **run**, NOT sourced (imported). # - See my answer: https://stackoverflow.com/a/70662116/4561887 if [ "$__name__" = "__main__" ]; then time install_all "$@" fiMark it executable, and run it:
chmod +x install_linux-apfs-rw.sh ./install_linux-apfs-rw.shWhat's really nice about this tool is that it works with the normal
mountcommand, so clicking on the APFS disk in your GUI file manager automatically mounts and opens it!I've asked Parted Magic to install
linux-apfs-rwandapfs-fuseinto Parted Magic as part of the default image, in this private forum post here: https://partedmagic.com/forums/viewtopic.php?p=8936#p8936. We'll see if they do this. Hopefully they do!apfs-fuse. This tool installed easily, and allowed me to read the files, butduwould show all files on the mounted APFS drive as 0 bytes. I don't know why. I opened an issue here: https://github.com/sgan81/apfs-fuse/issues/180Here are my installation and usage instructions, again, on a fresh Ubuntu 20.04 or 22.04 live USB:
How to build
apfs-fuseon a fresh Ubuntu 20.04 live USB# See: https://askubuntu.com/a/227788/327339 sudo add-apt-repository universe sudo apt install ncdu # see my comment: https://github.com/sgan81/apfs-fuse/issues/101#issuecomment-1547206616 sudo apt install fuse libfuse3-dev bzip2 libbz2-dev cmake gcc g++ git libattr1-dev zlib1g-dev git clone https://github.com/sgan81/apfs-fuse.git cd apfs-fuse git submodule update --init --recursive mkdir build cd build cmake .. time make ./apfs-fuse -h # mount mkdir -p ~/mount/macbook sudo ./apfs-fuse /dev/sda2 ~/mount/macbook/ # unmount sudo umount ~/mount/macbookAnd to view the mounted files as root via the default Ubuntu
nautilusfile manager:sudo nautilus /home/ubuntu/mount/macbook/The cool thing about this tool is that once I built it, even if building it on my main Linux machine, using it on an Ubuntu live USB, or even on a Parted Magic boot disk, was as simple as copying over the executable!
It would just run.
That's it for the free and open source tools I was able to get to work, and I tried really flippin' hard on this, probably spending 1 full week and 70 or so hours on it.
2. Paid tools for Windows or Linux
In the future, if I need a tool to work, and I don't want to waste my time, and if one of the above two tools doesn't work immediately (ex: on an encrypted APFS filesystem), I think I'll just fork out the $40 and be done!
- For Linux: $40 for personal use: APFS for Linux by Paragon Software --> click "Buy now." It's probably worth it.
- For Windows: the trial is free, otherwise it's $50 for personal use: APFS for Winows by Paragon Software --> click "Download" for the trial version, or "Buy now" to buy.
They have business licenses too. I'll let you find the links from there.
The APFS ecosystem of tools
The maker of linux-apfs-rw was kind enough to help me understand the various tools available, here:
I think it would be nice to have an "alternatives" section in the readme
I guess I can do that eventually. For now I'll tell you here quickly:
This is a fuse driver, not a kernel driver. So it's probably more portable, but it's also much slower. Unlike mine it also supports encryption, but it's read-only and has no plans for write support. Writes take much more work to implement than reads, so that's a big selling point for both my driver and the Paragon one.
I've never used this one (though I did get some layout information from the author's work). The first obvious difference is that it's a library. So again, more portable than mine, and it can be built into other tools if that's what you want. I think it includes a way to mount via fuse, so it's similar to the previous one in that regard.
Assuming the README is up to date, it seems to be missing support for snapshots and several compression algorithms, which are all supported in my driver (and also in apfs-fuse, I believe). I don't know where it stands in some stuff it doesn't mention, like sealed volumes. I'm guessing those are not implemented. It does support encryption though.
Like apfs-fuse, this one is also read-only, and there are no plans for write support as far as I can see.
The main disadvantage of this one is that it's paid and closed-source. I've never used it (I'm assuming it's expensive?), so I can't talk about its quality, sorry. It's probably much more complete than mine, and they don't use the 'experimental' disclaimer like I do, so they must be very confident that the writes work correctly. Nobody likes to lose data though, and we don't know much about its development process, so if you are interested in this option you should talk to other customers and see if it's reliable.
See also
- If trying to back up stuff from a
CrapMacBook, using a Linux live USB booted on the Mac, I recommend the exFAT filesystem, but it's a bit tricky. Here are some answers I wrote for this project that you'll need:- Which filesystem to use for Windows, Mac, and Linux?
- How to format an exFAT filesystem on Linux with the desired cluster size to tune your selection along the tradeoff curve between speed and disk usage
- Best
rsyncsettings for copying and mirroring to or from FAT and exFAT filesystems - [article on my website] exFAT filesystem speed and disk usage based on cluster size
- [article on my website] How to repair your MacBook when it won’t boot
- 1,818
- 2
- 22
- 34
Paragon now has driver with full Read/Write support:
https://www.paragon-software.com/home/apfs-linux/
(it's not free though)
- 135
- 4
-
7Paragon was already mentioned in Marcelo's answer, then in Aleksei Nosachev's answer. If you are just adding that it now has full read/write support, that would be more appropriate as a comment on Marcelo's answer. – fixer1234 May 24 '19 at 20:41