User:Pietinger/Tutorials/Kernel Commandline Parameter

From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.

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):

KERNEL
Processor type and features  --->
    [*] Built-in kernel command line
    (root=/dev/sda2 ro)

Using grub

Edit in /etc/default/grub the variable GRUB_CMDLINE_LINUX. See more here: GRUB#Setting_configuration_parameters

Using UEFI

Configure your UEFI boot entry with additional options when creating this entry (EXAMPLE]:

root #efibootmgr -c -d /dev/sda -p 2 -L "Gentoo" -l '\efi\gentoo\bzImage.efi' -u 'root=/dev/sda2'

See more here: Efibootmgr#Creating_a_boot_entry and here: EFI_stub#Troubleshooting

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:

KERNEL
Processor type and features  --->
    [*]     Built-in command line overrides boot loader arguments

Paramter: root=

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.