User:Pietinger/Tutorials/Kernel Commandline Parameter
Tutorial: Kernel Commandline Parameter
This is a short overview how you can give your kernel some parameters. Main difference is how you boot your kernel: Using a bootmanager (like grub) or using UEFI (booting a stub kernel directly).
A list of all possible parameters kernel will understand is here: https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
What always work
Independent how you boot your kernel you can always "hardcode" needed parameters into your kernel directly with (EXAMPLE):
Processor type and features ---> [*] Built-in kernel command line (root=/dev/sda2 ro)
Edit in /etc/default/grub the variable GRUB_CMDLINE_LINUX. See more here: GRUB#Setting_configuration_parameters
Configure your UEFI boot entry with additional options when creating this entry (EXAMPLE]:
efibootmgr -c -d /dev/sda -p 2 -L "Gentoo" -l '\efi\gentoo\bzImage.efi' -u 'root=/dev/sda2'
Can I mix it ?
Yes, you can give your kernel some parameters via built-in command line and some more via grub or UEFI. Kernel will put both informations together (at boot-time). But it is not recommended. Maybe there exists some special constellations where you need it. If you dont want that your bootmanager or UEFI will add (or even override) your built-in commandline parameters (for security reasons) you must enable this:
Processor type and features ---> [*] Built-in command line overrides boot loader arguments
Why it is not recommended to use root=/dev/sdXY ?
Because it could confuse your kernel. This can happen if you have two (or more) hard disks in your system. Then it could be that sometimes your 2nd harddisk becomes /dev/sda and your first harddisk is /dev/sdb and then kernel will not find its root partition on /dev/sda2 because this is now the 2nd partiton of your 2nd harddisk. Another problem can occure if you have an USB-stick attached to your system when booting. Here it is also possible your harddisk becomes /dev/sdb instead /dev/sda.
So I should always use root=PARTUUID=... ?
Yes, it is better (more safe), BUT there is one exception: If you use an initramfs it could be you must use root=UUID=... instead. Of course then you must use the real UUID and not the PARTUUID. Just ask for it with blkid.