I am trying to mount a apfs partition in linux.
So far I have been able to compile the apfs-fuse build system, and apfs-fuse seems to be working, if I have a working USB drive with a proper apfs partition as follows
/dev/sda
/dev/sda1
/dev/sda2
In this case, I can use sudo ./apfs-fuse /dev/sda2 /mnt/apfs to mount the apfs partition, and it works.
However, lets say I have a image of a drive from a backup, I am having trouble mounting the partition.
Heres what I did so far to see if I can mount a partition in backup with a damaged drive (deleted partition table) using losetup. I am assuming that I am able to find the beginning and end sectors here.
I created a new file containing 2 partitions using
sudo dd if=/dev/zero of=backup.img bs=1M count=100
sudo fdisk backup.img and partitioned backup.img into two partitions, after which sudo fdisk -lu backup.img shows as follows
Device Boot Start End Sectors Size Id Type
backup.img1 2048 104447 102400 50M 83 Linux
backup.img2 104448 204799 100352 49M 83 Linux
The partitions here are ext3 and ext4 partitions as I am just testing if I can mount partitions with a non-existant partion table using losetup
Then I tried this
sudo losetup -r -o 1048576 /dev/loop0 backup.img works, after which I can do sudo mount /dev/loop0 /mnt/test.
However, I am assuing that I have a raw image with no partition table, so I have to manually provide the partition table. Also I dont want to mess with the existing backup as it could damage the disk further.
sudo losetup -o 1048576 --sizelimit 52428288 /dev/loop0 backup.img works.
However, when I try to mount the loop device using
sudo mount /dev/loop0 /mnt/test, it fails saying
mount: /mnt/test: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program or other error
Why does losetup not recognize the partition when I provide the sizelimit?
Is there something I am missing here?