Arch Linux Working On Unified Kernel Image

What is a Unified Kernel Image?

A Unified Kernel Image (UKI) is a single executable file that combines:

  • The Linux kernel
  • An initramfs (initial RAM filesystem)
  • The kernel command line
  • UEFI stub (for direct UEFI booting)
  • Optional secure boot signatures

UKIs simplify the boot process by bundling everything needed into one file, making it easier to manage and sign for Secure Boot compatibility.

Generating UKIs

Arch linux mkinitcpio will assemble the UKI itself unless systemd-ukify is installed.

Using mkinitcpio

mkinitcpio preset file for the linux package at /etc/mkinitcpio.d/linux.preset

ESP_DIR="/efi/EFI/ArchLinux"

ALL_kver="/boot/vmlinuz-linux${SUFFIX}"

PRESETS=('default') # this is not for a fallback

default_image="/boot/initramfs-linux${SUFFIX}.img"
default_uki="${ESP_DIR}/arch-linux${SUFFIX}.efi"
default_options="--cmdline /etc/kernel/cmdline"

This code can be helpfull when creating a template i.e. for linux-lts e.g. in /etc/mkinitcpio.d/linux-lts.preset

SUFFIX="-lts"
source /etc/mkinitcpio.d/linux.preset

Kernel command line

mkinitcpio supports reading kernel parameters from command line files in the /etc/cmdline.d directory. mkinitcpio will concatenate the contents of all files with a .conf extension in this directory and use them to generate the kernel command line. Or /etc/kernel/cmdline can also be used as illustrated in above code.

rd.luks.name=fe30dd04-9v8a-4817-q10e-0999ece7oo31=archlinux root=/dev/mapper/archlinux rootflags=noatime,ssd,compress=zstd:1,space_cache=v2,discard=async,subvol=@ rw quiet splash loglevel=3 systemd.show_status=auto rd.udev.log_level=3

Additional info

mkinitcpio.conf contains hooks e.g.

HOOKS=(base systemd plymouth autodetect microcode modconf kms keyboard sd-vconsole block sd-encrypt filesystems fsck)

Note

Please give a proper read unified_kernel_image and mkinitcpio.

Configure Mkinitcpio With Kernel Parameters

It uses default_options="--cmdline /etc/kernel/cmdline". If you are using a single uefi binary file to load your system without any bootloader. This option will generate binary with kernel parameters. This will be helpfull if you are using btrfs with luks and swap is enabled on a laptop with suspend-then-hibernate from systemd.

My /etc/kernel/cmdline contains

root=/dev/mapper/cryptroot
resume=UUID=XxXxxxXX-xxxx-Xxxx-xXXx-xxxXxxXXxXXX
resume_offset=nnnnNNNN rw rootflags=subvol=@ rootfstype=btrfs

If you are using luks and want to pass discard parameter to kernel on boot. You should put it in cryptab or crypttab.initramfs. Offset can be obtained by running

# btrfs inspect-internal map-swapfile -r swap_file

You can verify parameters from /proc/cmdline after booting.

Crypttab And Crypttabinitramfs

Crypttab

The four fields of /etc/crypttab are defined as follows:

  • The first field contains the name of the resulting volume with decrypted data; its block device is set up below /dev/mapper/.
  • The second field contains a path to the underlying block device or file, or a specification of a block device via "UUID=" followed by the device UUID.
  • The third field specifies an absolute path to a file with the encryption key. Optionally, the path may be followed by “:” and an /etc/fstab style device specification (e.g. starting with "LABEL=" or similar); in which case the path is taken relative to the specified device’s file system root. If the field is not present or is "none" or "-", a key file named after the volume to unlock (i.e. the first column of the line), suffixed with .key is automatically loaded from the /etc/cryptsetup-keys.d/ and /run/cryptsetup-keys.d/ directories, if present. Otherwise, the password has to be manually entered during system boot. For swap encryption, /dev/urandom may be used as key file, resulting in a randomized key.
  • If the specified key file path refers to an AF_UNIX stream socket in the file system, the key is acquired by connecting to the socket and reading it from the connection. This allows the implementation of a service to provide key information dynamically, at the moment when it is needed.

Crypttab.initramfs

  • It is same as crypttab but it is used for mainly root partition to decrypt

td;lr

crypttab is for encrypted partitions other than root. For root use crypttab.initramfs.

QXL With Wayland And 4K Resolution

The default memory limit for the QXL video card is very conservative. If you’re running FullHD or higher resolution it is adviced to increase the memory by editing the xml.

Behaviour

  • Frozen screen

QXL Configuration Guide

Windows Guest

  • vgamem = (width * height * 4) / 1024
  • ram = 4 * vgamem
  • vram: Unimportant (e.g., 8 MB)

Modern Linux Guest (KMS driver)

  • vgamem = (width * height * 4 * heads) / 1024
    • Heads = number of screens
    • Wayland: Double the result
    • Round up to nearest power of 2 if using Virt-Manager
  • ram = 4 * vgamem
  • vram >= vgamem * 2

Key Notes

  • Wayland Warning: Avoid in VMs—poor performance (stuttering, low FPS). Use X11 for guests.
  • Max Resolution:
    • X11: 2560x1600 (optimal performance at ≤1080p)
    • Higher resolutions may impact performance.

Example Configs

4K (3840x2160) - Wayland Guest

<video>
  <model type="qxl" ram="524288" vram="262144" vgamem="131072" heads="1" primary="yes"/>
  <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/>
</video>

4k (3840x2160) - X11 Guest

<video>
  <model type="qxl" ram="131072" vram="65536" vgamem="32768" heads="1" primary="yes"/>
  <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/>
</video>

Additional Advice

  • Avoid excessive memory allocation—wastes RAM without performance gains.
  • Screen arrangement impacts memory needs (e.g., compact vs. diagonal layouts).

Using Wayland With Nvidia Drivers

Wayland does not play well with proprietary drivers especially with Nvidia. But some time installing Nvidia drivers to use with Evonycontrol, which is way better than any Nvidia Optimus System Managers. If you are using Gnome, it will automatically disable Wayland upon first install. But with Linux, there is always way around. First of all, edit /etc/gdm/custom.conf and see and comment out the line containing WaylandEnable=false. This file should look like after editing

# GDM configuration storage daemon
# Uncomment the line below to force the login screen to use Xorg
#WaylandEnable=false

Edit /usr/lib/udev/rules.d/61-gdm.rules and comment out below two lines. This is the only case in my experience.

LABEL="gdm_prefer_xorg"
# RUN+="/usr/lib/gdm-runtime-config set daemon PreferredDisplayServer xorg"
GOTO="gdm_end"

LABEL="gdm_disable_wayland"
# RUN+="/usr/lib/gdm-runtime-config set daemon WaylandEnable false"
GOTO="gdm_end"

kms-modifiers must be enabled through gsettings. Try the following command

gsettings set org.gnome.mutter experimental-features '["kms-modifiers"]

Enable modesetting for nvdia drivers. Follow the Arch Wiki Instructions. Also make sure to double check xorg-xwayland and egl-wayland are installed. The most important thing, Reboot. Congratulations, Gnome is running with Wayland despite Nvidia drivers. This will only work for arch linux. I have not tried it on any other Linux.