linux-apfs / linux-apfs-rw

APFS module for linux, with experimental write support
GNU General Public License v2.0
532 stars 35 forks source link

wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error. #1

Closed sickcodes closed 3 years ago

sickcodes commented 3 years ago

Hey @eafer, I'm very very keen on using this!

[user@hostname ~]$ yay apfs
5 aur/linux-apfs-git 1:r6.2a598f1-1 (+2 0.68) (Installed: 1:r8.0e35d97-1)
    Experimental APFS kernel module (DKMS)
4 aur/apfsprogs-git r304.26f3461-1 (+3 0.68) (Installed: r331.8ecdb0b-1)
    Experimental APFS tools for linux
3 aur/linux-apfs-dkms-git 1:r5.277a34e-1 (+5 0.68) (Installed: 1:r8.0e35d97-1)
    Experimental APFS kernel module (DKMS)
2 aur/apfs-fuse-git r77.670e45e-1 (+9 0.79) (Installed: r92.ee71aa5-1)
    FUSE driver for APFS (Apple File System)
# dkms status
linux-apfs, 0.1, 5.10.26-1-lts, x86_64: installed
linux-apfs, 0.1, 5.11.10-arch1-1, x86_64: installed (original_module exists)

Install over your existing linux-apfs-dkms-git? https://github.com/linux-apfs/linux-apfs-rw/commit/cb4f9d2514ea0d4913ddc2ce3b4fe95258b22587

sudo pacman -Rns linux-apfs-dkms-git linux-apfs-git
yay --getpkgbuild linux-apfs-dkms-git
cd linux-apfs-dkms-git
sed -i -e s/oot/rw/ PKGBUILD
makepkg -si

I have a 50GB raw disk image, made with https://github.com/sickcodes/Docker-OSX

It is APFS + Unencrypted + Case Sensitive:

export IMAGE="${PWD}/mac_hdd_ng_nonqcow.img"
sudo mkdir -p "/media/${USER}/macos"
fdisk -l ${IMAGE}
Disk ./mac_hdd_ng_nonqcow.img: 50 GiB, 53687091200 bytes, 104857600 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: 5C21B10B-9C3E-4AE9-8482-F4C321A8094D

Device                                                   Start      End  Sectors  Size Type
./mac_hdd_ng_nonqcow.img1     40   409639   409600  200M EFI System
./mac_hdd_ng_nonqcow.img2 409640 48174215 47764576 22.8G Apple APFS

apfs-fuse works fine (read-only)

sudo apfs-fuse -o allow_other "$IMAGE" "/media/${USER}/macos"
ls "/media/${USER}/macos"
# private-dir  root
sudo touch "/media/${USER}/macos/root/ok"
# touch: cannot touch '/media/user/macos/root/ok': Read-only file system
sudo umount "/media/${USER}/macos"

When I try mount your new one, I get the bad superblock error :(

[user@hostname test]$ sudo mount -t apfs -o cknodes,vol=1 "$IMAGE" "/media/${USER}/macos"
mount: /media/${USER}/macos: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
[user@hostname test]$ stat /dev/loop0 
  File: /dev/loop0
  Size: 0           Blocks: 0          IO Block: 4096   block special file
Device: 5h/5d   Inode: 801         Links: 1     Device type: 7,0
Access: (0660/brw-rw----)  Uid: (    0/    root)   Gid: (  994/    disk)
Access: 2021-04-04 00:22:50.183666683 +0000
Modify: 2021-04-04 00:22:50.183666683 +0000
Change: 2021-04-04 00:22:50.183666683 +0000
 Birth: -
sudo losetup -d /dev/loop0
[user@hostname ~]$ sudo losetup -d /dev/loop0
losetup: /dev/loop0: detach failed: No such device or address

Since I can still apfs-fuse, I need to remove all and install ONLY this -rw repo instead of -oot?

Also, perhaps change https://github.com/linux-apfs/linux-apfs-rw/blob/master/dkms.conf to

PACKAGE_NAME="linux-apfs-rw"
PACKAGE_VERSION="0.2"

BUILT_MODULE_NAME[0]="apfsrw"
DEST_MODULE_LOCATION[0]="/extra"

Or will you merge into linux-apfs soon?

Should I try the non-dkms version?

sickcodes commented 3 years ago

Image did have bad superblock xD

This is amazing @eafer!

eafer commented 3 years ago

I'm glad that you like it, and thanks for pointing out the dkms issue. I don't use it myself so I forgot to change it.