Where are kernel and initramfs files for systemd-boot?
Locating Kernel and Initramfs Files for systemd-boot: A Comprehensive Guide for Arch Linux Installations
For those undertaking a fresh installation of Arch Linux and opting for systemd-boot
as their bootloader, a common point of confusion arises when it comes to the critical step of copying the kernel and initramfs images onto the EFI System Partition (ESP). The instruction to “Copy your kernel and initramfs onto that ESP” can be perplexing when the expected files, such as vmlinuz-linux
and initramfs-linux.img
, seem to be nowhere to be found, neither on the installation media nor within the mounted target partitions. This guide, presented by revWhiteShadow, aims to demystify this process, providing a detailed and exhaustive explanation of where these essential boot components reside and how to properly prepare them for systemd-boot
. We understand the frustration of encountering such a roadblock during installation and are here to provide the clarity and precision needed to move forward.
Understanding the Boot Process with systemd-boot
Before delving into the specifics of file locations, it is crucial to grasp how systemd-boot
(formerly known as gummiboot
) interacts with the boot process. systemd-boot
is a simple, UEFI boot manager that operates directly from the ESP. Its primary function is to load an operating system by finding and executing its kernel and initramfs images. Unlike traditional bootloaders that rely on configuration files within the operating system itself, systemd-boot
primarily uses configuration files stored on the ESP to define boot entries.
The ESP, formatted as FAT32, is a small, dedicated partition that the UEFI firmware can access during the boot sequence. It typically resides at /boot
or /efi
within the installed operating system. systemd-boot
scans this partition for bootloader executables (like systemd-bootx64.efi
) and, importantly, for the operating system’s kernel and initramfs images. When the system boots, the UEFI firmware loads systemd-bootx64.efi
from the ESP. systemd-boot
then consults its configuration files to present a boot menu or directly load the default kernel, requiring direct access to these files.
The Role of the Kernel and Initramfs
The kernel is the core of the operating system, responsible for managing the system’s resources, including memory, processes, and hardware. In Arch Linux, the standard kernel package is linux
, and its executable file is typically named vmlinuz-linux
.
The initramfs (initial RAM filesystem) is a small filesystem loaded into memory by the bootloader. It contains the essential tools and modules needed to mount the root filesystem and continue the boot process. Think of it as a bootstrap environment for the kernel. For the linux
package in Arch Linux, the corresponding initramfs image is usually initramfs-linux.img
.
The kernel and initramfs are the fundamental components that systemd-boot
needs to load an Arch Linux system. Without them, the bootloader has nothing to execute to start the operating system.
The Installation Media vs. The Installed System: A Crucial Distinction
A primary reason for the confusion regarding the location of vmlinuz-linux
and initramfs-linux.img
is the misunderstanding of when these files become available. The Arch Linux installation media, whether it’s a USB drive or a DVD, is a temporary, read-only environment designed to facilitate the installation process. It contains a minimal set of tools and a live Arch Linux system.
The kernel and initramfs files that you need for your installed Arch Linux system are not present on the installation media. The installation media provides the tools to create and populate your target system’s partitions. Therefore, when you mount your newly created root partition and ESP during the installation, these kernel and initramfs files will not magically appear there. They are generated after the base system has been installed onto the target disk.
The prompt mentioned, “Nothing exists in /boot in either my Arch Linux install disk or the partitions that I’m working with.” This is entirely expected. The /boot
directory on the installation media is part of the live environment, and the partitions you’ve created for your new installation are, at this stage, empty or contain only the base filesystem structure.
Generating Kernel and Initramfs Images: The Post-Installation Step
The crucial realization is that the vmlinuz-linux
and initramfs-linux.img
files are generated as part of the Arch Linux installation process itself, specifically when you install the linux
package. This package is responsible for not only providing the kernel executable but also for creating the necessary initramfs image tailored to your system.
The mkinitcpio
command is the utility used by Arch Linux to generate these initramfs images. When the linux
package is installed using pacman
, its post-installation scripts automatically run mkinitcpio
to create the vmlinuz-linux
and initramfs-linux.img
files.
So, where are these files generated? By default, when you install the linux
package in Arch Linux, these files are placed in the /boot
directory of the target system. This is the system you are installing onto, not the live environment you are booting from.
The Correct Workflow: Installing the Base System First
The sequence of operations is paramount. You cannot copy files that have not yet been created. The correct workflow for installing Arch Linux with systemd-boot
involves these key stages:
- Boot from the Arch Linux installation media.
- Partition and format your storage devices. This includes creating your ESP, your root partition (
/
), and any other desired partitions (e.g.,/home
, swap). - Mount your partitions. You will need to mount your root partition (e.g., to
/mnt
) and your ESP (e.g., to/mnt/boot
or/mnt/efi
). It is common practice to mount the ESP at/mnt/boot
when usingsystemd-boot
to simplify subsequent steps, as the kernel and initramfs will naturally reside in/boot
. - Install the base system. Use
pacstrap
to install thebase
,linux
,linux-firmware
, and any other essential packages onto your mounted root partition (e.g.,pacstrap /mnt base linux linux-firmware
). - Generate fstab. Create the
fstab
file for your new system withgenfstab -U /mnt >> /mnt/etc/fstab
. - Chroot into the new system. Use
arch-chroot /mnt
to enter your newly installed environment. - Install bootloader. Now that the
linux
package is installed within your chrooted environment, thevmlinuz-linux
andinitramfs-linux.img
files will have been created and placed in/boot
of your target system.
Locating the Files After Base System Installation (Inside Chroot)
Once you have successfully chrooted into your new Arch Linux installation (using arch-chroot /mnt
), the files you are looking for will be readily available. Navigate to the /boot
directory within this chrooted environment.
You will find:
vmlinuz-linux
: This is the compressed Linux kernel image.initramfs-linux.img
: This is the initial RAM filesystem image for the standardlinux
kernel.intel-ucode.img
(optional): If you have an Intel CPU, thelinux-firmware
package may also generate microcode updates, often placed here.amd-ucode.img
(optional): Similarly, for AMD CPUs.
These are the exact files that systemd-boot
needs.
Copying Kernel and Initramfs to the ESP with systemd-boot
The next crucial step after installing the base system and having the kernel and initramfs files generated in /boot
(within your chrooted environment) is to copy them to the ESP.
Remember how you mounted your ESP earlier? If you mounted your ESP to /mnt/boot
when you were setting up the system (before chrooting), then the files are already in the correct location relative to the root of your installed system.
Scenario 1: ESP Mounted at /mnt/boot
If you followed the common practice of mounting your ESP at /mnt/boot
during the initial setup, then the files generated by mkinitcpio
will automatically be placed within this mounted ESP.
- Before chroot:
mount /dev/sdXN /mnt/boot # Where sdXN is your ESP partition pacstrap /mnt base linux linux-firmware
- Inside chroot:
When
pacstrap
installs thelinux
package,mkinitcpio
runs and placesvmlinuz-linux
andinitramfs-linux.img
directly into/mnt/boot
. Since/mnt/boot
is your ESP, they are already wheresystemd-boot
can find them.
Scenario 2: ESP Mounted at /mnt/efi
(or another mount point)
If you mounted your ESP at a different location, such as /mnt/efi
, then you will need to manually copy the files.
Before chroot:
mount /dev/sdXN /mnt/efi # Where sdXN is your ESP partition pacstrap /mnt base linux linux-firmware
Inside chroot: After chrooting (
arch-chroot /mnt
), the kernel and initramfs are located in/boot
. You need to copy them to your ESP’s mount point, which is/efi
from within the chroot.# Inside the chroot environment: cp /boot/vmlinuz-linux /efi/ cp /initramfs-linux.img /efi/ # If microcode is present: # cp /boot/intel-ucode.img /efi/ # cp /boot/amd-ucode.img /efi/
Important Note on mkinitcpio.conf
:
The behavior of mkinitcpio
is controlled by /etc/mkinitcpio.conf
. The HOOKS
array in this file dictates which modules and scripts are included in the initramfs. Crucially, the filesystems
hook is usually present, which ensures that the necessary modules to mount your root filesystem are included.
Furthermore, the installkernel
hook, which is typically enabled by default, is responsible for copying the kernel image. The mkinitcpio
package configuration determines the default output directory for the kernel and initramfs. For most standard Arch Linux installations, this defaults to /boot
.
Configuring systemd-boot
Once the kernel and initramfs files are on your ESP, the next step is to configure systemd-boot
to recognize and load them.
Install systemd-boot: From within your chrooted environment, install the
bootctl
utility and installsystemd-boot
to the ESP.# Inside the chroot environment: bootctl install
This command installs the necessary UEFI bootloader files (
systemd-bootx64.efi
,loader.efi
, etc.) to the ESP.Create the loader configuration: The main configuration file for
systemd-boot
is/boot/loader/loader.conf
(if ESP is mounted at/boot
). This file specifies general boot manager settings, such as the default entry and timeout.Example
/boot/loader/loader.conf
:default arch.conf timeout 3 console-mode max
Create boot entry files: For each operating system or kernel you want to boot, you create a separate
.conf
file in/boot/loader/entries/
. These files specify the kernel image, initramfs image, kernel command line parameters, and other options.Example
/boot/loader/entries/arch.conf
:Assuming your ESP is mounted at
/boot
and the files are in/boot
:title Arch Linux linux /vmlinuz-linux initrd /initramfs-linux.img options root=PARTUUID=YOUR_ROOT_PARTUUID rw # Replace with your actual root partition's PARTUUID or UUID
If your ESP is mounted at
/efi
, the paths would change accordingly:title Arch Linux linux /arch/boot/vmlinuz-linux # Or simply /vmlinuz-linux if you copied them to the root of ESP initrd /arch/boot/initramfs-linux.img # Or simply /initramfs-linux.img if you copied them to the root of ESP options root=PARTUUID=YOUR_ROOT_PARTUUID rw
Crucially, you need to determine the correct paths to your kernel and initramfs images on the ESP. If you copied them directly to the root of your ESP, then
/vmlinuz-linux
and/initramfs-linux.img
are correct. If you created a subdirectory on the ESP, for example,/boot/efi/EFI/Arch/
, then you would adjust the paths in the.conf
file to reflect that. However, the standard practice when mounting ESP at/boot
means they reside in/boot
directly.Finding
YOUR_ROOT_PARTUUID
: You can find the PARTUUID or UUID of your root partition by runninglsblk -p -o NAME,UUID,PARTUUID
on the Arch Linux installation media or within your chrooted environment.
Addressing the bootctl
Question
The question “Do I need to install bootctl
before those files are available?” can now be answered definitively. No, you do not need to install bootctl
before the kernel and initramfs files are available.
bootctl
is the command-line utility for systemd-boot
. It is used to install systemd-boot
to the ESP and to manage boot entries (though manual creation of entry files is more common). The linux
package in Arch Linux is responsible for creating vmlinuz-linux
and initramfs-linux.img
. These are created when you install the linux
package using pacman
. bootctl
comes into play after these files have been generated and copied to the ESP, to configure systemd-boot
to use them.
The typical order is:
- Install the
linux
package (which generates kernel/initramfs in/boot
of the target). - Copy these files to the ESP (or ensure they are already there if ESP is mounted at
/boot
). - Install
systemd-boot
usingbootctl install
. - Configure
systemd-boot
by creatingloader.conf
and entry files.
Summary of File Locations and Workflow
To reiterate, for a successful Arch Linux installation with systemd-boot
:
- Kernel and initramfs are generated after installing the
linux
package. They are not present on the installation media. - Default location of generation:
/boot
within the target Arch Linux system. - If ESP is mounted at
/mnt/boot
: The generated files in/boot
of the target system are already on your ESP. - If ESP is mounted elsewhere (e.g.,
/mnt/efi
): You must explicitly copy/boot/vmlinuz-linux
and/boot/initramfs-linux.img
from your target system’s/boot
directory to the ESP’s mount point (e.g.,/efi
). bootctl
is used after the kernel and initramfs are on the ESP to install thesystemd-boot
EFI application.
By understanding this workflow and the lifecycle of these critical boot files, the process of setting up systemd-boot
on your Arch Linux installation becomes clear and manageable. revWhiteShadow is committed to providing such detailed insights to empower your Linux journey.