Talk:Dracut

From ArchWiki
Latest comment: 10 February by Dngray in topic Unified kernel image

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)Reply[reply]

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)Reply[reply]
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)Reply[reply]

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)Reply[reply]

/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)Reply[reply]
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)Reply[reply]
This old version [1] 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)Reply[reply]
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)Reply[reply]
In my opinion this article needs a cleanup. We should be instructing users to use systemd-ukify and the dracut-ukifyAUR method. I would like to see the removal of all those unmaintained hooks in AUR. I added this portion to try to tidy things up. Dngray (talk) 17:24, 18 December 2023 (UTC)Reply[reply]
Is there a change for you to add more specific instruction on using dracut-ukify?
It does not seem to useuefi_secureboot_cert nor uefi_secureboot_key, or any dracut conf files for that matter.
I'd like to RTFM, but I cannot find anything useful on that topic. I'm trying to figure this out as of right now but with no luck. Anonymous badger (talk) 20:01, 9 February 2024 (UTC)Reply[reply]
I can see you set your parameters in there, see Add global ukify flags to each invocation. See '/usr/lib/systemd/ukify --help' for an available flags
/etc/dracut-ukify.conf
::::::ukify_global_args+=(--cmdline "rw rd.auto=1 rd.luksoptions=discard
::::::root=UUID=cd7419c4-3564-4d0c-8bcb-993c185b2174
::::::resume=UUID=cd7419c4-3564-4d0c-8bcb-993c185b2174
::::::rootflags=subvol=@
::::::rd.luks.uuid=7fa03f88-af92-44e3-a356-174656056d6f")
Unfortunately when running sudo dracut-ukify -g linux I get "unpacking falied: invalid magic at start of compressed archive". Also mentioned in this forum thread https://bbs.archlinux.org/viewtopic.php?pid=2147149 I haven't yet found a solution however, but we should find out what is wrong because systemd-ukify is not going away. Dngray (talk) 10:19, 10 February 2024 (UTC)Reply[reply]

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)Reply[reply]

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)Reply[reply]

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)Reply[reply]