Skip to content

Instantly share code, notes, and snippets.

@bashtheshell
Last active February 16, 2025 11:21
Show Gist options
  • Save bashtheshell/a26a94964e79b7c838758920c7940971 to your computer and use it in GitHub Desktop.
Save bashtheshell/a26a94964e79b7c838758920c7940971 to your computer and use it in GitHub Desktop.
Guide on Creating Clover Bootloader USB on macOS - useful for users with PCIe NVMe SSDs installed on Legacy BIOS machines.

How to Create Clover Bootloader USB on macOS (for PCIe NVMe SSD booting on Legacy BIOS system):

SUMMARY:

If you are a macOS user like me, and you want to create a Clover Bootloader USB on it just so that you can boot up the operating systems that are installed on PCIe NVMe SSDs on your archaic hardware using legacy BIOS? Then you've come to the right place. You may be a homelabber like myself wanting to boot up the hypervisor (e.g. Proxmox).

I've spent numerous hours, searching for a clear step-to-step guide on this, and apparently there isn't an easily-searchable one for macOS users at the time of this writing. Fortunately for us, the Clover project, hosted on GitHub, has a convenient package for us to create a bootloader USB. This project is also hosted on SourceForge.

DOWNLOADING CLOVER:

First, you would need to go to the Release page and download the latest .pkg file as that's intended for macOS. As an example, Clover_r5139.pkg was the latest release at the time of this writing. This was tested on macOS 11 (Big Sur).

FORMATTING USB:

Before you run the package, you'd need to reformat the USB drive. The USB size can be as small as 8 GB as the actual files would only take up no more than 10 MB.

Before you can format the USB, it's important you get the correct disk identifier by running the diskutil list command.

For the sake of demonstration, the USB is at /dev/disk2.

We're going to format the USB and name the volume, CLOVER_USB. The USB should be remounted on its own after it is done.

diskutil eraseDisk FAT32 CLOVER_USB /dev/disk2

INSTALLING BOOTLOADER ON USB:

Open the Clover_rXXXX.pkg file that you downloaded from earlier to begin the installation wizard.

Proceed with the on-screen instruction until you reach the "Installation Type" step. Click on "Change Install Location..." and select the CLOVER_USB media. Then "Continue".

You're back at the "Installation Type" screen. This time click on "Customize".

Make sure you select the following packages to have them installed:

  • Boot Sectors > Install boot0af in MBR
  • BIOS Drivers, 64 bit > File Systems drivers [SELECT ALL] ☑️
  • UEFI Drivers > File System drivers [SELECT ALL] ☑️
  • UEFI Drivers > Additional drivers [SELECT ALL] ☑️
  • CloverConfigPlistValidator

When done selecting, click on "Install". It should take no more than a minute or so, and then you should be done with the wizard.

POST-INSTALLATION TASKS:

Assuming you haven't removed or unmount the USB, we would need to copy the drivers that are installed in the EFI/CLOVER/drivers/UEFI path to the EFI/CLOVER/drivers/BIOS path. It's imperative that we have the NvmExpressDxe.efi driver so that the bootloader can detect the PCIe NVMe SSDs on Legacy BIOS systems.

To copy the drivers to the correct location you can run the following:

