MacOS – Windows stop in the purple screen after Ubuntu installation

efimacosunixwindows

I have an external hard drive where I installed Windows 10 to use on my MacBook when needed. It works great, I just need to toggle the boot disk.

But I had to install Linux. To do this I separated space from the HD and installed Linux through a pen drive. Now whenever I boot the computer with this HD it opens GRUB and asks me to select between UBUNTU and WINDOWS BOOT MANAGER.

Initializing the ubuntu is easy but when I try to boot Windows it gets stuck. I checked through Ubuntu and all Windows files are still there …

Some information i get when i type fdisk -l in ubuntu:

Disk /dev/sda: 113 GiB, 121332826112 bytes, 236978176 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: AF2EB9E1-8E5E-41A3-82B6-16DAF94B546A

Device      Start       End   Sectors   Size Type
/dev/sda1      40    409639    409600   200M EFI System
/dev/sda2  409640 236978135 236568496 112,8G unknown


Disk /dev/sdc: 298,1 GiB, 320072932352 bytes, 625142446 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 2BA05492-9337-401D-9BB9-33D96A7159A9

Device         Start       End   Sectors   Size Type
/dev/sdc1         40    409639    409600   200M EFI System
/dev/sdc2     411648 331016191 330604544 157,7G Microsoft basic data **<- WINDOWS!?**
/dev/sdc3  331016192 338829311   7813120   3,7G Linux swap
/dev/sdc4  338829312 625141759 286312448 136,5G Linux filesystem

Whats ived tried:

  1. sudo update-grub in ubuntu
  2. Boot repair in ubuntu, he said "Please disable SecureBoot in the BIOS. Then try again.Do you want to continue?"

My Macbook is the Air (13-inch, Early 2014) using macOS Mojave with 1,4 GHz Intel Cor and 4GB of ram.

what should I do to fix it?

Best Answer

So far this is not a answer. To fully answer, I would need more information. Below is an explanation of what went wrong.

Both Ubuntu and Window place boot software in the /EFI/Boot folder in the EFI partition (sdc1). Most notably is the bootx64.efi file.

When you installed Ubuntu, the Windows EFI\Boot\bootx64.efi file was replace with an Ubuntu version. There is a backup copy of the overwritten file stored under the file name EFI\Microsoft\Boot\bootmgfw.efi. So repairing the broken Windows is fairly easy. You could just copy a file. However, this type of the repair would also break Ubuntu.

A possible solution would be to clone the EFI partition. You could then make the above repair to the clone. This would allow both Windows and Ubuntu to appear in the Mac Startup Manager. Below is an example of how to do this. Here, both Windows and Ubuntu were installed on a single drive in a VirtualBox virtual machine. This was done to verify the commands are correct.

While booted to Ubuntu, temporarily make Windows bootable. The steps are given below.

  1. Open a Terminal windows. Enter the command below to become the root user.

    sudo bash
    
  2. Enter the command given below. This changes the folder to the EFI/Boot on the partition labeled EFI.

    cd /boot/efi/EFI/Boot
    
  3. Rename the Ubuntu file bootx64.efi to the temporary name bootx64u.efi.

    mv bootx64.efi bootx64u.efi
    
  4. Enter the command given below to copy the Windows file bootmgfw.efi to bootx64.efi.

    cp ../Microsoft/Boot/bootmgfw.efi bootx64.efi
    

    If you do not have a Microsoft folder, then you will need to reinstall the Windows boot files. See the Appendix end of this answer.

  5. Enter the exit command twice to close the window.

    exit
    exit
    

The output produced when I entered these commands is shown below.

dma@dma-VirtualBox:~$ sudo bash
[sudo] password for dma: 
root@dma-VirtualBox:/boot/efi/EFI# cd /boot/efi/EFI/Boot
root@dma-VirtualBox:/boot/efi/EFI/Boot# mv bootx64.efi bootx64u.efi
root@dma-VirtualBox:/boot/efi/EFI/Boot# cp ../Microsoft/Boot/bootmgfw.efi bootx64.efi
root@dma-VirtualBox:/boot/efi/EFI/Boot# exit
exit
dma@dma-VirtualBox:~$ exit

Next, reboot to Windows and clone the EFI partition. Cloning can not be accomplished while booted directly to Windows. Instead, you have to reboot to the Windows Recovery Environment (winRE) or from a Windows USB flash drive installer. The instructions for using the winRE are given at the Microsoft website Start your PC in safe mode in Windows 10.

Note: The website explains how to reach "Startup Settings". You need to select "Command Prompt" instead of "Startup Settings".

  1. Execute the diskpart command and list the available drives.

    diskpart
    list disk
    
  2. Select the correct disk. I selected disk 0. You will need to select the correct external drive from the drives listed.

    select disk 0
    
  3. List the partitions on the selected drive.

    list partition
    
  4. Windows should be partition 2. Enter the following commands to create a new 200 MB partition labeled EFI2 after the Windows partition.

    select part 2
    shrink desired=200
    create partition efi
    format fs=fat32 label=EFI2 quick
    list partition
    
  5. Assign the new partition the letter T: and the original EFI partition the letter S:.

    assign letter=t
    select partition 1
    assign letter=s
    
  6. Enter the exit command to exit the diskpart command.

    exit
    
  7. Copy all the files from the old partition to the new partition.

    xcopy s:\* t:\ /e /h /q
    
  8. Restore the Ubuntu bootx64.efi file.

    del s:\EFI\Boot\bootx64.efi
    ren s:\EFI\Boot\bootx64u.efi bootx64.efi
    
  9. Enter the exit command twice to close the window.

    exit
    

The output produced when I entered these commands is shown below.

Microsoft Windows [Version 10.0.17763.107]
(c) 2018 Microsoft Corporation. All rights reserved.

X:\windows\system32>diskpart

Microsoft DiskPart version 10.0.17763.1

Copyright (C) Microsoft Corporation.
On computer: MININT-PVCCLL9

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          300 GB      0 B        *

DISKPART> select disk 0

Disk 0 is now the selected disk.

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    System             200 MB  1024 KB
  Partition 2    Primary            153 GB   201 MB
  Partition 3    Unknown           3815 MB   153 GB
  Partition 4    Unknown            142 GB   157 GB

DISKPART> select part 2

Partition 2 is now the selected partition.

DISKPART> shrink desired=200

DiskPart successfully shrunk the volume by:  200 MB

DISKPART> create partition efi

DiskPart succeeded in creating the specified partition.

DISKPART> format fs=fat32 label=EFI2 quick

  100 percent completed

DiskPart successfully formatted the volume.

DISKPART> list partition
  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    System             200 MB  1024 KB
  Partition 2    Primary            153 GB   201 MB
* Partition 3    System             200 MB   153 GB
  Partition 4    Unknown           3815 MB   153 GB
  Partition 5    Unknown            142 GB   157 GB

DISKPART> assign letter=t

DiskPart successfully assigned the drive letter or mount point.

DISKPART> select partition 1

Partition 1 is now the selected partition.

DISKPART> assign letter=s

DiskPart successfully assigned the drive letter or mount point.

DISKPART> exit

Leaving DiskPart...

X:\Windows\System32>xcopy s:\* t:\ /e /h /q
146 File(s) copied

X:\Windows\System32>del s:\EFI\Boot\bootx64.efi

X:\Windows\System32>ren s:\EFI\Boot\bootx64u.efi bootx64.efi

X:\Windows\System32>exit

Note: When finish, you may find the Startup Manager's selections confusing. If so, consider adding a Windows and/or Ubuntu icon to the Startup Manager menu.

Appendix

How to reinstall the Windows EFI boot files.

  1. Use the Boot Camp Assistant to create a Windows 10 USB flash drive installer. If you have problems do this, then see the question Boot Camp Assistant fails to create the USB installer from the Windows 10 October 2018 Update.
  2. With the flash drive inserted in a USB port, start (or restart) the Mac and hold down the option key until the Startup Manager icons appears. Select to boot from the USB drive icon labeled "EFI Boot".
  3. When the initial Windows 10 installation windows appears, press then shift+F10 key combination to open a Command Prompt window.

  4. Execute the diskpart command and list the available drives.

    diskpart
    list disk
    
  5. Select the correct disk. I selected disk 0. You will need to select the correct external drive from the drives listed.

    select disk 0
    
  6. Enter the command below to determine the drive letter assign to the Windows partition. In this example, I will assume the drive letter is C:.

    list volume
    
  7. Assign the EFI partition the letter S:.

    select partition 1
    assign letter=s
    
  8. Enter the exit command to exit the diskpart command.

    exit
    
  9. Enter the following command to create the Windows EFI boot files. If you determined a different drive letter than C: in step 6, then make the appropriate substitution.

    bcdboot C:\Windows /s S: /f UEFI
    
  10. Enter the command below to close the Command Prompt Window.

    exit
    
  11. Click on the red X button and then select Yes button to restart the Mac.