3

I was trying to resize windows partition using EASEUS partition manager in windows to free up unallocated space so that I can extend APFS partition in macOS but I failed to boot into macOS after resizing. Please help me! how to recover lost APFS partition?

Hex dump below.

enter image description here

enter image description here

Amans-iMac:~ aman$ sudo dd if=/dev/disk1 skip=335874048 bs=512 count=1 | hexdump 
Password:
1+0 records in
1+0 records out
512 bytes transferred in 0.001917 secs (267067 bytes/sec)
0000000 b9 e9 ff cb a4 6d fc f3 01 00 00 00 00 00 00 00
0000010 fc da 09 00 00 00 00 00 01 00 00 80 00 00 00 00
0000020 4e 58 53 42 00 10 00 00 29 ea 22 01 00 00 00 00
0000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000040 02 00 00 00 00 00 00 00 d8 36 06 fb 2f 1f 42 7a
0000050 b2 90 f5 cc 5c 85 9f 36 13 6f 08 00 00 00 00 00
0000060 fd da 09 00 00 00 00 00 18 01 00 00 18 6c 00 00
0000070 21 3c 06 00 00 00 00 00 28 c9 05 00 00 00 00 00
0000080 70 00 00 00 18 0f 00 00 6e 00 00 00 02 00 00 00
0000090 bc 0e 00 00 5c 00 00 00 af 6b 00 00 00 00 00 00
00000a0 69 ad 04 00 00 00 00 00 01 04 00 00 00 00 00 00
00000b0 00 00 00 00 64 00 00 00 03 04 00 00 00 00 00 00
00000c0 a4 6b 00 00 00 00 00 00 a6 6b 00 00 00 00 00 00
00000d0 a6 0d 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
0000200
1

Your partition table seems screwed:

Your first partition on disk1 is a Windows Recovery partition, the second is an EFI partition. Then either Microsoft Reserved (E3C9E316-0B5C-4DB8-817D-F92DF00215AE), Basic data (EBD0A0A2-B9E5-4433-87C0-68B6B72699C7) or Windows Recovery (DE94BBA4-06D1-4D40-A16A-BFD50179D6AC) partitions.

But the hexdump of block 335874048 (the first block of the 6th partition) looks promising:

...
0000020 4e 58 53 42 00 10 00 00 29 ea 22 01 00 00 00 00
...
  • 4e 58 53 42: magic string of an APFS container
  • 00 10 00 00: APFS block size: 4096
  • 29 ea 22 01 00 00 00 00 APFS container size in APFS blocks: 19065385 (=152523080 512-blocks)

    After re-arranging the Bytes 29 ea 22 01 00 00 00 00 > 00 00 00 00 29 ea 22 01 > 00 00 00 00 01 22 ea 29, you can get the decimal value here:

    enter image description here

The sixth partition obviously has the wrong type!

The partition type has to be modified with gpt then:

  • Disable SIP in Recovery Mode (the recovery system version has to be 10.11 or newer)
  • Boot to your external drive or Internet Recovery Mode.
  • Open Terminal and get some details:

    diskutil list
    sudo gpt -r show /dev/disk1
    
  • remove the 6th partition:

    sudo gpt remove -i 6 /dev/disk1
    
  • restore the same partition with the proper type:

    sudo gpt add -i 6 -b 335874048 -s 152523080 -t 7C3457EF-0000-11AA-AA11-00306543ECAC /dev/disk1
    
  • check the APFS container

    diskutil verifyVolume disk1s6
    
  • Enable SIP in Recovery Mode

The partition layout is still uncommon since macOS usually requires an EFI partition as first partition.

The non-default layout may prevent firmware updates in the future!

  • Thanks for saving me :) My mac is booting fine. Any way to safely extend APFS partition by shrinking Windows partition? – LegendaryAman Jan 21 '18 at 1:06
  • I guess I have to backup the current partition and then restore to the newly extended partition. – LegendaryAman Jan 21 '18 at 1:11
  • Around 128 gigs. – LegendaryAman Jan 21 '18 at 1:17
  • What I am upto is: Create DMG backup of macOS > Shrink windows disk > delete macOS > create a new partition from unallocated space in windows > Create a new APFS partition from that > restore dmg on new partition. – LegendaryAman Jan 21 '18 at 1:29
  • Will it work?.... – LegendaryAman Jan 21 '18 at 1:29
0

Found an easy way to shrink windows partition to increase space on apfs container if your partition table is messed up.

  • Make TimeMachine/Disk backup before proceeding.

  • Boot into other macOS using external disk/usb and download trial version of paragon Hard Disk Manager and shrink Windows/ntfs volume to your desired size.

  • In Paragon HDM Move free space by right clicking on APFS partition > Move/Resize Partition(Paragaon HDM will show APFS conatiner unformated but its okay) Move slider to add free space after the end of the APFS container.
  • Resize APFS container. diskutil apfs resizeContainer disk1s6 0 where disk1s06 is your apfs container id. Using 0 will allocate all the free space, you can also replace 0 with custom size like 120g. It Should be <= to Free unallocated space. Use diskutil list to verify your container id.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .