1

I have a fairly old macbook (2016) with a 256Gb hard drive running Catalina 10.15.7 on which I've set up Bootcamp splitting the disk roughly in half at the time.

Recently, I've decided to upgrade to BigSur and found out that I'm out of disk space to do so, the update says that about 25Gb is needed and since I had enough space on Bootcamp for my needs I've partitioned its size to be less, sure enough running into jinxing my APFS partition which is happily answered here on this helpful website :)

That freed up about 35Gb space on the disk, enough for my update, but I now cannot find a way to merge it with the original MacOS container:

SSDpartition

I would like to keep both Bootcamp and the existing MacOS intact, just add the free space to the existing 'Macintosh HD' as on the picture above and then proceed with my system upgrade. After browsing some further helpful answers here and here I now realize that this might just be harder than it looks because I don't have free space to clone any of the 2 partitions I want to keep if I go that way, and the sudo diskutil apfs resizeContainer disk0s3 0 does not work for me since the Free Space precedes the MacOS container (there is also a FAT32 container likely related to Bootcamp right at the beginning of the disk) and returns the following error:

Error: -69519: The target disk is too small for this operation, or a gap is required in your partition map which is missing or too small, which is often caused by an attempt to grow a partition beyond the beginning of another partition or beyond the end of partition map usable space

Free Space is disk0s2 then followed by the MacOS space disk0s3 and finally the Bootcamp space disk0s4 and all together it looks like one big ugly this:

DiskOverall DiskStructure

So is it even possible? Will I have to use an external hard drive to clone any of the 2 existing systems out, format, and then clone them back in? Or is there an easier way with some helpful diskutil or gpt commands that I'm not aware of?

Update 1

Output of diskutil list internal before reclaiming disk space:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                  Apple_HFS                         36.7 GB    disk0s2
   3:                 Apple_APFS Container disk2         111.0 GB   disk0s3
   4:       Microsoft Basic Data BOOTCAMP                102.3 GB   disk0s4
   5:           Windows Recovery                         513.8 MB   disk0s5

/dev/disk1 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme - +36.8 GB disk1 Physical Store disk0s2

/dev/disk2 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme - +111.0 GB disk2 Physical Store disk0s3 1: APFS Volume Macintosh HD - Data 86.9 GB disk2s1 2: APFS Volume Preboot 81.6 MB disk2s2 3: APFS Volume Recovery 529.0 MB disk2s3 4: APFS Volume VM 1.1 GB disk2s4 5: APFS Volume Macintosh HD 11.3 GB disk2s5

Update 2

After performing all the actions as recommended by David Anderson in the comment section below (use Gparted to move the partitions, then attempt to repair boot with the help of a created-on-mac usb stick image of Windows), I now realized that I've messed up on the move & resize part.

Currently, after successfully reclaiming the free space, the output of diskutil list disk0 is as follows:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI ⁨EFI⁩                     314.6 MB   disk0s1
   2:                 Apple_APFS ⁨Container disk1⁩         125.2 GB   disk0s2
   3:       Microsoft Basic Data ⁨BOOTCAMP⁩                125.0 GB   disk0s3
   4:           Windows Recovery ⁨⁩  

However, since I resized the Windows partition manually after moving the Apple container, the return from gdisk64.exe on the Windows bootable USB stick is the following:

X:\sources>c:\gdisk64.exe 0:
GPT fdisk (gdisk) version 1.0.8

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


Found invalid GPT and valid MBR; converting MBR to GPT format in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if you don't want to convert your MBR partitions to GPT format!


Warning! Secondary partition table overlaps the last partition by 33 blocks! You will need to delete this partition or resize it in another utility.


Most versions of Windows cannot boot from a GPT disk except on a UEFI-based computer, and most varieties prior to Vista cannot read GPT disks. Therefore, you should exit now unless you understand the implications of converting MBR to GPT or creating a new GPT disk layout!


Are you SURE you want to continue? (Y/N): y

Command (? for help): x

Expert command (? for help): p Disk 0:: 61046784 sectors, 29.1 GiB Sector size (logical): 512 bytes Disk identifier (GUID): 6994BC7D-0979-475B-942C-E6A107C02C86 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 61046750 Partitions will be aligned on 2048-sector boundaries Total free space is 2014 sectors (1007.0 KiB)

Number Start (sector) End (sector) Size Code Name 1 2048 61046783 29.1 GiB 0700 Microsoft basic data

Expert command (? for help):

  • Can you add to your question the results in text mode of the terminal command : diskutil list internal? –  Dec 05 '21 at 07:16
  • Added to the bottom of the question, I must admit it does paint a different view on the structure, but Bootcamp was still put in first it appears. – Anian Aksun Dec 05 '21 at 08:32

1 Answers1

0

A question similar yours was posted and answered after you posted this question. The difference is the other question has the free space occurring after the Windows partition. Your free space exists before the APFS partition containing macOS. (Actually, your question has some ambiguity in that the free space is also shown as a HFS partition containing an empty APFS container.)

