View previous topic :: View next topic |
Author |
Message |
nagmat84 Guru

Joined: 27 Mar 2007 Posts: 307
|
Posted: Sun May 05, 2024 6:54 am Post subject: Kernel cmd iine by boot manager vs. Dracut initramfs |
|
|
What is the difference between the kernel command line which the boot manager passes to the kernel and the command line which Dracut writes to the initramfs? Must both command lines be set? If yes, must both command lines be identical and each needs all options? Or does each command line only support a subset of the available options? Which tools use which command iine?
Currently, I am using rEFInd as my boot manager for UEFI boot. The Linux kernel is compiled with EFI-stub support and invoked as an EFI executable. I use the initramfs mostly to make firmware for AMDGPU early available during the boot process and due to the Root FS being encrypted with LUKS. The rEFInd boot manager, the Linux kernel and the initramfs reside (unencrypted) on the ESP.
Currently, I try to manually keep the kernel command line which rEFInd passes to the Linux kernel and the kernel command line which Dractut save inside the initramfs identical. However, this is error-prone and cumbersome. Hence, I am wondering if actually both are necessary. In particular, rEFInd invokes the kernel first with a path to the initramfs. Hence, I assume the Kernel command line is already available to the kernel before the initramfs is even loaded. Is it really necessary, to save the Kernel command line a second time inside the initramfs?
The kernel command line passed by rEFInd to the kernel: Code: | ro root=UUID=<UUID of decrypted root FS> resume=UUID=<UUID of swap partition> rootfstype=ext4 rd.luks.uuid=<UUID of encrypted root partition> rd.luks.allow-discards rd.vconsole.font=eurlatgr rd.vconsole.keymap=de-latin1 rd.locale.LANG=de_DE.UTF-8 initrd=EFI/Gentoo/intel-uc.img initrd=EFI/Gentoo/initramfs-%v-signed.img init=/usr/lib/systemd/systemd random.trust_cpu=on udev.log_priority=2 splash quiet loglevel=2 | The command for Dracut Code: | --kernel-cmdline 'init=/usr/lib/systemd/systemd root=UUID=<UUID of decrypted root FS> rootfstype=ext4 resume=UUID=<UUID of swap partition> random.trust_cpu=on rd.luks.uuid=<UUID of encrypted root partition> rd.luks.allow-discards rd.vconsole.font=eurlatgr rd.vconsole.keymap=de-latin1 rd.locale.LANG=de_DE.UTF-8' |
|
|
Back to top |
|
 |
pietinger Moderator

Joined: 17 Oct 2006 Posts: 5621 Location: Bavaria
|
Posted: Sun May 05, 2024 3:09 pm Post subject: Re: Kernel cmd iine by boot manager vs. Dracut initramfs |
|
|
nagmat84 wrote: | Must both command lines be set? |
No.
nagmat84 wrote: | What is the difference between the kernel command line which the boot manager passes to the kernel and the command line which Dracut writes to the initramfs? |
Different places. (*)
You can even set one option in your kernel command line and another option via a bootmanager ... and kernel use both. You have in your dmesg two different lines where you can see which option comes from:
Code: | [ 0.000000] Command line: BOOT_IMAGE=/@/boot/vmlinuz-6.6.13-gentoo-x86_64 root=UUID=b9fc82e1-4a25-41d5-b151-f485705e3058 ro
...
[ 0.044125] Kernel command line: BOOT_IMAGE=/@/boot/vmlinuz-6.6.13-gentoo-x86_64 root=UUID=b9fc82e1-4a25-41d5-b151-f485705e3058 ro |
In the first line you will see all options coming from UEFI or a bootmanager; in the second line you see all aggregated options. (My first line is empty because I am using only built-in command line options and start my kernel directly via UEFI).
*) You can use these different places for more security: You can set all options built-in and configure your kernel so its doesnt accept any more options from UEFI or bootloader/bootmanger. See more here: https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Kernel_Commandline_Parameter _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
 |
nagmat84 Guru

Joined: 27 Mar 2007 Posts: 307
|
Posted: Sun May 05, 2024 3:43 pm Post subject: |
|
|
This means, I am basically free to decide where I put which option, right?
Of course, options which must be set before the initramfs is loaded must be set via the boot manager (or be compiled into the kernel), such as the path to the initramfs itself. Besides that, there is no real difference, right? Hence, setting all options in a single place and as early as possible, is probably the prefered way.
Assume I set the same option twice, but with contradictory values. Which setting takes precedence? The earlier or the later setting? |
|
Back to top |
|
 |
pietinger Moderator

Joined: 17 Oct 2006 Posts: 5621 Location: Bavaria
|
Posted: Sun May 05, 2024 4:23 pm Post subject: |
|
|
nagmat84 wrote: | This means, I am basically free to decide where I put which option, right? |
Yes.
nagmat84 wrote: | Of course, options which must be set before the initramfs is loaded must be set via the boot manager (or be compiled into the kernel), such as the path to the initramfs itself. Besides that, there is no real difference, right? |
This is true only for the option "initrd=" which must be set in UEFI or bootmanager/bootloader.
nagmat84 wrote: | Hence, setting all options in a single place and as early as possible, is probably the prefered way. |
No, it doesn't matter when options are set
nagmat84 wrote: | Assume I set the same option twice, but with contradictory values. Which setting takes precedence? The earlier or the later setting? |
Every setting from UEFI or bootmanager/bootloader takes precedence ... unless you activate CONFIG_CMDLINE_OVERRIDE=y _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|