Question

I installed Kali Linux on my iMac as Dual Boot. After a while I needed more space for Kali so I decided to shrink my Mac Partition (APFS) using MacOS Disk Utility Tool.

  • I created a new 100 GB Partition (exFat).
  • I tried to reboot my Computer and only Kali Linux showed up as bootable.

So far I tried to boot in Recovery Mode, but instead of the normal MacOS High Sierra recovery menu the recovery menu from MacOS Lion showed up.

kali@kali:~$ sudo fdisk -l /dev/sda

Disk /dev/sda: 931,53 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: CT1000MX500SSD1 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: E1EA0C68-DA59-406C-944A-089B812AD69D

Device          Start        End    Sectors   Size Type
/dev/sda1          40     409639     409600   200M EFI System
/dev/sda2      409640 1561962535 1561552896 744,6G Linux filesystem
/dev/sda3  1561964544 1757014015  195049472    93G Microsoft basic data
/dev/sda4  1757276160 1920016383  162740224  77,6G Linux filesystem
/dev/sda5  1920016384 1953523711   33507328    16G Linux swap

kali@kali:~$ sudo gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.5

Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): p
Disk /dev/sda: 1953525168 sectors, 931.5 GiB
Model: CT1000MX500SSD1 
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): E1EA0C68-DA59-406C-944A-089B812AD69D
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1953525134
Partitions will be aligned on 8-sector boundaries
Total free space is 265581 sectors (129.7 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI System Partition
   2          409640      1561962535   744.6 GiB   8300                                                                                                   
   3      1561964544      1757014015   93.0 GiB    0700                                                                                                   
   4      1757276160      1920016383   77.6 GiB    8300                                                                                                   
   5      1920016384      1953523711   16.0 GiB    8200   

enter image description here

Any ideas to on how to boot in MacOS without losing all my macOS data?

Was it helpful?

Solution

The answer below was developed based on your question and the image you posted. A cropped version of this image is posted below.

Enter the following from linux.

Note: I can tell you have taken steps that have not been posted to your question. Therefore, even if the procedure below repairs the partition tables, there may be damage to the APFS container from these steps that are unknown to me.

sudo gdisk /dev/sda
p
x
o
n
m
t
3
8300
n
5
409640
1561962535
AF0A
s
p
w
y

Explanation

Execute gdisk on the internal drive as root user.

sudo gdisk /dev/sda

Print out the GUID Partition Table (GPT) and the Master Boot Record (MBR) partition table.

p
x
o

Change the MBR partition table from hybrid to protective

n

Change the kali volume partition type from Microsoft to linux.

m
t
3
8300

Add back in the APFS partition.

n
5
409640
1561962535
AF0A

Sort the partitions in ascending order.

s

Print the resulting GPT.

p

Write the result back to the internal drive and exit gdisk.

w
y

OTHER TIPS

The second partition of the SSD (disk0s2/sda2) has the wrong GUID (0FC63DAF-8483-4772-8E79-3D69D8477DE4) which identifies it as a Linux native partition.

If you replace disk0s2/sda2 with a partition with the proper type (APFS) it should be a valid macOS boot partition again.

Changing the GUID while keeping the size and the start block won't alter the content of the partition if you don't repair the disk/volume!

In Recovery Mode enter in Terminal:

  1. Get the details (of the internal SSD):

    diskutil list
    gpt -r show disk0 #replace accordingly if the SSD has another device identifier
    
  2. Unmount disk0: diskutil umountDisk /dev/disk0
  3. Remove disk0s2:

    gpt remove -i 2 /dev/disk0
    diskutil umountDisk /dev/disk0
    
  4. Add the partition again with the proper GUID

    gpt add -i 2 -b 409640 -s 1561554904 -t 7C3457EF-0000-11AA-AA11-00306543ECAC /dev/disk0
    
  5. reboot

This (i.e. rebooting to macOS High Sierra) only works if you didn't reformat disk0s2/sda2 to some Linux file system (ext3, ext4, etc.) by accident previously.

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top