MacOS – Erased Windows partition with Disk Utility still can see the EFI boot on the boot screen

bootcampdisk-utilityefihigh sierramacos

This the setup I had

  1. iMac 21 inch
  2. HDD (500GB) for macOS installation
  3. SSD (256GB) for Windows 10 installation

This was working perfectly, until I upgraded to High sierra.

After upgrading to High Sierra, macOS stuck at the booting process and shows the spinning wheel all the time. Therefore I used the recovery mode and re-installed high sierra again but no luck. During that time I have erased the Windows 10 SSD via Disk Utility as well.

Then I used a Time Machine back up (2 years old) and reinstalled OS X El Captain. After three and half hour installation process, it booted and shows the white screen with the cursor. In safe mode it worked, but when I use normal mode it didn't. Then I followed these steps:

  1. Tried to reset the NVPRM, in the restart process Windows BSOD came
    up and displays the recovery options. In startup disk the boot volume was set to Macintosh HD.
  2. Then used the Internet recovery, opened the terminal and entered diskutil list. It shows disk0 as Windows partition, disk1 as
    Macintosh and disk2 as recovery partition.

But I can see partitions up to disk20 each having ~1 MB allocated space.

Checked diskutils cs list, it shows no CoreStorage logical volume groups found

Now I am running out of idea about how to recover the system.
I have created an image of the Macintosh HD before using Internet recovery therefore I'm not worrying data loss.

The image below was taken after I erased the Macintosh partition to install macOS again – I haven't installed it yet.

enter image description here

Best Answer

The drives shown as (disk image) are temporary drives stored in RAM. These drive will disappear when you leave Recovery mode.

Chasing Ghosts

You have successfully removed all windows partitions from your disks, but you have not yet removed all files added during your installation of Windows. What is left are files in your EFI partitions. The ghost is being caused by the file efi/boot/bootx64.efi stored in one of the EFI partitions.

  1. Open a Terminal window and enter the following command.

    sudo diskutil mount /dev/disk0s1
    
  2. From a Finder window, open the EFI disk. Next open the EFI folder. Remove any folders named Boot or Microsoft

  3. When finished, enter the command below.

    sudo diskutil unmount /dev/disk0s1
    
  4. Enter the following command.

    sudo diskutil mount /dev/disk1s1
    
  5. From a Finder window, open the EFI disk. Next open the EFI folder. Remove any folders named Boot or Microsoft

  6. When finished, enter the command below.

    sudo diskutil unmount /dev/disk1s1
    

If you booted to Recovery Mode or wish to just use a Terminal window, then enter the commands given below.

sudo  diskutil  mount  disk0s1
cd  /Volumes/EFI
rm  -fr  EFI/Windows
rm  -fr  EFI/Boot
cd  /
sudo  diskutil  unmount disk0s1
sudo  diskutil  mount  disk1s1
cd /Volumes/EFI
rm  -fr  EFI/Windows
rm  -fr  EFI/Boot
cd  /
sudo  diskutil  unmount  disk1s1