2

This is continuation from my previous question "I removed the rEFInd and rEFIt boot managers and now I've lost Windows Bootcamp from the Mac Startup Manager", where I now can boot Windows from the Mac Startup Manager.

I heard some people had success with installing Ubuntu and using grub on a Mac. The problem is, I ignored the vast majority of people who said it caused issues, and didn't install rEFInd first.

Now when I boot the computer, I get the grub boot menu, with options for Xubuntu and Windows bootloader. Xubuntu obviously works, Windows doesn't (I just get a black screen and have to hold the power button to shutdown). I can access the Mac side by pressing escape on grub and typing exit.

I wanted to test if some software would run better on Linux; it doesn't, so I'm happy to remove the linux partition and go back to how it was with Mac and Windows.

I just wanted to check if it's ok to remove the Linux partition from the Mac side. The linux partition is where I installed both Xubuntu and the grub bootloader. Will this return everything back to normal, Windows also?

I'm using a 2019 iMac running MacOS 11.6.1.

EDIT (added details):

My output for diskutil is

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI ⁨EFI⁩                     209.7 MB   disk0s1
   2:                 Apple_APFS ⁨Container disk2⁩         843.0 GB   disk0s2
   3:       Microsoft Basic Data ⁨⁩                        35.0 GB    disk0s3
   4:       Microsoft Basic Data ⁨BOOTCAMP⁩                122.0 GB   disk0s4

/dev/disk1 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *28.0 GB    disk1
   1:                        EFI ⁨EFI⁩                     314.6 MB   disk1s1
   2:                 Apple_APFS ⁨Container disk2⁩         27.6 GB    disk1s2

/dev/disk2 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +870.5 GB   disk2
                                 Physical Stores disk1s2, disk0s2
   1:                APFS Volume ⁨Macintosh HD⁩            20.3 GB    disk2s1
   2:              APFS Snapshot ⁨com.apple.os.update-...⁩ 20.3 GB    disk2s1s1
   3:                APFS Volume ⁨Macintosh HD - Data⁩     708.5 GB   disk2s2
   4:                APFS Volume ⁨Preboot⁩                 397.5 MB   disk2s3
   5:                APFS Volume ⁨Recovery⁩                626.4 MB   disk2s4
   6:                APFS Volume ⁨VM⁩                      2.1 GB     disk2s5

When I run sudo mkdir /Volumes/efi and sudo mount -t msdos /dev/disk1s1 /Volumes/efi

The EFI folder has BOOT and ubuntu folders inside.

I imagine the Windows boot files are gone? That's not a problem, I have a Windows 10 ISO and know how to replace them. My issue is that I want to know I'm not going to do something wrong and lose access to the Mac or lose the default Apple bootloader by removing the Xubuntu partition (/dev/disk0s3) or by deleting the ubuntu boot folder.

6
  • Why not just wipe the machine and re-do it? Commented Apr 19, 2022 at 14:55
  • @MarcWilson wipe the whole machine? Why would I do that if I don't have to? Commented Apr 19, 2022 at 14:58
  • @MarcWilson Do you mean wipe the files like documents as well? Or is there a way to wipe the Operating system and leave my data on the disk? Commented Apr 19, 2022 at 21:31
  • My earlier comment was deleted by mods (it was snark), but to answer you, yes, I'd just wipe the whole machine. It's far easier and I have good backups. Commented Apr 19, 2022 at 21:57
  • @MarcWilson I have backups of the home directory but all my applications would need to be reinstalled and reconfigured, and I'd rather not do that. It turns out reinstalling the OS worked, I got the Apple boot files back. But after booting into Xubuntu, it boots with grub every time again. The Apple boot files are still in the EFI folder this time, so that's an improvement. I'd still like someone to tell me I'm ok to remove the linux partition entirely. Commented Apr 20, 2022 at 0:45

1 Answer 1

2

The safest method to remove the Xubuntu is to boot from an USB Xubuntu Live flash drive, then enter command in a Terminal window to remove the Xubuntu partitions from your internal HDD. Once a Terminal window is open, enter the command lsblk to get the name of the internal drive. Here I will assume the name is sda. If you determine an different name, then make the appropriate substitutions. Next, enter the following command below to remove the Xubuntu partition.

sudo gdisk /dev/sda

The gdisk command is interactive. Enter the values given in the first column of the table below.

Entry Type Comment
s command sort GPT entries in ascending order
p command print the GPT
d command delete a partition
3 data third GPT entry
x command switch to experts menu
n command create a new protective MBR
m command switch to main menu
s command sort GPT entries in ascending order
w command write new MBR and new GPT and exit
y data confirm OK to write

Boot back to macOS and enter the following commands to remove any Xubuntu boot files (GRUB) that may exist in the first EFI partition. Here I will assume the HDD is disk0.

sudo diskutil mount disk0s1
cd /Volumes/EFI/EFI
rm -rf BOOT
rm -rf ubuntu
cd ~
diskutil unmount disk0s1

Since the free space occurs immediately after the partition identified as disk0s2, this free space can be added back to macOS. To add the free space back to macOS, enter the command given below. You can enter this command while booted to macOS. Again, I assume disk0 is the internal HDD.

sudo diskutil apfs resizeContainer disk0s2 0

The installation of Xubuntu erased one of the Microsoft boot files. This file is a exact duplicate of another Microsoft boot file. The commands below can be use to restore this erased file. Again, I assume disk0 is the internal HDD.

sudo diskutil mount disk0s1
cd /Volumes/EFI/EFI
mkdir -p Boot
cp Microsoft/Boot/bootmgfw.efi Boot/bootx64.efi
cd ~
diskutil unmount disk0s1

 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .