This answer is not finished. Please do not edit!
This answer is based on the accepted answer to the question "Boot Camp Assistance is stuck on create a partition?". Modifications were made to include improvements suggested by user128216 to this answer.
Based on the lack of posted questions regarding using the Boot Camp Assistant to install Windows, I have assumed most users are successfully installing Windows on drives containing APFS partitions. When the Boot Camp Assistant fails, generally the problem is not with the Boot Camp Assistant, but rather with the APFS container. So, the usual solution is to backup your stuff, wipe the drive, and reload everything.
However, if you wish to install Windows without using the Boot Camp Assistant (except for creating the USB installation flash drive), you need to first determine how much space is available for Windows. This can be determined from the output of the command diskutil apfs resizecontainer diskXsY limits
, where X
is the drive number identifier and Y
is the partition number of the APFS container.
These are the basic steps needed to install Windows 10 for an EFI boot.
Note: To get a better view of the images shown below, either click on an image or open an image in a new window.
Use the Boot Camp Assistant application to copy the Windows 10 installation files and the Boot Camp Support Software to a 16 GB or larger flash drive. A USB 3.0 flash drive would operate considerably faster than a USB 2.0 flash drive.
The command below will create the 70 GB "BOOTCAMP" partition on your internal SSD drive. The space occupied by this partition will be used for installing Windows.
sudo diskutil apfs resizeContainer disk0s2 180.8G FAT32 BOOTCAMP 70G
If you have not already done so, insert the flash drive containing the Windows 10 installation files and the Boot Camp Support Software.
Use the command shown below to rename the AutoUnattend.xml
file.
mv /volumes/WINSTALL/AutoUnattend.xml /volumes/WINSTALL/NoAutoUnattend.xml
Next, you need to boot from the volume where the Windows installation files reside. Hold down the option key immediately after restarting on your Mac. Release the option when the Startup Manager window appears. Select the icon labeled "EFI boot". Next, select the arrow below the "EFI boot" label.
Open a Windows Command Prompt window, by following the procedure outlined in this step. Below is an image of what is initially displayed by the Windows 10 installer. Select "Next".
In the image shown below, select "Repair your computer".
In the image shown below, select "Troubleshoot".
In the image shown below, select "Command Prompt".
The result should be the image shown below.
Use the command diskpart
to finish partitioning disk0
. The commands you need to enter are given below.
Note: Sometimes it can take a while for the diskpart
command to produce the first prompt. Be patient.
diskpart
list volume
From the output of the command list volume
, determine the number for the volume with the label "BOOTCAMP". In this example, I will assume the number is 0
. Your number could be different. The next command selects this partition.
select volume 0
The next commands effect the "BOOTCAMP" volume. The format is changed to NTFS. Next, the size is shrunk by 600 MB.
format fs=ntfs label=BOOTCAMP quick
shrink desired=600
Create a Windows Recovery Environment (WinRE) partition. The next commands create and initialize an empty 600 MB WinRE.
create partition primary
set id=de94bba4-06d1-4d40-a16a-bfd50179d6ac
gpt attributes=0x8000000000000001
format fs=ntfs label=Recovery quick
The next command lists the current volumes. Take note of the drive letter (Ltr) for the volume with label "WINSTALL". In this example, I will assume the letter is D
. Your letter could be different.
list volume
The command below quits the command diskpart
.
exit
Enter the command below to start the Windows installation. If the drive letter, for the "WINSTALL" volume, is not D
, then make the appropriate substitute when entering the command below.
setup /unattend:D:\NoAutoUnattend.xml
When a window similar to what is shown below appears, select the "BOOTCAMP" partition, then click on the "Next" button.
Continue with the installation of Windows 10. If the computer boots back to macOS, goto System Preferences and select Windows as your startup disk. Restart the computer to continue initializing Windows 10.
When finished, the Windows Support Software installer should automatically launch. If this does not occur, use the Windows File Explorer to open the Windows Support Software application named "Setup". This application can be found in the "BootCamp" folder on the "WINSTALL" drive. After the installer application completes, allow the computer to restart.
If asked, I can clarify any of the above steps.
Yes, it possible to have multiple macOS installations inside a single container with multiple virtual partitions, but some of the partitions will be shared.
Note: I do not think virtual partitions is the correct terminology. I believe the terminology should be APFS volumes sharing the same APFS partition.
I started with High Sierra installed to volume labeled Macintosh HD
in a APFS container. I using the Disk Utility application to add a new APFS volume labeled Macintosh HD 2
. Next, I downloaded High Sierra from the App Store and installed to the Macintosh HD 2
volume. The result from diskutil list
is shown below.
Note: I used a external drive, so disk2
appears below instead of the expected disk1
.
/dev/disk2 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +200.0 GB disk2
Physical Store disk1s6
1: APFS Volume Macintosh HD 50.8 GB disk2s1
2: APFS Volume Preboot 46.1 MB disk2s2
3: APFS Volume My Recovery 1.0 GB disk2s3
4: APFS Volume VM 8.6 GB disk2s4
5: APFS Volume Machintosh HD 2 18.2 GB disk2s5
While both High Sierra installations use different root volumes (disk2s1 and disk2s5), the installations share disk2s2
, disk2s3
and disk2s4
.
Next, I created another APFS volume labeled Mojava 1
and then downloaded Mojava Beta from this Apple website. The result after installing is shown below.
/dev/disk2 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +200.0 GB disk2
Physical Store disk1s6
1: APFS Volume Macintosh HD 50.8 GB disk2s1
2: APFS Volume Preboot 74.5 MB disk2s2
3: APFS Volume My Recovery 1.5 GB disk2s3
4: APFS Volume VM 8.6 GB disk2s4
5: APFS Volume Machintosh HD 2 18.1 GB disk2s5
6: APFS Volume Mojava 1 35.8 GB disk2s6
Mojava installed to disk2s6
and shares share disk2s2
, disk2s3
and disk2s4
with the other two High Sierra installations.
So there is now three macOS Recoveries for both High Sierra and Mojava. In my case, both High Sierra macOS Recoveries are Version 1.0 (327) and the Mojava macOS Recovery is Version 1.0 (330).
I can boot to one of the three macOS Recoveries stored on disk2s3
by holding down the ⌘+R key combination at startup. If the default startup disk is a APFS volume containing macOS, then the corresponding macOS recovery will startup. For example, if the startup disk is set to the APFS volume Machintosh HD 2
, then holding down the ⌘+R key combination at startup will result in the Mac booting to High Sierra macOS Recovery on APFS Volume My Recovery
.
Note: macOS Recovery no longer appears in the Mac Startup Manager. However, macOS Recovery, for a given macOS installation, can be booted using the rEFInd Boot Manager.
BTW: Removing Mojave from the APFS container is covering in my answer to the question: Erase an APFS volume?
Best Answer
When Mojave is installed, you need to choose a APFS volume. However, the operating system is not just installed to this volume. Additionally, three other hidden APFS volumes (Preboot, Recovery and VM) are created, if they do not already exist. The preboot files are placed in a folder in the Preboot APFS volume and the recovery files are place in a folder in the Recovery APFS volume. In both cases, the name of the folder is the same as the UUID assigned to the APFS volume you chose when installing Mojave. The VM volume is used to store the sleep image and the swap file.
If you create a new APFS volume and install Mojave to this volume, then the three hidden volumes are reused. Again the preboot and recovery files are placed in a folders with a name the same as the UUID of the new APFS volume.
If you delete a APFS volume that was chosen for a Mojave installation, only this volume is removed. The three hidden volumes remain and still contain and the same files. To remove the folders containing the preboot and recovery files, you have to manually mount the volumes and remove the folders. (For example, use the
diskutil mount
command to manually mount each volume.) Since the space taken up by these folders and their contents is fairly small, most users will probably elect to just leave the folders intact on these hidden volumes.What I wrote above also applies to High Sierra when installing to a APFS volume.