2

I have installed Windows 10 besides MacOS Big Sur using bootcamp on a Macbook retina 2015 with PCIe based SSD. wubiuefi failed to install Ubuntu 22.04 within the Windows partition and I wonder if there exists any straightforward and trusted method to shrink the BOOTCAMP partition (Windows) and install Ubuntu, without the need for any 3rd party boot manager, and if this can be riskful for further Ubuntu upgrades.

Here is the output of diskutil list:

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

/dev/disk1 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme - +220.0 GB disk1 Physical Store disk0s2 1: APFS Volume ⁨MacBook - Data⁩ 24.3 GB disk1s1 2: APFS Volume ⁨Preboot⁩ 333.0 MB disk1s2 3: APFS Volume ⁨Recovery⁩ 623.2 MB disk1s3 4: APFS Volume ⁨VM⁩ 1.1 GB disk1s4 5: APFS Volume ⁨MacBook⁩ 15.3 GB disk1s5 6: APFS Snapshot ⁨com.apple.os.update-...⁩ 15.3 GB disk1s5s1

  • Your BOOTCAMP volume may not have enough free space to shrink more than 2 GB. If you can not sufficiently shrink the BOOTCAMP volume, then reinstalling Windows may be necessary in order to install Ubuntu after Windows. – David Anderson Jun 29 '23 at 15:43
  • The BOOTCAMP shrink size limit problem was due to unmovable hibernation and paging files and now is resolved by temporarily disabling hibernation, system restore and virtual memory. – Mohammad Mahdi Amirian Jun 29 '23 at 20:56

1 Answers1

0

The Boot Camp Assistant will install Windows 10 to UEFI boot on a 2015 MacBook. This means the hybrid method of partitioning used with older Intel Macs is not employed. Therefore, you can boot to Windows and use the Disk Management (an extension of the Microsoft Management Console) to shrink the Windows partition and create free space for a Ubuntu install.

Note: The file I downloaded was named ubuntu-22.04.2-desktop-amd64.iso.

Below are the steps to install Ubuntu. These steps were adapted from the answer posted by guru431.

Note: The last three steps are optional.

The Ubuntu installer always chooses the first EFI partition on the drive regardless of what you choose. This is why step 4 changes the first efi partition to a ordinary FAT32 volume. The installer will then put the Ubuntu boot files in the new EFI partition created in step 6. The first partition is changed back to EFI in step 9, thus undoing step 4. A second EFI partition is added to avoid overwriting a Windows boot file stored in the first EFI partition.

  1. Go into Windows and use Disk Management to shrink its partition. The free space will be used by Ubuntu.

  2. Boot from Ubuntu install flash drive. From the GRUB menu, select Try or Install Ubuntu. If you wait 30 seconds, this will happen automatically.

  3. When the "Install" popup appears, select Try Ubuntu.

  4. Open the Terminal application and enter the following command to change the first partition type from EFI to FAT32.

    sudo sgdisk -t 1:0700 /dev/nvme0n1
    

    When finished, quit the Terminal application.

  5. Open the Install Ubuntu 22.04.2 LTS application and proceed with installing Ubuntu. During the installation, select the following when each appears.

    • Install third-party software for graphics and Wi-Fi hardware and additional media formats
    • Something else
  6. Select the largest amount of free space and create a new partition. Next, click on the + button, then select the following.

    • Size: 315 MB
    • Type for the new partition: Primary
    • Location for the new partition: Beginning of this space
    • Use as: EFI System Partition
  7. Again, select the largest amount of free space and create a new partition. Next, click on the + button, then select the following.

    • Size: Do not change this value.
    • Type for the new partition: Primary
    • Location for the new partition: Beginning of this space
    • Use as: Ext4 journaling file system
    • Mount point: /
  8. Install Ubuntu.

  9. After rebooting, open the Terminal application and enter the following command. This command changes the first partition type from FAT32 to EFI and removes any hybrid partitioning. (Actually, there should be not be any hybrid partitioning to remove. Therefore, most likely the -h EE option does not change anything.)

    sudo sgdisk -t 1:ef00 -h EE /dev/nvme0n1
    
  10. Boot into macOS.

  11. Goto the URL given below, then download and mount mac-icns.

    https://sourceforge.net/projects/mac-icns/
    
  12. Open the Terminal application and enter the following commands to assign an icon and label to Ubuntu:

    sudo diskutil mount disk0s4
    cp /Volumes/mac-icns/OSX10.11.6/os_ubuntu.icns /Volumes/EFI2/.VolumeIcon.icns
    bless --folder /Volumes/EFI2/EFI/BOOT --label "Ubuntu"
    diskutil unmount disk0s4
    

