The Limine package provides a modern bootloader, an alternative to GRUB.
Mtools-4.0.49 and NASM
dosfstools and efibootmgr
Install Limine by running the following commands:
CC_FOR_TARGET=cc \
LD_FOR_TARGET=ld \
OBJCOPY_FOR_TARGET=objcopy \
OBJDUMP_FOR_TARGET=objdump \
READELF_FOR_TARGET=readelf \
./configure --prefix=/usr \
--enable-bios \
--enable-bios-cd \
--enable-uefi-cd \
--enable-bios-pxe \
--enable-uefi-ia32 \
--enable-uefi-x86-64 &&
make
Now, as the root user:
make install &&
mv -v /usr/share/doc/limine{,-12.3.3}Limine has been installed, but like GRUB, that doesn't mean it is completely installed quite yet. During the build process, various images have been built. Depending on the boot firmware, they may be able to be simply copied from one place to another, or you will need to use limine to help aid with the bootloader installation.
Before complete installation is carried out, it's important to address a
limitation but also a benefit of Limine. The focus of Limine is to be
small and to not have as much features as GRUB. This means it only
supports FAT typed filesystems. EXT4 is not supported. There are a few
options for an already made LFS system in which /boot is formatted as EXT4 if it's a
separate partition, or if it isn't a separate partition.
For UEFI systems, this can be circumvented a bit easier, as one could
stuff all needed assets, including the kernel, into the ESP. For BIOS,
there isn't an option besides creating the /boot partition if it isn't already made,
and formatting it as VFAT/FAT-32. This will require dosfstools if you're
booted in the LFS target. Back up all of your assets needed for booting
and be careful if you need to create the partition.
For UEFI, if you wish to put assets into the ESP, be sure it's big
enough. A resize may be required. Ensure it gets mounted at boot
by putting an entry in /etc/fstab.
For UEFI, the built EFI files
can be copied into the standard location. Install the
EFI files as the root user
(replace
with the ESP location, such as <ESP>/boot/efi):
mkdir -pv<ESP>/EFI/BOOT && cp -v /usr/share/limine/*.EFI \<ESP>/EFI/BOOT
If you want a non-standard location for the EFI or the UEFI firmware doesn't search
that standard location, you will need efibootmgr if you're
booted in the LFS target, and to loosely follow the LFS GRUB Setup,
“Booting With UEFI” section.
For BIOS, you will need to use the limine utility.
Run the following as the root user (repace /dev/sda with the disk you want to install
the bootloader for):
mkdir -pv /boot/limine && cp /usr/share/limine/limine-bios.sys /boot/limine && limine bios-install /dev/sda
Now the configuration file must be made. boot()
points to the root of the partition hosting the configuration file.
This could be /boot, or it could
be the ESP. Thus, the location of the configuration file will vary.
You must move the boot assets to the location boot()
points too, factoring in the sub-directories. Example locations are
as follows: /boot/limine.conf,
/boot/limine/limine.conf,
/boot/efi/limine.conf, and
/boot/efi/EFI/BOOT/limine.conf.
Now create the configuration file as the root user:
mkdir -pv<CONF_LOCATION>&& cat ><CONF_LOCATION>/limine.conf << "EOF"timeout: 5 /GNU/Linux protocol: linux path: boot():/vmlinuz-EOF<linux-version>cmdline: root=/dev/sda2 ro
Replace /dev/sda2 with the
root partition. Like with GRUB, PARTUUID can be
used instead, and UUID under certain conditions.
To get a better idea of the layout, see the below two snippets.
For UEFI:
/boot └── efi ├── EFI │ └── BOOT │ ├── BOOTIA32.EFI │ ├── BOOTX64.EFI │ └── limine.conf ├── config-7.0.8 ├── System.map-7.0.8 └── vmlinuz-7.0.8
For BIOS:
/boot ├── limine │ ├── limine.conf │ └── limine-bios.sys ├── config-7.0.8 ├── System.map-7.0.8 └── vmlinuz-7.0.8