User:Skepticalview/Clover BIOS wrapper

From ArchWiki

Installation

stub


Clover BIOS wrapper

https://github.com/CloverHackyColor/CloverBootloader/releases/latest

$ truncate --size=500M clovertest.raw
$ qemu-system-x86_64 \
     -drive file=clovertest.raw,media=disk,format=raw \
     -boot order=c -enable-kvm -m 512

This command will be reused multiple times to test the progress. At this point it would try to boot via iPXE but ultimately find No bootable device.

Create a partition table.

$ echo -e "label: gpt \n size=300M type=uefi \n size=200m" | sfdisk clovertest.raw
Checking that no-one is using this disk right now ... OK

Disk clovertest.raw: 500 MiB, 524288000 bytes, 1024000 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

>>> Script header accepted.
>>> Created a new GPT disklabel (GUID: E47DB923-1A30-A149-8FAB-5EFF6B039E54).
clovertest.raw1: Created a new partition 1 of type 'EFI System' and of size 300 MiB.
clovertest.raw2: Created a new partition 2 of type 'Linux filesystem' and of size 198 MiB.
clovertest.raw3: Done.

New situation:
Disklabel type: gpt
Disk identifier: E47DB923-1A30-A149-8FAB-5EFF6B039E54

Device           Start     End Sectors  Size Type
clovertest.raw1   2048  616447  614400  300M EFI System
clovertest.raw2 616448 1021951  405504  198M Linux filesystem

The partition table has been altered.
Syncing disks.

The important part here is creating the partition of type=uefi for the ESP. It is also possible to create partition table interactively using fdisk.

qemu would attempt Booting from Hard Disk... Unsuccessfully.

Download the latest .iso.7z Clover release from https://github.com/CloverHackyColor/CloverBootloader/releases

Unpack it into current directory with

$ bsdtar -xf ~/Downloads/Clover-*-X64.iso.7z -O | bsdtar -xf -


$ dd if=usr/standalone/i386/boot0af bs=440 count=1 conv=notrunc of=clovertest.raw 

At this point we start seeing results in qemu output: boot0af: error. This is expected, as there is nothing to load.

# losetup --find --show --partscan clovertest.raw 

Assuming it has been set up as /dev/loop0

# mkfs.fat -F 32 -n EFI /dev/loop0p1
# dd if=/dev/loop0p1 count=1 bs=512 of=origbs
$ cp usr/standalone/i386/boot1f32 newbs
$ dd if=origbs skip=3 seek=3 bs=1 count=87 conv=notrunc of=newbs
# dd if=newbs of=/dev/loop0p1

qemu should now infinitely loop at Booting from Hard Disk... with a blinking cursor.

# mount /dev/loop0p1 /mnt/
# cp usr/standalone/i386/x64/boot6 /mnt/boot

From here qemu system can already boot. 6_ should appear momentarily and then a BIOS-like interface with five options, with Continue as topmost one. It means boot file was successfully loaded and is working but it cannot find the file CloverX64.efi [1]

It is already possible to launch an UEFI boot loader, for example systemd-boot, from here with Boot Maintanance Manager > Boot From File > EFI,[device] > EFI > systemd > systemd-bootx64.efi

Now proceed to #Installation or continue with #chainload systemd-boot

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" "http://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>