This incident occurred a few months ago, so you will have to forgive my poor memory. Please let me know if anything needs clarification.
I had a Dell Latitiude E6410 that I was using as a hackintosh (read: I installed macOS on non-Apple hardware). It was booting macOS 10.15.3 Catalina off of an APFS volume using a Legacy-based Clover installation. I wanted to switch to a UEFI-based boot solution.
Unfortunately, my laptop had trouble detecting ESPs that weren't identified explicitly as FAT32 volumes, even if they were, in all other respects, FAT32 volumes.
Rather than wipe my hard drive and reinstall macOS completely, as I should have done, I attempted to change the partition type of the ESP from "ESP" to "FAT32" using either fdisk or gdisk.
As I recall, this did not work, so I used fdisk to reformat the ESP as a FAT32 partition. For whatever reason, the command used to do so was taking a bit longer than usual - I believe this was because it was formatting the FAT32 partition outside of its specified 200MB bounds, thus overwriting the following APFS header - so I cancelled the command. For whatever reason, I afterwards rebooted my computer, and was greeted with a lovely "no bootable volume found" screen from the laptop's BIOS.
My data was gone, or so I suspected at first. Here's what diskutil list
reports:
/dev/disk4 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *275.1 GB disk4
1: EFI NO NAME 209.7 MB disk4s1
2: Apple_APFS Container disk5 274.9 GB disk4s2
/dev/disk5 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +ERROR disk5
Physical Store disk4s2
diskutil apfs list
:
APFS Containers (2 found)
|
...
|
+-- Container ERROR -69808
======================
APFS Container Reference: disk5
Size (Capacity Ceiling): ERROR -69620
Capacity In Use By Volumes: ERROR -69620
Capacity Not Allocated: ERROR -69620
|
+-< Physical Store disk4s2 D6816D3B-582B-485D-8CC4-0079AF1EBEBD
| -----------------------------------------------------------
| APFS Physical Store Disk: disk4s2
| Size: 274854445056 B (274.9 GB)
|
+-> No Volumes
fsck_apfs
:
** Checking the container superblock.
** Checking the EFI jumpstart record.
** Checking the space manager.
error: (oid 0x7126) cib: found zeroed-out block
error: failed to read spaceman cib 0x7126
Space manager is invalid.
** The volume /dev/disk4s2 could not be verified completely.
inspect_apfs
from Jivan Pal's apfs-tools (see this question): pastebin
I'd like to recover the data that was on this APFS volume, retaining original filesystem structure if possible. Note that I was able to use R-Studio to see the original "Hackintosh HD - Data" partition and view some of my files. However, for the most part, the filesystem structure was not preserved, mixing in a tragic amount of caches and the likes with my valuable data. Also note that I believe my conundrum is rather similar to this conundrum.
Thank you.