I posted an answer to the other question which involved using GParted to move a partition. In testing, I was able to verify GParted can also move APFS partitions. So you could move the APFS partition to be before the free space, then enter a command (similar to the command given in your question and my other answer) to add the free space to this partition.

However, you would wish to pursue temporarily cloning to an external drive as a solution (as some would insist is the only possible answer), then post a message. I should first warn that I have no experience with Carbon Copy Cloner. I would try instead to use tools included with macOS.

How to Use macOS to Create a Bootable USB Stick Windows 10 Installer.

  1. Use the Disk Utility to erase a USB stick. Choose an appropriate name. Select the ExFAT format and Master Boot Record scheme.

  2. Use the Finder to mount the Windows 10 ISO file.

  3. Use the Finder to copy the contents of the Windows 10 ISO file to the USB stick.

  4. Use the Boot Camp Assistant to download the Window Support Software.

  5. Copy the Windows Support Software to the USB stick.

  6. Examine the contents of the USB stick. Below is the result for a 2018 Mac mini when the Win10_21H2_English_x64.iso file from Microsoft was used.

    Note: If you see a file named AutoUnattend.xml, then rename this file to the name NoAutoUnattend.xml

How to Use macOS add GPT fdisk to a Bootable USB Stick Windows 10 Installer.

  1. Open Safari. If the Develop menu does not appear on the menu bar, choose SafariPreferences… from the menu bar, click the Advanced tab in the popup, then select Show Develop menu in menu bar. When finished, close the popup.
  2. Goto the GPT fdisk project homepage. From the menu bar, select DevelopUser AgentFirefox — Windows. Next, select the green Download button on the GPT fdisk project homepage. The default action is to download the latest version of GPT fdisk for Windows to your Downloads folder, then unzip to a folder. When the download completes, close the Safari window.
  3. Copy gdisk64.exe Microsoft Windows application from the folder created during the download to the root directory of the Bootable USB Stick Windows 10 Installer.

How to Load the Drivers Before Using a Bootable USB Stick Windows 10 Installer to Repair Your Computer

  1. Boot from the USB Stick Windows 10 Installer.

  2. When the window shown below appears, make the appropriate selections, then select the Next button.

  3. When the window shown below appears, select Install now and proceed as if you wanted to install Windows.

  4. When the window shown below appears, just select the red box with the "X" character.

    When the popup shown below appears, select the Yes button.

  5. When the window shown below appears, select the Repair your computer button.

How to Open the Mac Internal Drive in GPT fdisk Using a Bootable USB Stick Windows 10 Installer

  1. Follow the steps given in the section titled "How to Load the Drivers Before Using a Bootable USB Stick Windows 10 Installer to Repair Your Computer."

  2. Open a Command Prompt window.

  3. Use the output from the command below to get the drive letter assigned to the Bootable USB Stick Windows 10 Installer.

    echo list volume | diskpart
    
  4. Use the output from the command below to get the number assigned to the internal drive.

    echo list disk | diskpart
    
  5. Enter the command below to execute GPT fdisk. If you determined a different drive letter and/or disk number, then make the appropriate substitutions.

    c:\gdisk64 0:
    

How to Use GPT fdisk to Turn Off Hybrid Partitioning.

If you are UEFI booting Windows, then you want a fully protective MBR.

The entries to gdisk64 are given below. Enter in the order shown in the first column.

Entries Comments
x Enter the experts' menu
p Display basic GPT partition summary
n Create a new protective MBR
o Display protective MBR data
w Write MBR to disk and exit
y Confirm to write and exit

How to Use GPT fdisk to Turn On Hybrid Partitioning.

If you are legacy BIOS booting Windows, then you want to use hybrid partitioning.

I assume your output from the command diskutil list disk0 would be similar to what is shown below. If your output does not match the values shown in any column except the SIZE column, then you should update your question and post a comment before proceeding.

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         147.7 GB   disk0s2
   3:       Microsoft Basic Data BOOTCAMP                102.3 GB   disk0s3
   4:           Windows Recovery                         513.8 MB   disk0s4

The entries to gdisk64 are given below. Enter in the order shown in the first column.

Entries Comments
r Enter recovery and transformation menu
p Display basic GPT partition summary
h Make hybrid MBR
2 3 4 Partitions from GPT to add to the MBR
y Confirm placing EFI GPT (0xEE) partition first in MBR
ff Hex code for second partition in MBR
n Reject setting the bootable flag
07 Hex code for third partition in MBR†
y Confirm setting the bootable flag
27 Hex code for forth partition in MBR†
n Reject setting the bootable flag
o Display protective MBR data
w Write MBR to disk and exit
y Confirm to write and exit

