vermaden / automount

Simple devd(8) based automounter for FreeBSD
66 stars 20 forks source link

Consider supporting APFS #51

Open probonopd opened 10 months ago

probonopd commented 10 months ago

Please consider supporting APFS (the filesystem used on macOS nowadays).

https://www.freshports.org/devel/libfsapfs/ contains a library and tools (especially fsapfsmount) to access the Apple File System (APFS).

vermaden commented 10 months ago

Thank You for pointing my eyes on this.

As I already support HFS I was not aware that its now possible to mount APFS on FreeBSD.

Expect automount(8) update - I hope sooner then later ...

Regards, vermaden

vermaden commented 10 months ago

Seems not to work very well ...

I personally created new APFS filesystem on a apfs.dmg file on a Mac - then transferred to my FreeBSD machine.

These are the results of using libfsapfs package.

% pkg info -l libfsapfs                                                                                                                                                   
libfsapfs-e.20221102:                                                                                                                                                                           
        /usr/local/bin/fsapfsinfo                                                                                                                                                               
        /usr/local/bin/fsapfsmount                                                                                                                                                              
        /usr/local/include/libfsapfs.h                                                                                                                                                          
        /usr/local/include/libfsapfs/codepage.h                                                                                                                                                 
        /usr/local/include/libfsapfs/definitions.h                                                                                                                                              
        /usr/local/include/libfsapfs/error.h                                                                                                                                                    
        /usr/local/include/libfsapfs/extern.h                                                                                                                                                   
        /usr/local/include/libfsapfs/features.h                                                                                                                                                 
        /usr/local/include/libfsapfs/types.h                                                                                                                                                    
        /usr/local/lib/libfsapfs.a                                                                                                                                                              
        /usr/local/lib/libfsapfs.so                                                                                                                                                             
        /usr/local/lib/libfsapfs.so.1                                                                                                                                                           
        /usr/local/lib/libfsapfs.so.1.0.0                                                                                                                                                       
        /usr/local/lib/python3.9/site-packages/pyfsapfs.a                                                                                                                                       
        /usr/local/lib/python3.9/site-packages/pyfsapfs.so                                                                                                                                      
        /usr/local/libdata/pkgconfig/libfsapfs.pc                                                                                                                                               
        /usr/local/man/man1/fsapfsinfo.1.gz                                                                                                                                                     
        /usr/local/man/man1/fsapfsmount.1.gz                                                                                                                                                    
        /usr/local/man/man3/libfsapfs.3.gz                                                                                                                                                      
        /usr/local/share/licenses/libfsapfs-e.20221102/LGPL3+                                                                                                                                   
        /usr/local/share/licenses/libfsapfs-e.20221102/LICENSE                                                                                                                                  
        /usr/local/share/licenses/libfsapfs-e.20221102/catalog.mk

% /usr/local/bin/fsapfsinfo ./apfs.dmg                                                                                                                                    
fsapfsinfo 20221102                                                                                                                                                                             

Unable to open: ./apfs.dmg.
libfsapfs_container_superblock_read_data: invalid object type: 0x00000000.
libfsapfs_container_superblock_read_file_io_handle: unable to read container superblock data.
libfsapfs_internal_container_open_read: unable to read container superblock at offset: 0 (0x00000000).
libfsapfs_container_open_file_io_handle: unable to read from file IO handle.
info_handle_open_input: unable to open input container.

% mdconfig.sh -c apfs.dmg 
IN: created vnode at /dev/md0

% /usr/local/bin/fsapfsinfo /dev/md0  
fsapfsinfo 20221102

Unable to open: /dev/md0.
libfsapfs_container_superblock_read_data: invalid object type: 0x00000000.
libfsapfs_container_superblock_read_file_io_handle: unable to read container superblock data.
libfsapfs_internal_container_open_read: unable to read container superblock at offset: 0 (0x00000000).
libfsapfs_container_open_file_io_handle: unable to read from file IO handle.
info_handle_open_input: unable to open input container.

%  doas /usr/local/bin/fsapfsmount /dev/md0 /mnt/   
fsapfsmount 20221102

Unable to open source container
libfsapfs_container_superblock_read_data: invalid object type: 0x00000000.
libfsapfs_container_superblock_read_file_io_handle: unable to read container superblock data.
libfsapfs_internal_container_open_read: unable to read container superblock at offset: 0 (0x00000000).
libfsapfs_container_open_file_io_handle: unable to read from file IO handle.
mount_handle_open: unable to open container.

Does it behaves the same on your side?

Regards, vermaden

probonopd commented 10 months ago

Were you using APFS version 1 or 2? According to https://github.com/libyal/libfsapfs/wiki, only version 2 and certain features of it are supported.

vermaden commented 10 months ago

Send me please version '2' or give me the instructions to create it.

Thanks in advance.

probonopd commented 10 months ago

Apparently one cannot directly format a regular file with APFS2. APFS (Apple File System) is designed to be used on block devices like hard drives and SSDs, and not on regular files.

APFS version 2 is the default filesystem version for macOS 10.13 and iOS 10.3 and above, hence it will be automatically chosen when creating a new APFS filesystem.

To format a USB stick with the APFS2 file system, one can most likely approximately use the following procedure (unfortunately my Macs don't run a recent enough version of macOS so I couldn't test):

  1. Connect the USB stick to your Mac computer.
  2. Launch Disk Utility. You can find it in the Utilities folder within the Applications folder.
  3. In Disk Utility, locate your USB stick in the list of drives on the left-hand side.
  4. Select the USB stick and click on the "Erase" button in the toolbar.
  5. In the Erase dialog box, choose a name for the volume (filesystem) on the USB stick.
  6. From the Format dropdown menu, select "APFS".
  7. Choose "GUID Partition Map" as the Scheme.
  8. Double-check your settings to ensure they are correct.
  9. Click on the "Erase" button to begin the formatting process.

Please note that formatting the USB stick will erase all data stored on it, so make sure to back up any important files before proceeding.

vermaden commented 10 months ago

I used 'file' for the APFS filesystem creation - does the instruction differ for a file?

probonopd commented 10 months ago

I would assume it puts the APFS into a UDIF file then, which libfsapfs may not be able to read.

vermaden commented 10 months ago

Possibly.