I have seen that most of the time the answer to the questions "How can I merge the primary APFS partition with another empty APFS partition?"Or"How do we delete the BOOTCAMP partition and add the volume of an existing APFS container?”Is the total reinstallation of macOS with HDD formatting.
Well, there are other, simpler solutions that do not require a system reset that could take several hours with custom applications and settings.
If you have used it Boot Camp Assistant to install a parallel operating system (Windows7, Windows 10, etc.), on macA new OS called BOOTCAMP has appeared. This partition usually keeps the operating system parallel, it being created during the installation process from the space of the primary partition. Master. If you want to give up the parallel operating system installed on Mac, MacBook and you want the space occupied by the "BOOTCAMP" partition to be deleted and added to the partition macOS, then you have to follow a simple tutorial that will take much less time than it does reinstall the entire operating system macOS.
How to delete a parity and how to add free space to an APFS partition - Resize APFS Container
In our scenario we have to deal with a hard of 250 GB divided into a partition (container) APFS the main 199 GB (Apple_APFS Container disk1 - disk0s2) and one that we had BOOTCAMP by 50.7 GB (Apple_HFS Untitled - disk0s3) to be deleted and its 50.7 GB space added to the main partition. At the end we will get one 250GB partition.
1. We delete the disk0s3 volume without formatting it. In this way we will get one free space on the disk that we can later add to disk0s2.
sudo diskutil eraseVolume "Free Space" %noformat% /dev/disk0s3
2. We give the main APFS partition space left on the disk after the above operation.
diskutil apfs resizeContainer disk0s2 0
In the end we will get a single partition "macOS ”/ disk0s2 by 250 GB.
If you have multiple partitions you need to be very careful what you delete. Correctly identify the name of the partition you want to delete, then execute the command line. To view all available partitions and volumes, run in Port command: disktil list.
This tutorial is done on a beta version of a macOS Mojave, but it is compatible macOS High Sierra.Merge APFS Containers in single partition / macOS High Sierra or Mojave