0

I recently had an issue relating to BootCamp that rendered my Mojave partition unbootable, so I got interested on how to read that APFS partition to retrieve the files using my elementary OS Juno, saved by access through Grub. Fortunately there is a free solution to perform this recovery through apfs-fuse.

1 Answer 1

1

Plan

  1. There's a free tool to mount APFS drive in linux: apfs-fuse https://github.com/sgan81/apfs-fuse for Linux
  2. installation process prerequisites (taken from this walkthrough)
  3. compiling install missing dependencies by googling the error messages, simply relaunch make

There are many packages that need to be installed to run apfs-fuse. use the below command to update APT

apt-get update

Then, install the required dependencies with apt-get, as seen below.

apt-get install zlib1g bzip2 gcc-8-base build-essential cmake clang icu-devtools libicu-dev libghc-bzlib-dev libfuse-dev libattr1-dev

Clone the Apfs-Fuse Repository:

Next, install Git with apt-get install git.

apt-get install git

Then, clone the apfs-fuse repository with git clone github.com/sgan81/apfs-fuse.

git clone https://github.com/sgan81/apfs-fuse

Change into the newly created apfs-fuse/ directory using the cd command.

cd apfs-fuse/

Update the Submodules:

Use git submodule init to initialize the LZFSE compression submodule.

git submodule init

Then, use git submodule update to update the LZFSE compression submodule.

git submodule update

Wrap Up the Installation:

Create a new directory called build using the mkdir command.

mkdir build

Next, change into the directory.

cd build/

Then, compile with CMake, a software for managing the build process of software using a compiler-independent method.

cmake ..

Last, use make, a utility that will determine automatically which pieces of a program need to be recompiled.

Test Apfs-Fuse:

That's it for downloading and compiling apfs-fuse.

Apfs-fuse's available options can be viewed using the ./apfs-fuse command. Change to the directory where apfs-fuse is located. (/bin or in my case, build).

./apfs-fuse

Options: -d level : Enable debug output in the console. -o options : Additional mount options. -v volume-id : Specify number of volume to be mounted. -r passphrase : Specify volume passphrase. The driver will ask for it if needed. -s offset : Specify offset to the beginning of the container. -p partition : Specify partition id containing the container. -l : Allow driver to return potentially corrupt data instead of failing, if it can't handle something.

Create the Mount Destination:

Create a new directory called my_apfs_partition using the mkdir command.

mkdir /tmp/my_apfs_partition

Use Apfs-Fuse to mount the Partition

./apfs-fuse <partition> <mount destination>

Here's an example of the command I used to mount my MacBook's internal hard drive. When this command is run, apfs-fuse will mount the partition - if encrypted by File Vault, it will prompt for a password.

./apfs-fuse /dev/sda2 /tmp/my_apfs_partition

Your APFS partition will then be browsable from that directory!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.