Skip to content

Instantly share code, notes, and snippets.

@tuklusan
Last active March 2, 2020 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuklusan/ed0c26da22df8106393c2c5b27e82b00 to your computer and use it in GitHub Desktop.
Save tuklusan/ed0c26da22df8106393c2c5b27e82b00 to your computer and use it in GitHub Desktop.
Mount MAC OS X APFS file system partition for Linux Ubuntu Mate on Apple MacBook Pro 17" - See https://supratim-sanyal.blogspot.com/2020/02/install-and-dual-boot-linux-on-17-inch_17.html
###
# Terminal session log:
# Mounting MacOS X APFS partition on Linux Ubuntu Mate on Apple MacBook Pro 17"
# See https://supratim-sanyal.blogspot.com/2020/02/install-and-dual-boot-linux-on-17-inch_17.html
###
localuser@macbookpro17inch:~$ # MOUNT THE MAC OS X APFS PARTITION ON UBUNTU ON MACBOOK PRO
localuser@macbookpro17inch:~$ sudo apt-get update
...
localuser@macbookpro17inch:~$ sudo apt-get upgrade
...
localuser@macbookpro17inch:~$ mkdir apfs-fuse.build
localuser@macbookpro17inch:~$ cd apfs-fuse.build/
/home/localuser/apfs-fuse.build
localuser@macbookpro17inch:~/apfs-fuse.build$ git clone https://github.com/sgan81/apfs-fuse.git
Cloning into 'apfs-fuse'...
remote: Enumerating objects: 803, done.
Receiving objects: 0% (1/803)
Receiving objects: 1% (9/803)
...
Resolving deltas: 100% (533/533), done.
localuser@macbookpro17inch:~/apfs-fuse.build$ cd apfs-fuse
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse$ git submodule init
Submodule '3rdparty/lzfse' (https://github.com/lzfse/lzfse.git) registered for path '3rdparty/lzfse'
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse$ git submodule update
Cloning into '/home/localuser/apfs-fuse.build/apfs-fuse/3rdparty/lzfse'...
Submodule path '3rdparty/lzfse': checked out 'e634ca58b4821d9f3d560cdc6df5dec02ffc93fd'
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse$ mkdir build
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse$ cd build
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ cmake ..
Command 'cmake' not found, but can be installed with:
sudo apt install cmake
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo apt install cmake
Reading package lists... 0%
...
After this operation, 25.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ cmake ..
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/localuser/apfs-fuse.build/apfs-fuse/build
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ make
Scanning dependencies of target lzfse
[ 2%]
Building C object CMakeFiles/lzfse.dir/3rdparty/lzfse/src/lzfse_decode.c.o
...
Building CXX object CMakeFiles/apfs.dir/ApfsLib/Util.cpp.o
/home/localuser/apfs-fuse.build/apfs-fuse/ApfsLib/Util.cpp:37:10:
fatal error:
bzlib.h: No such file or directory
#include <bzlib.h>
compilation terminated.
CMakeFiles/apfs.dir/build.make:734: recipe for target 'CMakeFiles/apfs.dir/ApfsLib/Util.cpp.o' failed
make[2]: *** [CMakeFiles/apfs.dir/ApfsLib/Util.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/apfs.dir/all' failed
make[1]: *** [CMakeFiles/apfs.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo apt-get install libbz2-1.0 libbz2-dev libbz2-ocaml libbz2-ocaml-dev
Reading package lists... 0%
...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
W: http://us.archive.ubuntu.com/ubuntu/pool/main/n/ncurses/libtinfo-dev_6.1-1ubuntu1.18.04_amd64.deb: Automatically disabled Acquire::http::Pipeline-Depth due to incorrect response from server/proxy. (man 5 apt.conf)
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo apt install fuse libfuse-dev libicu-dev bzip2 libbz2-dev cmake clang git libattr1-dev
Reading package lists... 0%
Reading package lists... 100%
...
http://us.archive.ubuntu.com/ubuntu/pool/main/g/gcc-7/libobjc-7-dev_7.4.0-1ubuntu1~18.04.1_amd64.deb: Automatically disabled Acquire::http::Pipeline-Depth due to incorrect response from server/proxy. (man 5 apt.conf)
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ make clean
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ make
[ 2%]
Building C object CMakeFiles/lzfse.dir/3rdparty/lzfse/src/lzfse_decode.c.o
...
[K/home/localuser/apfs-fuse.build/apfs-fuse/apfsfuse/ApfsFuse.cpp:31:10:
fatal error: fuse3/fuse.h: No such file or directory
#include <fuse3/fuse.h>
compilation terminated.
CMakeFiles/apfs-fuse.dir/build.make:62: recipe for target 'CMakeFiles/apfs-fuse.dir/apfsfuse/ApfsFuse.cpp.o' failed
make[2]: *** [CMakeFiles/apfs-fuse.dir/apfsfuse/ApfsFuse.cpp.o] Error 1
CMakeFiles/Makefile2:143: recipe for target 'CMakeFiles/apfs-fuse.dir/all' failed
make[1]: *** [CMakeFiles/apfs-fuse.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /home/localuser/apfs-fuse.build/apfs-fuse/build
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ ccmake .
Command 'ccmake' not found, but can be installed with:
sudo apt install cmake-curses-gui
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo apt install cmake-curses-gui
Reading package lists... 0%
...
[####################################################################..............]
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
#####
## Now we run ccmake to disable FUSE 3 library and use FUSE 2 library instead
####
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ ccmake .
#####
## AT this point, curses-based ccmake launches. Do the following:
## - Navigate to USE_FUSE3, and if it is not set to OFF, hit enter
## - Press c to configure
## - Press g to generate Makefile and exit ccmake
##
## Ref: response by Simon Gander (sgan81) at https://github.com/sgan81/apfs-fuse/issues/87
####
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ make clean
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ make
[ 2%]
Building C object CMakeFiles/lzfse.dir/3rdparty/lzfse/src/lzfse_decode.c.o
In file included from
/home/localuser/apfs-fuse.build/apfs-fuse/3rdparty/lzfse/src/lzfse_internal.h:30:0
from
/home/localuser/apfs-fuse.build/apfs-fuse/3rdparty/lzfse/src/lzfse_decode.c:25
...
...
Linking CXX executable apfsutil
[100%] Built target apfsutil
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ ls -lrt
total 2396
-rw-rw-r-- 1 localuser localuser 3116 Feb 13 13:57 cmake_install.cmake
-rw-rw-r-- 1 localuser localuser 15954 Feb 13 14:04 CMakeCache.txt
-rw-rw-r-- 1 localuser localuser 47562 Feb 13 14:04 Makefile
-rw-rw-r-- 1 localuser localuser 58358 Feb 13 14:04 liblzfse.a
-rw-rw-r-- 1 localuser localuser 655208 Feb 13 14:05 libapfs.a
-rwxrwxr-x 1 localuser localuser 410992 Feb 13 14:05 mapfs-dump
-rwxrwxr-x 1 localuser localuser 443648 Feb 13 14:05 mapfs-fuse
-rwxrwxr-x 1 localuser localuser 397960 Feb 13 14:05 mapfs-dump-quick
-rwxrwxr-x 1 localuser localuser 397488 Feb 13 14:05 mapfsutil
drwxrwxr-x 10 localuser localuser 4096 Feb 13 14:05 CMakeFiles
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo cp apfs-* /usr/local/bin
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo cp apfsutil /usr/local/bin
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo fdisk -l
...
...
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 084E7565-6EF5-4A47-98B6-CABDA6CA8B4D
Device Start End Sectors Size Type
/dev/sda1 40 409639 409600 200M EFI System
/dev/sda2 409640 488688511 488278872 232.8G unknown
/dev/sda3 488688512 976967383 488278872 232.8G Linux filesystem
/dev/sda4 976967384 1953525127 976557744 465.7G unknown
#####
## The Mac OS X APFS partition is /dev/sda2
## I know this because I have only two 250GB partitions, and /dev/sda2 is of Type "unknown".
#####
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo mkdir /macos-filesystem # This is the mount-point for the APFS partition
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo apfs-fuse -o ro,allow_other /dev/sda2 /macos-filesystem # Run a mount command for testing
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
...
/dev/sda2 on /macos-filesystem type fuse (ro,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
# Mount is successful
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ ls -l /macos-filesystem/root/Users/localuser
total 0
drwx------ 1 502 dialout 2 Feb 1 03:02 Applications
...
...
drwxr-xr-x 1 502 dialout 2 Feb 1 02:05 Public
# Unmount it
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo fusermount -u /macos-filesystem
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sync
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ # "Making it stick"
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo ln -s /usr/local/bin/apfs-fuse /usr/sbin/mount.apfs
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo cp /etc/fstab /etc/fstab.orig
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo vi /etc/fstab
#####
## Now add the following line at the bottom:
## mount.apfs#/dev/sda2 /macos-filesystem fuse ro,noexec,userr,allow_other 0 0
#####
#####
## Test mount from /etc/fstab
#####
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ sudo mount -a
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
...
/dev/sda3 on / type ext4 (rw,relatime,errors=remount-ro)
...
/dev/sda2 on /macos-filesystem type fuse (ro,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,allow_other)
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ ls -l /macos-filesystem/
total 0
drw-r--r-- 1 root root 0 Feb 13 10:42 private-dir
drwxr-xr-x 1 root root 28 Feb 2 00:42 root
localuser@macbookpro17inch:~/apfs-fuse.build/apfs-fuse/build$ ls -l /macos-filesystem/root/Users/localuser/
total 0
drwx------ 1 502 dialout 2 Feb 1 03:02 Applications
...
drwxr-xr-x 1 502 dialout 2 Feb 1 02:05 Public
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment