Contribute
Register

EFISTUB: Load Linux with Clover

Status
Not open for further replies.
Joined
Jul 24, 2015
Messages
2,191
Motherboard
MSI H81i
CPU
i5-4570
Graphics
RX 580
Clover can boot linux without the need for chain-loading of bootloaders e.g. GRUB. This is possible because for some time (>3.3) the kernel has contained its own EFI bootloader. Clover loads the kernel as an EFI executable.

Arch Linux

Example steps using an existing EFI system partition (e.g. same one as Clover). Using the EFI partition in this way means we don't need additional file system drivers.

First, discover some partition UUIDs, and edit /etc/fstab so that the EFI partition mounts at boot time on /boot.

Unmount whatever is mounted on /boot

Code:
sudo umount /boot

We need 2 partition UUIDs (PARTUUID), one for the root volume (for the kernel command line) and one for the EFI partition (from where the kernel itself will be loading). Copy them for later use.

List partitions with blkid

Code:
sudo blkid

PARTUUIDs obtained from 'blkid' output that will be used in this example:

EFI: 3ecfa8d5-8c7f-485e-a90e-a917f1fa7da5
Root: c8c7afb0-55c6-4065-bf3d-dd39cbd39e69

Edit existing or create new fstab entry for /boot

Code:
sudo nano /etc/fstab

Use the EFI partition UUID you obtained earlier e.g.

Code:
PARTUUID=3ecfa8d5-8c7f-485e-a90e-a917f1fa7da5     /boot    vfat

Save the file, and mount the partition

Code:
sudo mount PARTUUID=3ecfa8d5-8c7f-485e-a90e-a917f1fa7da5 /boot

Next configure kernel and ramdisk updates so both of these get located at /boot (i.e. root of EFI partition). See your distro's documentation, steps for Arch:

mkinitcpio: Backup + edit linux.preset

Code:
sudo cp /etc/mkinitcpio.d/linux.preset /etc/mkinitcpio.d/linux.backup
sudo nano /etc/mkinitcpio.d/linux.preset

Verify contents of mkinitcpio 'linux' preset, if no changes needed that is fine

# mkinitcpio preset file for the 'linux' package

ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-linux"

PRESETS=('default' 'fallback')

#default_config="/etc/mkinitcpio.conf"
default_image="/boot/initramfs-linux.img"

#fallback_config="/etc/mkinitcpio.conf"
fallback_image="/boot/initramfs-linux-fallback.img"
fallback_options="-S autodetect"

Install the kernel package with the new configuration + /boot mount point

Code:
sudo pacman -S linux

Verify that the kernel and ramdisk are now present in the root of our EFI partition:

Code:
ls /boot

Edit Clover's config.plist, creating a custom entry for the Linux kernel

Code:
sudo nano /boot/efi/clover/config.plist

The custom entry should look something like this. We are still using the same UUIDs obtained earlier, pay attention to the EFI-style path (\ separator) in the Clover 'Path' property vs the POSIX-style path (/ separator) in the kernel command line.

<dict>
<key>Arguments</key>
<string>initrd=/initramfs-linux.img root=PARTUUID=c8c7afb0-55c6-4065-bf3d-dd39cbd39e69 rw quiet</string>
<key>Path</key>
<string>\vmlinuz-linux</string>
<key>Type</key>
<string>Linux</string>
<key>Volume</key>
<string>3ECFA8D5-8C7F-485E-A90E-A917F1FA7DA5</string>
</dict>

With the kernel now loadable from the EFI partition you could also add an option in the firmware boot menu with efibootmgr. EFISTUB on ArchWiki
 
Last edited:
I started playing with Clover's options a bit and found that if I installed the proper filesystem drivers, Clover sees my Linux kernels just fine--no need to copy them anywhere. They don't boot without specifying a command line of course. With rEFInd, I can create a file that specifies how to do that for all kernels coming from a particular location (so multiple Linux distributions are possible). Is this something Clover can do and is it documented anywhere?

If not, as long as I can specify Linux options for kernels from ONE distribution by default, that'll be enough. I just don't like it breaking when I upgrade kernels. ;)
 
I started playing with Clover's options a bit and found that if I installed the proper filesystem drivers, Clover sees my Linux kernels just fine--no need to copy them anywhere. They don't boot without specifying a command line of course. With rEFInd, I can create a file that specifies how to do that for all kernels coming from a particular location (so multiple Linux distributions are possible). Is this something Clover can do and is it documented anywhere?

If not, as long as I can specify Linux options for kernels from ONE distribution by default, that'll be enough. I just don't like it breaking when I upgrade kernels. ;)
Using Clover's custom entries feature, you can pass the kernel command line in 'Arguments'.
 
I found this entry on the Arch wiki talking about how to do that for a generic kernel symlink, but not necessarily, "for any Linux kernels you find on <partition ID>, use this command line..." If I want that, I may need to resort to chainloading bootloaders or spending an afternoon with the git repository perhaps.
 
I found this entry on the Arch wiki talking about how to do that for a generic kernel symlink, but not necessarily, "for any Linux kernels you find on <partition ID>, use this command line..." If I want that, I may need to resort to chainloading bootloaders or spending an afternoon with the git repository perhaps.
Command line is likely available at runtime, at /proc/cmdline and in bootloader configuration files. Mainly you need to pass the root disk path and ramdisk path and you will be able to boot. The Arch wiki has good documentation of efistub.
 
I'd like to add something here. There is a Linux Kernel Scan feature which could potentially do this if the default arguments will work for you. Otherwise as indicated above you need to create a custom entry to specify a kernel file and command line. I just use one custom entry with the default options for the Arch and Ubuntu kernels on my machine and chainload GRUB for more options since Clover doesn't have working custom subentries.
 
I'd like to add something here. There is a Linux Kernel Scan feature which could potentially do this if the default arguments will work for you. Otherwise as indicated above you need to create a custom entry to specify a kernel file and command line. I just use one custom entry with the default options for the Arch and Ubuntu kernels on my machine and chainload GRUB for more options since Clover doesn't have working custom subentries.
Not sure what options you mean. I have Arch installed on a desktop and on a chromebook and have found no need for GRUB.
 
Not sure what options you mean. I have Arch installed on a desktop and on a chromebook and have found no need for GRUB.

I found GRUB subentries useful for organizing multiple Linux kernels, with different command lines, from one or more distributions rather than creating several custom entries for each OS and kernel combination in Clover. This way I can boot each with it's standard options directly from Clover or select GRUB if I want to boot a different kernel or recovery mode, single user mode, terminal mode or want to change the arguments at boot time. The person above could use rEFInd too and hide it until it's needed so the Clover menu is cleaner. It's just an idea from my experience and maybe it'll help someone.
 
I started playing with Clover's options a bit and found that if I installed the proper filesystem drivers, Clover sees my Linux kernels just fine--no need to copy them anywhere. They don't boot without specifying a command line of course. With rEFInd, I can create a file that specifies how to do that for all kernels coming from a particular location (so multiple Linux distributions are possible). Is this something Clover can do and is it documented anywhere?

If not, as long as I can specify Linux options for kernels from ONE distribution by default, that'll be enough. I just don't like it breaking when I upgrade kernels. ;)

Any chance you can elaborate on "the proper filesystem drivers?" I copied VBoxExt4.efi into drivers64UEFI and it doesn't see my linux kernels.

Antergos keeps them at /boot with a consistent name.
 
Any chance you can elaborate on "the proper filesystem drivers?" I copied VBoxExt4.efi into drivers64UEFI and it doesn't see my linux kernels.

Antergos keeps them at /boot with a consistent name.
/Boot is the mount point - Clover needs a driver for whatever partition is mounted at /boot - i.e. in /etc/fstab. If you have your EFI partition mounted on /boot no extra filesystem driver is needed.

Once you are sure Clover can read the partition and the kernel and ram disk are present create a custom entry with the required properties:

Volume: GPT Partition UUID of whatever is mounted on /boot (Clover matches what you put here to its device path description so anything that matches should do really)
Path: Path to linux kernel on above partition (EFI style so backslash not forward slash in paths)
Arguments: Kernel command line (POSIX style paths)

e.g.

<dict>
<key>Arguments</key>
<string>initrd=/efi/arch/intel-ucode.img initrd=/efi/arch/initramfs-linux.img root=/dev/disk/by-uuid/c61e967d-85f7-4bcc-aa5b-d2e999736030 rw quiet</string>
<key>Path</key>
<string>\efi\arch\vmlinuz-linux.efi</string>
<key>Type</key>
<string>Linux</string>
<key>Volume</key>
<string>3ECFA8D5-8C7F-485E-A90E-A917F1FA7DA5</string>
<key>VolumeType</key>
<string>Internal</string>
</dict>

Edit:

If the kernel is at /boot/vmlinuz-linux then
<key>Path</key>
<string>\vmlinuz-linux</string>
 
Last edited:
Status
Not open for further replies.
Back
Top