If you removed a previous version of Windows or Ubuntu, then you may have files remaining in the EFI partition (disk0s1
). The commands given below will remove these files.
Use the Disk Utility application to erase a 16 GB or larger flash drive. Choose the ExFAT
format and the Master Boot Record
scheme.
Mount the Windows ISO file, the copy the files to the flash drive. The current Windows 10 ISO can be downloaded from the Microsoft website Download Windows 10 Disc Image (ISO File).
Copy the Windows Support Software designed for your Mac to the flash drive. The Windows Support Software can be downloaded by using the Boot Camp Assistant application. Select Action->Download Window Support Software
from menu bar.
Below is the contents of Windows installation flash drive as viewed in the Finder application. The AutoUnattend.xml
file and both the $WinPEDriver$
and BootCamp
folders came from the Windows Support Software downloaded from Apple for an iMac (21.5-inch, Late 2013). The remaining files and folders were from the Win10_1909_English_x64.iso
file downloaded from Microsoft.
Create free space to be used by Windows. In this example, 400 GB will be reserved for Windows on a 1.1 TB drive. Before allocating the free space, the output from the command diskutil list disk0
is shown below.
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.1 TB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_APFS Container disk1 1.1 TB disk0s2
To make 300 GB of free space available, the command shown below was used.
sudo diskutil apfs resizeContainer disk0s2 700G
The new output from the command diskutil list disk0
is shown below. Notice, the 300 GB block of free space created directly below disk0s2
is not shown.
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.1 TB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_APFS Container disk1 700.0 GB disk0s2
Restart the Mac and immediately hold down the option key until the Startup Manager icons appear. Choose the EFI Boot
label below the flash drive icon.
When the image below appears, press the shift+F10 key combination.
The Command Prompt window shown below should appear.
Enter the following command to create the Windows partitions. There commands are based on the instructions found at the Microsoft website UEFI/GPT-based hard drive partitions.
diskpart
select disk 0
create partition msr size=16
create partition primary
shrink desired=800
format quick fs=ntfs label=BOOTCAMP
assign letter=w
create partition primary id=de94bba4-06d1-4d40-a16a-bfd50179d6ac
format quick fs=ntfs label=Recovery
gpt attributes=0x8000000000000001
list partition
exit
The output from the list partition
command for this example is given below.
Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 System 200 MB 20 KB
Partition 2 Unknown 651 GB 200 MB
Partition 3 Reserved 16 MB 652 GB
Partition 4 Primary 371 GB 652 GB
* Partition 5 Recovery 800 MB 1023 GB
Enter the command exit
to close the Command Prompt window.
Proceed and finish the installation of Windows.
Note: If the Mac boots back to macOS before the installation of Windows completes, open the Startup Disk pane of the System Preferences application. After unlocking, highlight the icon labeled Windows and then click on the Restart
button. The installation of Windows should proceed.
If after Windows finishes installing, the Windows Support Software does not automatically starting installing, run the Setup
application in the BootCamp
folder on the flash drive.
Download the latest Ubuntu installation ISO file from the Ubuntu Home Page. The file download and used in this answer was named ubuntu-18.04.3-desktop-amd64.iso
.
Create free space to install Ubuntu. In this example, 300 GB of space will be reserved for Ubuntu. The output from diskutil list disk0
after install Windows is shown below.
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.1 TB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_APFS Container disk1 700.0 GB disk0s2
3: Microsoft Reserved 16.8 MB disk0s3
4: Microsoft Basic Data BOOTCAMP 398.4 GB disk0s4
5: Windows Recovery 838.9 MB disk0s5
Note: In this example, the EFI partition (disk0s1
) is 209.7 MB. Remember the size of the EFI partition on your drive. You will need this value in a later step.
The command given below will shrink the APFS by 300 GB.
Note: To be compatible with macOS, the entries in the Guid partition table (GPT) should occur in ascending order. To help insure this happens, dummy partitions need to be created when reserving the free space. Since the Ubuntu installer will be creating two new partitions, the command given below will create two dummy partitions.
sudo diskutil apfs resizeContainer disk0s2 400G exfat DUMMY1 200M exfat DUMMY2 200M
The dummy partition can arbitrary in size, since the partitions will be deleted later. The output from the command diskutil list disk0
, after entering the above command, is given below.
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.1 TB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_APFS Container disk2 400.0 GB disk0s2
3: Microsoft Basic Data DUMMY1 199.2 MB disk0s8
4: Microsoft Basic Data DUMMY2 199.2 MB disk0s9
5: Microsoft Reserved 16.8 MB disk0s3
6: Microsoft Basic Data 398.4 GB disk0s4
7: Windows Recovery 838.9 MB disk0s5
Use Etcher to create a bootable Ubuntu flash drive installer, then boot from this flash drive. A tutorial can be found at the Ubuntu website Create a bootable USB stick on macOS.
When the menu below appears, select Try Ubuntu without installing
.
When the Ubuntu desktop appears, press the control+option+T key combination to open a terminal window.
Temporarily rename the folders containing the Windows EFI boot files. This is done so certain files will not be overwritten when Ubuntu installs. Also, this will prevent Windows being added to the GRUB boot menu. Enter the following commands to rename the folders
sudo -i
mkdir efi
mount /dev/sda1 efi
mv efi/EFI efi/EFI.win
umount efi
rmdir efi
exit
Enter the command exit
to close the terminal window, then double click on the icon labeled Install Ubuntu 18.04.3 LTS
shown on the desktop. Proceed with install Ubuntu.
When the screen shown below appears, select "Install third-party software for graphics and Wi-Fi hardware and additional media formats", as shown below.
When the screen shown below appears, select "Something else", as shown below.
Delete the dummy partitions. Since the output from diskutil list disk0
showed the third and fourth partitions to be the dummies, the window below will identify these dummy partitions as devices /dev/sda3
and /dev/sda4
. Highlight device /dev/sda3
, then click on the -
button to delete. Repeat for the /dev/sda4
.
Highlight the 300 GB of free space, as shown below, then click on the +
button to add a new partition.
In the popup window, select a size and a use as of EFI System Partition
, as shown below. Here, 210
MB was used since the size of the original EFI partition was 209.7 MB. You should enter a value equal to the size of the original EFI partition on your drive rounded up to the nearest MB. Next, click on the OK
button.
Highlight the remaining free space, as shown below, then click on the +
button to add new partition.
In the popup window, select a mount point of /
, as shown below. Let use as default to Ext4 journaling file system
and do not change the size. Next, click on the OK
button.
Since all the new partitions have been created, click on the Install Now
button. When the screen show below appears, click on the Continue
button. Proceed and install Ubuntu.
When Ubuntu finishes installing, the Mac will need to be restarted. If asked to remove the installation medium, then do so. When the Mac restarts, immediately hold down the option key until the Startup Manager icons appears. Next, hold down the control key while selecting the EFI Boot
label under the internal drive icon. The Mac should boot Ubuntu.
From the Ubuntu desktop, press the control+option+T key combination to open a terminal window. Enter the following commands to move the Ubuntu EFI boot files to the new EFI partition and restore the Windows boot folder names.
sudo -i
mkdir efi
mount /dev/sda3 efi
mv /boot/efi/EFI efi
mv /boot/efi/EFI.win /boot/efi/EFI
umount efi
rmdir efi
Use the following command to label sda3
with EFI2
.
fatlabel /dev/sda3 EFI2
Use the following command to get the UUID value for the old (sda1
) and new (sda3
) partitions (to be used in the next step).
blkid /dev/sda1 /dev/sda3
From the output, the UUID value for sda1
and sda3
was determined to be 02E4-255E
and 2BCF-0C4E
, respectively. In your case, the UUID values themselves will be specific to your machine. The given UUID values are as an example and will likely be different in your case, as would be expected. The next step shows what to do with the UUID values.
Change the UUID in the /etc/fstab
file. Use the command nano /etc/fstab
or some other command to open the /etc/fstab
file in an editor. Replace the UUID for sda1
with the UUID for sda3
. For this example, this would mean to replacing 02E4-255E
with 2BCF-0C4E
. Save the change and close the editor.
Make sure the drive is not using hybrid partitioning. This can be accomplished by entering the command given below.
gdisk /dev/sda
This command is interactive. The interactive commands you will need to enter when prompted by gdisk
are given below.
x
n
w
y
Finally, enter the command exit
twice to close the terminal window. Restart the Mac.