Clover

From ArchWiki
(Redirected from Clover (简体中文))

Clover EFI is a boot loader developed to boot macOS (Hackintoshes), Windows and Linux in legacy or UEFI mode.

The main advantages of Clover are:

  • Emulate UEFI on legacy BIOS systems
  • Boot Linux kernels with EFI boot stub support
  • Supports native resolution GUI on wide screens people commonly use today
  • Easy to use
  • Easily customizable

Installation

As Clover emulates a UEFI environment on BIOS systems, the steps for each type of system are similar.

UEFI Systems

Mount EFI system partition to /boot. This is the preferred method when directly booting an EFI boot stub kernel from UEFI.

Generate initial ramdisk environment with mkinitcpio

Download Clover Bootable ISO from here.

Extract the archive Clover-*-X64.iso.7z and find the Clover-*-X64.iso file, mount it to a directory like /mnt/iso. It should be noted all file/folder names will be displayed in lower case in Linux, which is different from Windows and Mac OS.

Copy the whole /mnt/iso/efi folder to your EFI system partition. The tree for /boot should look likes the following

/boot/EFI
/boot/EFI/BOOT
/boot/EFI/CLOVER
/boot/initramfs-linux-fallback.img
/boot/initramfs-linux.img
/boot/vmlinuz-linux

BIOS Systems

Note: Even though this is Legacy BIOS, the UEFI/GPT partitioning layout is required. The only difference is the "Legacy BIOS bootable" flag needs to be set on the EFI system partition.

Download the Clover Bootable ISO.

Extract the archive Clover-*-X64.iso.7z and find the Clover-*-X64.iso file, mount it to directory like /mnt/iso.

Merge Clover code with current Master and Partition Boot Records (assuming ESP is partition 1 of /dev/sda, change if necessary):

# dd if=/dev/sda1 of=/tmp/original_PBR bs=512 count=1 conv=notrunc
# cp /mnt/iso/usr/standalone/i386/boot1f32 /tmp/new_PBR
# dd if=/tmp/original_PBR of=/tmp/new_PBR skip=3 seek=3 bs=1 count=87 conv=notrunc
# dd if=/tmp/new_PBR of=/dev/sda1 bs=512 count=1 conv=notrunc
# dd if=/mnt/iso/usr/standalone/i386/boot0ss of=/dev/sda bs=440 count=1 conv=notrunc

Mount the EFI system partition to /boot.

Copy the whole /mnt/iso/efi folder to your EFI system partition.

Copy the legacy bootloader to the EFI system partition:

# cp /mnt/iso/usr/standalone/i386/x64/boot6 /boot/boot

Configuration

Configuration is done through an XML file config.plist under path EFI/CLOVER from the EFI system partition.

A tool is now available to easily edit your config.plist in any OS: Cloud Clover Editor (CCE)[dead link 2024-10-12 ⓘ]

For the meaning of each key, please reference their wiki for custom entries. The key Volume should be the PARTUUID of the EFI system partition and must be in uppercase. The minimal initramfs initramfs-linux.img in Argumentsand the Linux kernel executable vmlinuz-linux in Path are relative to the EFI system partition. Backslashes should be used in accordance with EFI standards. For other arguments in Arguments, please reference EFI boot stub and Kernel parameters#Parameter list.

In this example, the initramfs and kernel files are placed at the root of the EFI system partition, at the same level as the efi directory. The EFI system partition is mounted at /boot

/boot/EFI/CLOVER/config.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>GUI</key>
  <dict>
    <key>Custom</key>
    <dict>
      <key>Entries</key>
      <array>
        <dict>
          <key>Arguments</key>
          <string>initrd=\initramfs-linux.img root=PARTUUID=d5d0fceb-c58e-c745-a7ff-f2f1b2824e66 rw add_efi_memmap</string>
          <key>Path</key>
          <string>\vmlinuz-linux</string>
          <key>Title</key>
          <string>Arch Linux</string>
          <key>Type</key>
          <string>Linux</string>
          <key>Volume</key>
          <string>33BA6C23-4772-294D-9053-72A49FCAEF39</string>
          <key>VolumeType</key>
          <string>Internal</string>
        </dict>
        <dict>
          <key>Arguments</key>
          <string>initrd=\initramfs-linux-fallback.img root=PARTUUID=d5d0fceb-c58e-c745-a7ff-f2f1b2824e66 rw debug add_efi_memmap</string>
          <key>Path</key>
          <string>\vmlinuz-linux</string>
          <key>Title</key>
          <string>Arch Linux Rescue Mode</string>
          <key>Type</key>
          <string>Linux</string>
          <key>Volume</key>
          <string>33BA6C23-4772-294D-9053-72A49FCAEF39</string>
          <key>VolumeType</key>
          <string>Internal</string>
        </dict>
      </array>
    </dict>
  </dict>
</dict>
</plist>

chainload systemd-boot

If you need a bootloader for BIOS systems that follows The Boot Loader Specification, then systemd-boot can be pressed into service on BIOS systems. This is the configuration file needed make Clover chainload systemd-boot.

/boot/EFI/CLOVER/config.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Boot</key>
	<dict>
		<key>DefaultVolume</key>
		<string>EFI</string>
		<key>DefaultLoader</key>
		<string>\EFI\systemd\systemd-bootx64.efi</string>
		<key>Fast</key>
		<true/>
	</dict>
	<key>GUI</key>
	<dict>
		<key>Custom</key>
		<dict>
			<key>Entries</key>
			<array>
				<dict>
					<key>Hidden</key>
					<false/>
					<key>Disabled</key>
					<false/>
					<key>Image</key>
					<string>os_arch</string>
					<key>Volume</key>
					<string>EFI</string>
					<key>Path</key>
					<string>\EFI\systemd\systemd-bootx64.efi</string>
					<key>Title</key>
					<string>Arch Linux</string>
					<key>Type</key>
					<string>Linux</string>
				</dict>
			</array>
		</dict>
	</dict>
</dict>
</plist>

See also