Talk:Dracut

From ArchWiki

Early microcode loading for Intel CPUs

Currently, it seems that dracut does not recognize the Arch way of shipping Intel microcode. It expects microcode in their original format, rather than processed by iucode-tools. See the filelist: https://fedora.pkgs.org/31/fedora-x86_64/microcode_ctl-2.1-32.fc31.x86_64.rpm.html Hexchain (talk) 15:51, 21 December 2019 (UTC)

What do you mean by 'expects microcode in original format' and 'processed by icode-tools'? I use dracut for several months and have no issue with intel-ucode. Providing 'intel-ucode.img' to 'initrd' command (in grub) seems to be sufficient ('kernel: microcode: microcode updated early to revision 0x2f, date = 2019-02-17'). Mxfm (talk) 05:14, 23 December 2019 (UTC)
dracut has an early-microcode option to package microcode directly into initrd, without the need to load another initrd. This can be useful with --uefi, which packages kernel + initramfs + cmdline into one single UEFI application for EFISTUB (especially on some broken firmware that does not recognize UEFI cmdline parameters, like the Dell XPS 9360 ones), or secure boot. dracut looks for microcode under /lib/firmware/intel-ucode and expects them to be in their original form (See [1]). The current intel-ucode package already packaged all microcode files into one single initrd with iucode-tools, which is not supported by this specific dracut feature. Hexchain (talk) 10:00, 23 December 2019 (UTC)
I see. Perhaps file a bug report? Mxfm (talk) 15:55, 25 December 2019 (UTC)
I have opened a feature request. -FS#65475 Neurognostic (talk) 01:46, 13 February 2020 (UTC)
It appears dracut now supports the /boot/*.img scheme for microcode natively. - https://github.com/dracutdevs/dracut/pull/699 - Neurognostic (talk) 04:09, 13 February 2020 (UTC)
As both FS#65475 and https://github.com/dracutdevs/dracut/pull/699 are done long time ago, I think we can close the discussion as the feature is already implemented. Stanislav.S (talk) 10:07, 17 April 2023 (UTC)

What is the reason for --no-hostonly-cmdline?

What is the reasoning behind including the option --no-hostonly-cmdline in the example dracut-install.sh script?

Is it to encourage the user to configure the kernel command line from the bootloader configuration rather than embedding in the initcpio? - Neurognostic (talk) 04:33, 5 February 2020 (UTC)

This might be a good question to ask grazzolini on IRC; he gave me the script to post. You can see it in this commit: "Add grazzolini's draft dracut script" https://wiki.archlinux.org/index.php?title=User:Krathalan&diff=prev&oldid=586226 Krathalan (talk) 16:06, 5 February 2020 (UTC)
I found out that if you do not use --no-hostonly-cmdline then dracut(8) may duplicate some kernel parameters, such as automatically create rd.luks.uuid=<UUID> in etc/cmdline.d/90crypt.conf on the initramfs; when, in fact, they are already specified elsewhere (e.g. in dracut.conf(5) as the kernel_cmdline option or the kernel parameters defined in the boot loader configuration). - Neurognostic (talk) 04:31, 15 February 2020 (UTC)

Unified kernel image

The --uefi option seems to successfully create a unified kernel image, but I can't figure out a sane way to set kernel parameters. Presumably they should be set in /etc/cmdline.d/, but I can't get it to work.

  • Without any options in /etc/dracut.conf.d/*.conf the unified kernel image does not have any kernel parameters. In simple setups booting is still possible thanks to systemd-gpt-auto-generator.
  • With hostonly="yes" in /etc/dracut.conf.d/*.conf the unified kernel image contains some sort of autodetected kernel parameters and the resulting binary only contains the modules for the running system.

Below are the pacman hooks which I'm using.

-- nl6720 (talk) 12:35, 30 March 2020 (UTC)

/etc/cmdline.d is relative to the initdir and needs to be copied into into it first, e.g. via --install. dracut then showed the proper cmdline in its output, at least when i used --hostonly-cmdline. I haven't yet managed to get it to boot, though.
--Lobachevsky (talk) 17:51, 29 May 2020 (UTC)
Update: The problem was me trying to use zstd as compression, which did not work, but xz does. I haven't tested without --hostonly-cmdline yet, but the combinations --hostonly-cmdline --install /etc/cmdline.d/mycmdline.conf produced a bootable UEFI binary.
Lobachevsky (talk) 15:05, 1 June 2020 (UTC)
This old version [2] has a working version that integrates with kernel-install, which is how systemd imagines kernels do be installed. It's also natively supported my dracut (for non-unified kernels) and mkinitcpio, so lends itself excellently to usage in a hook. The kernel-install script uses the same mechanism the scripts provided by dracut would use to get the kernel cmdline /etc/kernel/cmdline.
Lobachevsky (talk) 12:04, 10 August 2020 (UTC)
The kernel_cmdline config entry works as expected, I have successfully used it to mount a root partition that lives on a mdadm raid 0 array, with luks2, and btrfs. And it successfully worked with my tpm2 unlocked btrfs-on-luks2 root filesystem on my laptop. This issue is fixed. Otherwise feel free to answer me so we figure out the correct way and update the wiki.
Adelks (talk) 16:08, 12 August 2022 (UTC)

Unified kernel image hooks

/etc/pacman.d/hooks/90-dracut-install-uki.hook
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = usr/lib/modules/*/pkgbase

[Action]
Description = Generating unified kernel images (with dracut!)...
When = PostTransaction
Exec = /usr/local/bin/dracut-install-uki.sh
NeedsTargets
/usr/local/bin/dracut-install-uki.sh
#!/usr/bin/env bash

ESP_MOUNTPOINT="esp"

[[ ! -e "${ESP_MOUNTPOINT}/EFI/Linux" ]] && mkdir -p -- "${ESP_MOUNTPOINT}/EFI/Linux"

while read -r package_file_path_line; do
	if [[ "$package_file_path_line" == 'usr/lib/modules/'+([^/])'/pkgbase' ]]; then
		read -r pkgbase < "/${package_file_path_line}"
		kver="${package_file_path_line#'usr/lib/modules/'}"
		kver="${kver%'/pkgbase'}"

		dracut --force --uefi --uefi-stub /usr/lib/systemd/boot/efi/linuxx64.efi.stub "${ESP_MOUNTPOINT}/EFI/Linux/Arch-${pkgbase}.efi" --kver "$kver"
	fi
done

dracut.cmdline and LVM on LUKS

It seems that setting kernel command line arguments in /etc/cmdline.d/ has no effect if the root partition is encrypted.

Perhaps these files would normally be parsed while booting before mounting the rootfs.

Summerer (talk) 09:25, 18 April 2020 (UTC)

No, these files need to be included into the initrd, dracut will not add them by itself, since initrd/etc/cmdline.d is dracut's own mechanism to get cmdline arguments in order. Lobachevsky (talk) 11:55, 10 August 2020 (UTC)

Recommend rebuild-initramfs-dracutAUR?

Disclosure: I'm the author of this package.

Unlike mkinitcpio which has -P and -p, in dracut you'd have to type the command by hand. I wrote a script to fix this situation and have put it on the AUR after having used it personally for some time: rebuild-initramfs-dracutAUR.

I'm certainly biased, but I think it wouldn't be a bad idea to mention this on the Wiki page as a "replacement" for mkinitcpio -P. Xuanruiqi (talk) 23:42, 4 June 2020 (UTC)