building an Unified Kernel Image with dracut

created onJanuary 14, 2026

dracut is usually used as a low-level tool for generating an initramfs/initrd, but can as well be used to build an UEFI image that can be executed by an UEFI firmware. To build a Unified Kernel Image with dracut, you need:

  • a kernel image – by default, dracut detects and uses the kernel currently running, but you can also specify the kernel image to use in dracut’ config.
  • an UEFI stub – if you don’t know where to get an UEFI stub, you can check here.

Of course, you can add optional resources like a boot splash image.

create a dracut uki config file

I use the file . usually doesn’t exist, so the dracut uki config in there can’t clash with the system’s dracut config.

Start the file with the following content:

uefi=yes # create no initramfs image, but an UEFI image, executable by an UEFI firmware. uefi_stub=<path/to/uefi/stub> # usual file suffix is '.stub' kernel_image=<path/to/kernel image> # optional. If not specified, dracut uses the image of the kernel currently running.

add stuff from the system’s dracut config

dracut’s config is most likely in and/or in files in . Check the config files, they most likely list stuff that you need in your kernel. I.e., I have the following file :

add_drivers+=" nvidia nvidia_modeset nvidia_uvm nvidia_drm "

Add what you need from the system’s dracut config to your dracut uki config file.

add the kernel commandline to the config file

Run . The output on my machine is:

root@idoru:/$ cat /proc/cmdline | sed 's/^\| /\n /'g root=/dev/nvme0n1p5 net.ifnames=0 initrd=boot\initramfs-6.12.34_1.img

Add the kernel parameters to the dracut file like this:

cmdline=( root=/dev/nvme0n1p5 net.ifnames=0 initrd=boot\initramfs-6.12.34_1.img ) kernel_cmdline="${cmdline[*]}" # prints kernel parameters in a single line, separated by space unset cmdline

You could as well just dump the output of right into your dracut uki config file, but the extra step with the variable in the uki config file makes the kernel params more readable if you check or revise the config file later.

optional config

listing included modules during build

If you want to see which drivers and modules are added to the image during the build of the UEFI image, add the following to the dracut uki config:

show_modules=yes # list names of included modules to stdout during build

config for smaller image size

For a smaller UEFI image size, add the following code snippet to the uki config file:

do_strip=yes # needed for directive 'aggressive_strip' below aggressive_strip=yes # strips more than just debug symbol and sections, for a smaller image build. hostonly=yes # install only what is needed for booting the local host instead of a generic host hostonly_mode=sloppy # install some extra drivers and modules, so image is still bootable with minor hardware change # 'strict' is more aggressive, minor changes in hardware or environment can make the image unbootable

adding a splash image

Add the following code snippet to the uki config file to specify the UEFI stub loader’s splash image:

uefi_splash_image="<image file>"

The splash image must be in bitmap image format ()

building the UKI with dracut

Finally, run dracut to build the UEFI image. If you didn’t specify the kernel image file in the dracut uki config with , dracut uses the image of the kernel currently running, and you get the kernel version with

dracut --force --verbose --kver $(uname -r) --conf /etc/uefi/dracut.conf vmlinuz-$(uname -r).efi

However, if you specified the kernel image file in the dracut uki config with you have to supply the kernel version by hand:

kversion="6.12.34_1"; dracut --force --verbose --kver ${kversion} --conf /etc/uefi/dracut.conf vmlinuz-${kversion}.efi
When running dracut with , especially with , including the machine name into the file name of the resulting image is probably a good idea.

reference

  • dracut man page
  • dracut.conf man page
x