Recover data from corrupted APFS external volume
Here's how to do this:
-
Create bootable USB Stick for Ubuntu:
If you have a Mac that has a T2 chip, you must first allow the computer to start from other removable media.
-
Once you get Ubuntu running, go to "software & updates" and select everything or you will not get the required community-maintained packages when doing "sudo apt update"
-
Now we install something called APFS-fuse, which allows Ubuntu to mount and read drives that have been formatted with Apple's APFS file system
-
run
sudo apt remove zsys
or you will get an error later -
run (source: https://linuxnewbieguide.org/how-to-mount-macos-apfs-disk-volumes-in-linux/)
sudo apt install libicu-dev bzip2 cmake libz-dev libbz2-dev fuse3 libfuse3-3 libfuse3-dev clang git libattr1-dev
git clone https://github.com/sgan81/apfs-fuse.git
cd apfs-fuse
git submodule init
git submodule update
mkdir build
cd build
cmake ..
make
sudo cp apfs-* /usr/local/bin
-
Run
sudo fdisk -l
and find the identifier of your disk. Say its "sdb1" -
sudo mkdir -p /media/$(stat -f %Su)/macos
-
Mount the disk:
sudo apfs-fuse -o allow_other /dev/sdb1 /media/ubuntu/macos
it will appear in the file viewer and you can see your files. Because you need Ubuntu to see files stored in a filesystem made by Apple...