Determine Boot Mode and Bootloader
Before proceeding with bootloader configuration, it is crucial to determine the architecture and boot mode of the VM. Let’s clarify this step by step.
Step 1: Determine the Architecture
The architecture of the VM (x86, x86_64, ARM, etc.) can be determined using the following command:
uname -m
If the output is
x86_64
, the VM is running on a 64-bit x86 architecture.If the output is
i386
ori686
, the VM is running on a 32-bit x86 architecture.Other outputs like
aarch64
indicate ARM architecture.
Step 2: Determine the Boot Mode (BIOS vs. UEFI)
The presence of the /boot/loader
directory suggests that systemd-boot (formerly gummiboot) might be in use, which is typically associated with UEFI booting. However, since the /boot/efi
directory is empty, this could indicate one of the following scenarios:
UEFI Boot with systemd-boot:
The
/boot/loader
directory is used by systemd-boot, which is a UEFI bootloader.Even if
/boot/efi
is empty, the UEFI bootloader might be installed elsewhere (e.g., on the EFI System Partition (ESP) mounted at a different location).
Legacy BIOS Boot with GRUB:
The presence of
/boot/grub2
suggests GRUB is being used, which is common for BIOS booting.The
/boot/loader
directory might be a leftover or misconfiguration.
To confirm the boot mode, you can check the following:
Check for UEFI Boot
Run the following command to check if the system is booted in UEFI mode:
ls /sys/firmware/efi
If the directory exists, the system is booted in UEFI mode.
If the directory does not exist, the system is likely booted in BIOS (legacy) mode.
Check for systemd-boot Configuration
If the system is booted in UEFI mode, check if systemd-boot is the active bootloader:
bootctl status
If systemd-boot is installed, this command will display details about the bootloader, including the boot mode (UEFI) and the installed entries.
Step 3: Verify the Bootloader in Use
Based on the above checks, you can determine the bootloader in use:
If UEFI and systemd-boot are confirmed:
The bootloader is systemd-boot, and the configuration files are located in
/boot/loader/entries/
.You should add your custom kernel entry as a new
.conf
file in/boot/loader/entries/
.
If BIOS and GRUB are confirmed:
The bootloader is GRUB, and the configuration files are located in
/boot/grub2/
.You should add your custom kernel entry to
/etc/grub.d/
and regenerategrub.cfg
.
Step 4: Proceed Based on Bootloader
Once you’ve confirmed the bootloader, you can proceed as follows:
For systemd-boot (UEFI)
Create a new
.conf
file in/boot/loader/entries/
:sudo nano /boot/loader/entries/copied_kernel.conf
Add the following content (adjust paths as needed):
title Copied Kernel version Copied Kernel linux /boot/copied_kernel/vmlinuz-copied initrd /boot/copied_kernel/initrd.img-copied options root=/dev/sda1
Reboot the system, and the new entry should appear in the boot menu.
For GRUB (BIOS)
Create a custom entry in
/etc/grub.d/
:sudo nano /etc/grub.d/40_custom
Add the following content (adjust paths as needed):
menuentry 'Copied Kernel' { set root='hd0,msdos1' linux /boot/copied_kernel/vmlinuz-copied root=/dev/sda1 initrd /boot/copied_kernel/initrd.img-copied }
Make the file executable:
sudo chmod +x /etc/grub.d/40_custom
Regenerate the GRUB configuration:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot the system, and the new entry should appear in the GRUB menu.
Summary of Steps
Determine the architecture using
uname -m
.Check the boot mode using
ls /sys/firmware/efi
andbootctl status
.Verify the bootloader (systemd-boot or GRUB).
Add the custom kernel entry based on the bootloader.