†This should be the default value.

  • Thank you David, gparted worked for me once I figured out how to move the partitions relative to the free space, I have now reclaimed the free space and updatec my MacOS, however the Windows on bootcamp stopped booting possibly because it was moved around and I can't help it with bootrec command because the recovery software loaded into RAM can't see any of the physical disks for some reason, DISKPART's LIST DISK returns no disks. I can still access the bootcamp partition from within MacOS and copy files from it - it's there - just the boot that is jinxed now. – Anian Aksun Dec 11 '21 at 08:43
  • Did Windows boot before using gparted? If Windows did boot before using gparted, then did you use gparted to move or resize the Windows partition? My answer stated you should just move the APFS partition. – David Anderson Dec 11 '21 at 09:06
  • How are you booting to the recovery software? Which options where you planning to use with bootrec. I ask because /FixMbr and /FixBoot are for a BIOS booting Windows and your Mac does not have a BIOS. Your Mac UEFI boots Windows. – David Anderson Dec 11 '21 at 09:36
  • Windows booted before i used gparted, it did prompt me that boot may fail after moving, and it did - i moved the windows partition by resizing it slightly. To load the recovery media I use a USB stick with a system image. – Anian Aksun Dec 11 '21 at 10:10
  • Did you copy the Windows Support Software to the flash drive? Did you press the shift+F10 key combination when you reach the window asking for the product key? – David Anderson Dec 11 '21 at 11:01
  • No I didn't copy it I created the disk using the Microsoft Bootable Media Creator for Windows. I can't press any key combinations at all because as soon as I pick the bootcamp option on the boot screen it immediately goes black and the system unresponsive - only option after that is to cut the power. – Anian Aksun Dec 11 '21 at 14:27
  • I edited my answer and included instructions for how to create the USB stick and then how to boot from the USB stick. See if diskpart shows your internal drive. – David Anderson Dec 11 '21 at 20:36
  • Thanks for the extended instructions! I have successfully created a Windows boot disk as described therein and now DISKPART sees the AppleSSD, but it does not, however, see any of the partitions present there: just two strange volumes - one is 14Gb and the other 61Mb. Naturally, all of the 'bootrec' commands fail to do anything because it seems the boot sector of the disk is still not visible. – Anian Aksun Dec 12 '21 at 07:26
  • While running diskpart, enter the command list disk. In the output, there will be a column labeled Gpt. Does the AppleSSD have a * character in this column? – David Anderson Dec 12 '21 at 17:36
  • When you enter the bootrec command, which options are you using? – David Anderson Dec 12 '21 at 17:42
  • No it does not have a * under GPT. I tried using /fixmbr, /fixboot and /rebuildbcd - they all seem to have nothing to target, however. – Anian Aksun Dec 13 '21 at 02:05
  • Your internal drive is incorrectly hybrid partitioned. You can use gdisk64.exe to fix this. I believe your 2016 Mac does not have a BIOS and therefore should not be hybrid partitioned. Since I have never had access to your Mac model, I could be wrong. I updated my answer to include how to add and execute gdisk64.exe from your USB stick. I also, added to my answer instructions for turning on and off hybrid partitioning. – David Anderson Dec 13 '21 at 06:18
  • My Mac model info can be found here. The output of the diskutil list disk0 command is exactly as described in your answer section How to Use GPT fdisk to Turn On Hybrid Partitioning. When I try to run gdisk64.exe i get the following error: Problem opening \\. \physicaldrive for reading! - I have checked that the usb stick is indeed c: – Anian Aksun Dec 15 '21 at 00:58
  • The only way I can replicate the message you received from gdisk64.exe is to enter the command c:\gdisk :. In other words, I have to omit the number assigned to the internal drive. – David Anderson Dec 16 '21 at 07:14
  • Thanks again for your input and time! I don't really know what went wrong the first time, but after trying again the original command worked and I was able to start gdisk64. Just as you said, my faulty actions of moving the Windows partition itself resulted in it becoming overwritten in some way, as the output says - I have edited the original question. Section Update 2 now has the output of gdisk64 - I tried to take peek after the warning message but all it can see is the USB stick and not the MBR. So now I am wondering how to proceed - turn hybrid partitioning on or off as you described? – Anian Aksun Dec 16 '21 at 19:56
  • Based on your update, I assume c:\gdisk64 0: read the MBR partition table from the 32 GB USB stick. If so, then I would assume c:\gdisk64 1: would read the MBR partition table and the GUID partition table (GPT) from the internal drive. – David Anderson Dec 16 '21 at 20:39
  • Actually, I was typing :0 instead of 0: and that was the reason - I'm a whole lot of dumdum, It appears :D After doing it the right way 1: and then writing a protective MBR as described in How to Use GPT fdisk to Turn Off Hybrid Partitioning my laptop instantly booted into Windows, so now there is no free space, both OS's are working fine and no data was lost in the process. HUGE thanks from me to you, David Anderson, for literally babysitting me through this :) And to this website as well - I hope It's not too much of a duplicate and helps someone in the future. This is now fully resolved. – Anian Aksun Dec 17 '21 at 00:11