I have a Macbook Pro running MacOS X Catalina with a 500G SSD drive.
I installed Bootcamp on it, and in an effort to expand the bootcamp partition, I shrunk the main MacOS partition by 64G. then booted into Windows to expand the bootcamp partition using MiniTool Partition Wizard.
Instead of deleting just the newly created partition of 64G, I also mistakenly deleted the main OSX partition (by using partition manager, and then right clicking on the main MacOS partition, and selecting delete).
My HD used to look like this:
1 | 2 | 3 | 4 |
---|---|---|---|
EFI | Mac OS partition | Unallocated space (64G) | BOOTCAMP (64G) |
but now it's like the following
1 | 2 | 3 |
---|---|---|
EFI | Unallocated space | BOOTCAMP (64G) |
I can no longer boot in MacOS mode. but I'm able to boot into Windows 10.
When I startup in Recovery mode this is the output I get from running the following commands:
# diskutil list
/dev/disk0 (disk image):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme +2.1 GB disk0
1: Apple_HFS OS X Base System 2.0 GB disk0s1
/dev/disk1 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *500.3 GB disk1
1: EFI EFI 209.7 MB disk1s1
2: Microsoft Basic Data BOOTCAMP 64.1 GB disk1s2
and
# gpt -r show disk1
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 851564504
851974144 125130752 2 GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
977104896 131
977105027 32 Sec GPT table
977105059 1 Sec GPT header
As you can see from the last command, the partition is still there but not recognised...
I am sure all the data is still there, as I didn't write to the disk. Is there anyway to restore my deleted MacOS partition without loosing any data? is it possible using the recovery mode or even Windows 10 that's installed on the bootcamp partition?
Any help is very much appreciated.
EDIT: As per @David Anderson's comment:
# export LC_CTYPE="ASCII";dd if=/dev/disk1 count=1 bs=16 skip=13108482 | vis -cw;echo
1+0 records in
1+0 records out
16 bytes transferred in 0.001788 secs(8948 bytes/sec)
NXSB\0\^P\0\0\M-S\M-Oi\^E\0\0\0\0
Using macOS, the above output can be converted to hexadecimal by the following command.
echo -n "NXSB\0\^P\0\0\M-S\M-Oi\^E\0\0\0\0" | unvis | hexdump -Cv
Doing so produces the following output.
00000000 4e 58 53 42 00 10 00 00 d3 cf 69 05 00 00 00 00 |NXSB......i.....|
00000010
According to klanomath's answer to this question, the following can be determined
4e 58 53 42
: magic string of an APFS container00 10 00 00
: APFS block size: 4096d3 cf 69 05 00 00 00 00
APFS container size in APFS blocks: 90820563 (=726564504 512-blocks)
diskutil unmountdisk disk1
followed byexport LC_CTYPE="ASCII";dd if=/dev/disk1 count=1 bs=16 skip=13108482 | vis -cw;echo
. Edit your question and add the output from the commands.