How to Install Ubuntu on Mac with High Sierra and Legacy BIOS Booting Windows 10?
My 21.5-inch, Mid 2011 iMac has High Sierra (macOS 10.13.6) installed. A 64 bit version of Windows was originally installed using Boot Camp. Windows uses the legacy BIOS boot method. I have upgraded to the Windows 10 version 1803 (March 2018). I wish shrink my Widows 10 partition and use the free space to install Ubuntu.
What would be the procedure to do this?
Solution 1:
Steps Needed to Install Ubuntu after Installing macOS and Windows 10
Here I assumed the following.
- The macOS operating system was installed to a partition formatted
Mac OS Extended (Journaled).
- Boot Camp was used to install Windows 10.
- Windows 10 uses the legacy BIOS boot method.
- Windows 10 is version 1803 (i.e. March 2018).
- The Desktop Ubuntu version is 18.04.1 LTS.
- Ubuntu uses the EFI boot method.
- The file
ubuntu-18.04.1-desktop-amd64.iso
was used to install Ubuntu.
Note: If you are using
APFS
or Core Storage, then you will have to make the appropriate minor modifications to these instructions.
- Boot to Windows 10.
- Download and install
gdisk
. - Launch the Disk Manager.
-
Right click on the Windows boot partition and select
Shrink volume...
, as shown below. -
Enter the size needed for Ubuntu. In the example shown below, 100 GB was selected. After entering the amount, select the
Shrink
button. -
The result is shown below. You can exit the Disk Manager. Note: The Disk Manager has updated the Master Boot Record (MBR) partition table, but not the GUID Partition Table (GPT) used by macOS and Ubuntu. This error will be corrected in subsequent steps by using the
gdisk
command. -
Enter the following command in a Administrator Command Prompt window to execute
gdisk
on your primary internal drive.gdisk64 \\?\PhysicalDrive0
This will result is output similar to what is shown below.
GPT fdisk (gdisk) version 1.0.4 Partition table scan: MBR: hybrid BSD: not present APM: not present GPT: present Found valid GPT with hybrid MBR; using GPT. Command (? for help):
-
Enter the commands needed to copy the size of the Windows boot partition from the Master Boot Record (MBR) partition table to the GUID partition table (GPT). An example is shown below.
Enter the following commands to print out the Master Boot Record (MBR) partition table.
Command (? for help): r Recovery/transformation command (? for help): o Disk size is 1048576000 sectors (500.0 GiB) MBR disk identifier: 0x3C984A3E MBR partitions: Number Boot Start Sector End Sector Status Code 1 1 411647 primary 0xEE 2 411648 210126847 primary 0xAF 3 210126848 211458047 primary 0xAB 4 * 211458048 843775966 primary 0x07 Recovery/transformation command (? for help):
Note: You should record the information stored in this table. You will need this information to rebuild the MBR partition table after installing Ubuntu.
The
*
character shown above indicates partition 4 as the boot partition. The boot partition information needs to be copied to the GUID partition table (GPT). Note: your start and end values will be different from the values of 211458048 and 843775966 used in this example. Also, your boot partition number may be 3 instead of the value of 4 used in this example. Below is an example, where the copy is accomplished be deleting and creating a corrected partition 4.Recovery/transformation command (? for help): m Command (? for help): d Partition number (1-4): 4 Command (? for help): n Partition number (4-128, default 4): 4 First sector (34-1048575966, default = 211458048) or {+-}size{KMGTP}: 211458048 Last sector (211458048-1048575966, default = 1048575966) or {+-}size{KMGTP}: 843775966 Current type is 'Microsoft basic data' Hex code or GUID (L to show codes, Enter = 700): 700 Changed type of partition to 'Microsoft basic data' Command (? for help):
Print out the GPT to verify partition 4 has the correct values, as shown below.
Command (? for help): p Disk \\?\PhysicalDrive0: 1048576000 sectors, 500.0 GiB Sector size (logical): 512 bytes Disk identifier (GUID): A984BAF1-4F22-4E6C-9077-40FEEDF064DB 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 1048575966 Partitions will be aligned on 2048-sector boundaries Total free space is 204802014 sectors (97.7 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 411647 200.0 MiB EF00 EFI System 2 411648 210126847 100.0 GiB AF00 Apple HFS/HFS+ 3 210126848 211458047 650.0 MiB AB00 Recovery HD 4 211458048 843775966 301.5 GiB 0700 Microsoft basic data Command (? for help):
Write out the changes and quit, as shown below.
Command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to \\?\PhysicalDrive0. Disk synchronization succeeded! The computer should now use the new partition table. The operation has completed successfully.
You can now shutdown Windows 10 and install Ubuntu in the free space.
Adding Partitions for Ubuntu
Below are display snapshots illustrating the partitioning I chose while installing Ubuntu. Basically, I added a new partition for the Ubuntu files and allowed the EFI partition to be default for storing the GRUB boot files. These boot files a stored in a way compatible with the Mac Startup Manager.
-
When the following display occurs, select
Something else
, as shown below, then click on theContinue
button. -
Select
free space
, as shown below, then click on the+
button. -
Create swap space. For
Use as:
, selectswap area
. ForLocation for the new partition:
, selectEnd of this space
. A typical value for swap space is twice the amount of RAM memory installed. Since my Mac has 4 GiB of RAM, the "Size:" field should be8590
MB. The result is shown below. Next, click on theOK
button. -
Select
free space
, as shown below, then click on the+
button. -
For the
Mount point:
, select/
, as shown below, then click on theOK
button.Note: The
Size:
field should automatically default to all the available free space. -
The result is shown below.
Note: Since
End of this space
was selected in a previous step, the new partitions will not be created in ascending order. This will cause problems with macOS. In a later step, this problem will be corrected.Next, click on the
Install Now
button. -
Click on the
Continue
button shown below to allow the installation to proceed passed the partitioning phase.
Correcting Errors in the GPT and MBR Partition Table
When you installed Ubuntu, the MBR partition table was converted from hybrid to protective. This means most of the values in the MBR partition table were erased. This will prevent Windows from booting. Execute the following steps to correct this problem.
-
If you have not already done so, boot to Ubuntu and login. You should see a desktop similar to what is shown below.
Press the key combination controloptionT to open a Terminal application window. The result should similar to what is shown below.
-
Enter the following command to execute
gdisk
on your primary internal drive. You will be prompted for your login password.sudo gdisk /dev/sda
This will result in output similar to what is shown below.
GPT fdisk (gdisk) version 1.0.3 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help):
Start by checking to see if the partitions in the GUID Partition Table (GPT) are in ascending order. Enter the command below to print out the GPT.
Command (? for help): p Disk /dev/sda: 1048576000 sectors, 500.0 GiB Model: VBOX HARDDISK Sector size (logical/physical): 512/512 bytes Disk identifier (GUID): A984BAF1-4F22-4E6C-9077-40FEEDF064DB 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 1048575966 Partitions will be aligned on 2048-sector boundaries Total free space is 4062 sectors (2.0 MiB) Number Start (sector) End (sector) Size Code Name 1 2048 411647 200.0 MiB EF00 EFI System 2 411648 210126847 100.0 GiB AF00 Apple HFS/HFS+ 3 210126848 211458047 650.0 MiB AB00 Recovery HD 4 211458048 843775966 301.5 GiB 0700 Microsoft basic data 5 1031798784 1048573951 8.0 GiB 8200 6 843776000 1031798783 89.7 GiB 8300 Command (? for help):
Partition number 5 should occur after partition 6. Enter the commands given below to swap the values stored in the GPT for these two partitions.
Command (? for help): x Expert command (? for help): t Partition number (1-6): 5 New partition number (1-128, default 7): 6 Expert command (? for help):
Enter the command give below to confirm the partitions are now in ascending order.
Expert command (? for help): p Disk /dev/sda: 1048576000 sectors, 500.0 GiB Model: VBOX HARDDISK Sector size (logical/physical): 512/512 bytes Disk identifier (GUID): A984BAF1-4F22-4E6C-9077-40FEEDF064DB 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 1048575966 Partitions will be aligned on 2048-sector boundaries Total free space is 4062 sectors (2.0 MiB) Number Start (sector) End (sector) Size Code Name 1 2048 411647 200.0 MiB EF00 EFI System 2 411648 210126847 100.0 GiB AF00 Apple HFS/HFS+ 3 210126848 211458047 650.0 MiB AB00 Recovery HD 4 211458048 843775966 301.5 GiB 0700 Microsoft basic data 5 843776000 1031798783 89.7 GiB 8300 6 1031798784 1048573951 8.0 GiB 8200
Next, rebuild the MBR partition table. To do this, you will need the values your recorded earlier while booted to Windows. Enter the following.
Command (? for help): r Recovery/transformation command (? for help): h WARNING! Hybrid MBRs are flaky and dangerous! If you decide not to use one, just hit the Enter key at the below prompt and your MBR partition table will be untouched. Type from one to three GPT partition numbers, separated by spaces, to be added to the hybrid MBR, in sequence: 2 3 4 Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): y Creating entry for GPT partition #2 (MBR partition #2) Enter an MBR hex code (default AF): af Set the bootable flag? (Y/N): n Creating entry for GPT partition #3 (MBR partition #3) Enter an MBR hex code (default AB): ab Set the bootable flag? (Y/N): n Creating entry for GPT partition #4 (MBR partition #4) Enter an MBR hex code (default 07): 07 Set the bootable flag? (Y/N): y Recovery/transformation command (? for help):
If you are prompted with the question given below, enter
n
. Note: The more experienced individual may want to entery
, then enter83
when prompted for a MBR hex code.Unused partition space(s) found. Use one to protect more partitions? (Y/N):
Print out the MBR partition table to verify the partitions have the correct values, as shown below. The result should be the same as you recorded earlier.
Recovery/transformation command (? for help): o Disk size is 1048576000 sectors (500.0 GiB) MBR disk identifier: 0x3C984A3E MBR partitions: Number Boot Start Sector End Sector Status Code 1 1 411647 primary 0xEE 2 411648 210126847 primary 0xAF 3 210126848 211458047 primary 0xAB 4 * 211458048 843775966 primary 0x07 Recovery/transformation command (? for help):
Write out the changes and quit, as shown below.
Recovery/transformation command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/sda. Warning: The kernel is still using the old partition table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) The operation has completed successfully.
Quit the Terminal application.
Power off or restart Ubuntu.