Note: During the installation of Ubuntu, the UUID of the FAT32 volume stored in the second EFI partition is recorded in the /etc/fstab file. This should cause Ubuntu to keep using the second EFI partition even through upgrades and any changes to the Grub configuration.

  • Thank you. Would you give me (as a newbie to EFI) the details of each step? Will bootcamp be responsible for booting into all three OSs at last? BTW, would be installing other linux distributions e.g. Fedora somehow easier than Ubuntu, without the need to these steps? – Mohammad Mahdi Amirian Jun 29 '23 at 02:04
  • Answers with more details have been posted before. For example, see the question How can I triple boot MacOS Catalina , Ubuntu 18.04, and Windows 10. Your Mac is a year newer and your macOS is the next released version. However, I believe the steps should be the same, especially since you may need to reinstall Windows. If you find a step that does not work, let me know. – David Anderson Jun 29 '23 at 20:25
  • Thank you, I had viewed several related posts before, including the above link, but I think my system configuration might be different and needs different instructions as 1) the shrink problem is resolved and no need to reinstall windows, 2) my Macbook 2015 has internal PCIe-based SSD for which the above link has forwarded to a 6-step Ubuntu installation without grub but besides rEFInd: (https://askubuntu.com/questions/1127375/install-ubuntu-18-04-on-mac-mini-2018). I prefer to give all the triple booting role to Apple's boot camp instead of hiring rEFind (if possible) – Mohammad Mahdi Amirian Jun 29 '23 at 21:20
  • Let me know if I'm doing fine with following steps: 1- Shrink BOOTCAMP. 2- Restart with Ubuntu installer USB stick. 3- Choose Try Ubuntu instead of Install Ubuntu. 4- Launch Ubuntu installer via terminal with the command ubiquity -b to ignore GRUB installation. 5- When asked for Installation type, choose Something else. 6- Choose the shrink partition and, with type Primary (not Logical), use it as Ext4 with mount point /. Now I have /dev/nvme0n1p3 ntfs followed by the chosen partition /dev/nvme0n1p4 ext4 7-Stopped risking here, should I clickInstall Now? – Mohammad Mahdi Amirian Jun 30 '23 at 02:37
  • I know my scenario is not following your 4-step guidance, because that's too abstract. Please correct mine via hints between the 7-step if the way is totally fine but needs correction, and also guide me with the rest of the steps to make boot camp realize Ubuntu as a third boot partition. – Mohammad Mahdi Amirian Jun 30 '23 at 03:35
  • Thank you for the detailed instructions. One more choice before installation is displayed: device for boot loader installation. Which one should I choose: /dev/nvme0n1(500GB)APPLE SSD , /dev/nvme0n1p1(314MB)fat32 , or /dev/nvme0n1p4(314MB)efi? – Mohammad Mahdi Amirian Jun 30 '23 at 18:17
  • My experience has been that this setting is ignored. The Ubuntu installer always chooses the first EFI partition on the drive regardless of what you choose. This is why step 4 changes the first efi partition to a ordinary FAT32 volume. The installer will then put the Ubuntu boot files in the new EFI partition created in step 6. The first partition is changed back to EFI in step 9, thus undoing step 4. – David Anderson Jun 30 '23 at 18:50
  • You should leave the "device for boot loader installation" as the default, which should be /dev/nvme0n1(500GB)APPLE SSD. – David Anderson Jun 30 '23 at 18:51
  • Great! Boot camp now supports triple boot. Beside your answer that explains WHAT I'm doing, I realized from your last comment WHY I'm doing that, the way you alternate boot partition backup and restore is tricky. I suggest you move that to the body of your answer. Adding a brief description of what boot camp does and how you make it realize Ubuntu would also be perfect to prevent other readers get confused. – Mohammad Mahdi Amirian Jun 30 '23 at 20:47
  • And please add to the final version of instructions, answer to this question: What should I do for any Ubuntu future upgrade? Should I change the first boot partition type temporarily to fat32 and revert back to efi? – Mohammad Mahdi Amirian Jun 30 '23 at 20:59
  • Any Ubuntu future upgrades should not require changing any partition types. I verified this by installing Ubuntu 20.04.6, then upgrading to Ubuntu 22.04.2 by following these instructions. The EFI partition used by Ubuntu did not change. – David Anderson Jul 01 '23 at 00:13
  • If you feel I answered your question, then you should accept my answer. This will put a green check mark next to my answer. Also, others will see an answer has been found to your question. – David Anderson Jul 08 '23 at 00:54
  • Hi @david_anderson , would you please suggest a secure way to remove the ubuntu partition installed in this way without loosing macos or windows? – Mohammad Mahdi Amirian Feb 19 '24 at 16:02
  • 1- Restart with Ubuntu installer USB stick. 2- Choose Try Ubuntu instead of Install Ubuntu. 3- Launch GPT fdisk via terminal with the command gdisk /dev/nvme0n1. 4- Choose the interactive functions to delete Linux partitions. 5- Write out your changes and exit gdisk. – David Anderson Feb 19 '24 at 16:50