cp -n /Volumes/CLOVER_USB/EFI/CLOVER/drivers/UEFI/* /Volumes/CLOVER_USB/EFI/CLOVER/drivers/BIOS

After copying the files, you're done creating the bootloader USB. You can now unmount.

TESTING USB IN VIRTUALBOX (OPTIONAL):

This section is strictly optional. It may be convenient for those who would rather not test the USB on the physical machine until proven otherwise, especially if they were having trouble getting the USB to boot the first time. You are strongly recommended to skip this section if you are doing this for the first time as it's relatively quicker to test the USB directly on the physical machine.

In case you're running macOS on Intel architecture and you would like to quickly make sure USB is bootable before making an attempt on your Legacy BIOS system, you can do so using VirtualBox. Be sure to also install the latest Extension Pack for VirtualBox. At the time of this writing, the latest version was used (6.1.26 r145957).

You may run into isolated issues with VirtualBox on macOS if installing it for the first time due to security restrictions. Be sure to review both the General and Privacy tabs in Security & Privacy Settings in System Preferences. Please use the search engine to research for solutions if issues persist.

CREATING IMAGE FROM USB:

First, you'd need to create image from the USB we just created, and of course, the USB has to be mounted. Open the Disk Utility app.

You should see CLOVER_USB populated on the left side. Right-click it and select "Image from 'CLOVER_USB'". The Format can be left as read-only as that's the default. The encryption should be none. Save it to your preferred location, and you would end up with a .dmg file.

After you're done, you can unmount the physical volume (USB) as you'll be using the .dmg file instead for testing.

CREATING VIRTUAL MACHINE AND BOOT IT UP:

I won't cover how to use VirtualBox here, but if you're familiar with it, then this step should be relatively straightforward.

First, you'd need to create a new VM with type set to Linux. While creating the VM, you can continue with the default selections in the remaining steps.

After you're done creating the VM, go to its Settings, modify its Storage. You'd see an Empty optical disk. Click on it and you should see a disk icon on the right side. Click on it and it'd show the options to add the file to it. You should be able to add the .dmg file you previously created.

While you're still in the VM's Settings, go to the System tab and select the Enable EFI (special OSes only) extended feature. Once you're done, click on "Ok" to apply the change.

You may start the VM, and it should be able to boot the Clover Bootloader. That's it for testing. If it doesn't load, then you may have misconfigured the USB somewhere. Perhaps, the VirtualBox test may not be a reliable indicator for you, and you can proceed to test it on the actual hardware just to double-check.


CONFIGURING PERSISTENT SETTINGS IN CLOVER BOOTLOADER:

After you've booted up Clover bootloader on the actual legacy BIOS system, you may have noticed that you have to manually select the desired volume each time as it won't automatically boot the detected volumes for you. This is the expected behavior as you would have to do some customization.

BOOT THE CLOVER BOOTLOADER FROM USB:

First, you would need to boot the bootloader on your legacy BIOS system. Once you reached the Clover Operating Systems Boot Manager home screen, you should be able to view some options. Press F1 key to view the Help menu.

You would see that you can save the existing preboot.log to the EFI/CLOVER/misc/ directory. Press the F2 key to save the preboot.log to the USB as you would need it for later steps. You may want to press a few more time just to make sure it's saved.

Before you go ahead shut down the computer, you may want to highlight the volume (not actually clicking on it as it'd boot to the OS) in the list and then press the SPACEBAR key to reveal the UUID information. You only need to briefly memorize the first and last couple characters so you can confidently make sure you are referencing to the correct UUID as we'll find it in the preboot.log file later to conveniently copy and paste.

Once you're done, you can do a hard shut down and then remove the USB.

REVIEW THE LOG FILE ON USB:

This step assumes you're using the same Mac that was used to create the bootloader on the USB as the preboot.log file would be reviewed on it.

Once you mount the USB, you'd need to find all the detected volumes that you saw in the bootloader in the previous section. To do so, run the following command.

sed -n '/ScanLoader/,/AddCustomTool/p' /Volumes/CLOVER_USB/EFI/CLOVER/misc/preboot.log

If nothing shows up, then you may want to manually check the file by running less /Volumes/CLOVER_USB/EFI/CLOVER/misc/preboot.log. If it's blank, chances are you didn't press F2 as instructed in the previous section.

If you see an output, you'd need to look at the very last block starting with the last === [ ScanLoader ] ============================== line and ending with the last === [ AddCustomTool ] =========================== line as you may have duplicate blocks.

Within the block, you should be able to see lines with - [XX]: 'SOME RANDOM NAME'. The XX should be digits. Those lines denote Menu Entry sections, and some are deliberately hidden by the bootloader. The USB bootloader itself is automatically hidden for obvious reason. The menu entry information may have a descriptive name.

The actual lines that you need to look for starts with Loader entry created for as each contains the UUID. Here's an example of an UUID, 57272A5A-7EFE-4404-9CDA-C33761D0DB3C. You would need to copy the UUID you recognized from previous step to be pasted later in the next section.

UPDATING THE CONFIG.PLIST FILE:

To be able to automatically boot to the preferred volume (menu entry) in the bootloader, you would need to update the DefaultVolume key with the preferred volume's UUID in the config.plist. Please see the original documentation here for more information if you are curious.

The easiest way to do this is to run the following commmands. Of course, you'd need to paste your UUID here.

YOUR_UUID=57272A5A-7EFE-4404-9CDA-C33761D0DB3C
sed -i.bkup "s/LastBootedVolume/${YOUR_UUID}/" /Volumes/CLOVER_USB/EFI/CLOVER/config.plist

To verify it's correctly updated:

grep -A 1 DefaultVolume /Volumes/CLOVER_USB/EFI/CLOVER/config.plist

In case you somehow screwed up (e.g. wrong UUID value) or you need to set new UUID again due to volume being reformatted, you can simply revert by running the following rather than starting over from scratch.

cp /Volumes/CLOVER_USB/EFI/CLOVER/config.plist.bkup /Volumes/CLOVER_USB/EFI/CLOVER/config.plist

Please note that you may need to update the DefaultVolume key value again the next time the preferred volume is reformatted (e.g. reinstalling OS on SSD) as new UUID would be created each time. You can simply revert to the original plist file by running the above command rather than starting again from the top. Then repeat only the first step. This assumes you know what the new UUID is. Please see earlier subsections for instruction.

DONE! YOU CAN UNMOUNT THE USB:

You are now all set! You can proceed to unmount the USB.

You should be able to boot to your preferred volume automatically. You may notice that it'd take five seconds before Clover bootloader can boot to your preferred volume. By default, this would take 5 seconds, but you'd need to change the Timeout value to 0 as described in the documentation here if you want to skip the bootloader entirely. Of course, you can simply edit the config.plist file directly for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment