1

My MacBook has three OSs at the same time: macOS, Boot Camp Windows 10, and Ubuntu. It will display Windows, Macintosh HD, and EFI Boot (going to Ubuntu) when pressing the option when booting. I split the disk size as follows:

macOS: 85 GB
Windows: 120 GB
Ubuntu: 40 GB
total: 256 GB

sh-3.2# diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk2         85.0 GB    disk0s2
   3:       Microsoft Basic Data BOOTCAMP                125.8 GB   disk0s3 
sh-3.2# gpt -vv -r show /dev/disk0
gpt show: /dev/disk0: mediasize=251000193024; sectorsize=512; blocks=490234752
gpt show: /dev/disk0: PMBR at sector 0
gpt show: /dev/disk0: Pri GPT at sector 1
gpt show: /dev/disk0: Sec GPT at sector 490234751
      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  166018024      2  GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
  166427664   78124016         
  244551680  245682176      3  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
  490233856        863         
  490234719         32         Sec GPT table
  490234751          1         Sec GPT header

1 Answer 1

1
  1. Boot to macOS Catalina and enter the following commands.

    diskutil apfs resizecontainer disk0s2 0
    sudo diskutil mount disk0s1
    cd /Volumes/EFI/EFI
    rm -r BOOT
    rm -r ubuntu
    cd ~
    diskutil unmount disk0s1
    
  2. Open a Command Prompt window by following steps 1 through 3 given as an update in this answer.

  3. Enter the command given below.

    diskpart
    

    The command is interactive. You should input the following.

    select volume c:
    set id=7
    extend filesystem
    active
    exit
    
  4. Rebuild the BCD by following steps 4 and 5 given as an update in this answer.


Steps to Uninstall Ubuntu

These steps assume the Mac was setup the same as before you first uninstalled Ubuntu.

  1. Boot to Windows.

  2. Download the GPT fdisk project from sourceforge.net. Extract the files to the default location.

  3. Open a Command Prompt window as an administrator.

  4. Enter the command given below. If the GPT fdisk version is not 1.0.9, then make the appropriate substitutions.

    %userprofile%\gdisk-windows-1.0.9\gdisk64 0:
    

    This command is interactive. Enter the values given in the first column of the following table.

    Entry Type Comment
    s command Sort partitions
    p command Print the partition table
    d command Delete a partition
    3 parameter Partition number
    w command Write table to disk and exit
    y parameter Confirm to proceed
  5. Boot to macOS Catalina and enter the following commands.

    diskutil apfs resizecontainer disk0s2 0
    sudo diskutil mount disk0s1
    cd /Volumes/EFI/EFI
    rm -r BOOT
    rm -r ubuntu
    cd ~
    diskutil unmount disk0s1
    
  6. Boot to Windows.

  7. Change the partition type for drive C: to 7. Two different ways to accomplish this are given below. The first way requires a full functioning Windows Recovery Environment (Windows RE). If your Windows RE is damaged or improperly configured, then choose the second way.

    • The First Way: Click Start > Settings > Update & Security > Recovery > under "Advanced startup", click Restart now.

      When the "Choose an option" menu appears, Click Troubleshoot > Advanced options > Command Prompt. If Command Prompt is missing, then your Windows RE is damaged or improperly configured. Sign in to get a Command Prompt window.

      Enter the command given below.

      diskpart
      

      The command is interactive. You should input the following.

      select volume c:
      set id=7
      exit
      

      Enter the command below to close the Command Prompt window.

      exit
      

      When the "Choose an option" menu appears, Click Continue.

    • The Second Way: Open a Command Prompt window as an administrator. Enter the command given below. If the GPT fdisk version is not 1.0.9, then make the appropriate substitutions.

      %userprofile%\gdisk-windows-1.0.9\gdisk64 0:
      

      This command is interactive. Enter the values given in the first column of the following table.

      Entry Type Comment
      r command Switch to recovery and transformations options menu
      o command Print protective MBR data
      h command Make hybrid MBR
      2 3 parameter Partition numbers to be added to the hybrid MBR, in sequence
      y parameter Place EFI GPT (0xEE) partition first in MBR (good for GRUB)?
      ff parameter MBR hex code for the second MBR partition
      n parameter Set the boot flag?
      7 parameter MBR hex code for the third MBR partition
      y parameter Set the boot flag?
      n parameter Use remaining partition space to protect more partitions?
      o command Print protective MBR data
      w command Write table to disk and exit
      y parameter Confirm to proceed

References

2
  • learned a lot, thank you very mush!
    – whaleboss
    Nov 22, 2023 at 2:42
  • If I reinstall ubuntu, can I still use these command to remove it?
    – whaleboss
    Nov 22, 2023 at 10:21

You must log in to answer this question.

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