How to fix partition table after resizing bootcamp, MacOS disappear
Solution 1:
The sudo get -r show disk0
command shows values stored in the GUID Partition Table (GPT) on the internal drive. The sudo dd if=/dev/disk0s2 count=1 bs=128 | hexdump -Cv
shows values stored at the beginning of the second partition on the internal drive.
The size in blocks of a APFS container is stored in the 8 bytes at offset 40 (28 hexadecimal) of the partition. In your case the bytes are fb 99 f2 04 00 00 00 00
. This can be converted to 512 byte sectors by the following steps.
- Reverse the order and remove the leading zeros to get 4f299fb.
- Use the Calculator application (or other equivalent means) to convert hexadecimal to decimal. In this case, the result is 83,007,995 blocks, where a block is 4096 bytes.
- In your case, there are 8 sectors per block. So the conversation to sectors is accomplished by multiplying by 8 to get 664,063,960 sectors, which is 340,000,747,520 bytes.
However, the output from the sudo gpt -r show disk0
command shows the size of the partition, with this APFS container, is only be 644,531,248 sectors, which is 329,999,998,976 bytes. This discrepancy would prevent any volumes in the APFS container from mounting.
Apparently, the macOS APFS container in the second partition and Windows NTFS volume in the third partition overlap by 10 GB. Since you can not mount the Windows NTFS volume, there is not enough information posted to the question to know this for certain. In other words, location and size of the NTFS volume is currently unknown. Also, neither the APFS container or NTFS volume may be intact.
I suppose, since the data on the macOS APFS volumes is important, the following commands could be used to remove the Windows partition and expand APFS partition to 340 GB. Hopefully, the desired volumes will mount and the data can be recovered.
diskutil unmount disk0s3
sudo gpt -f remove -i 3 disk0
sudo gpt -f remove -i 2 disk0
sudo gpt -f add -i 2 -b 409640 -s 664063960 -t apfs disk0