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:

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)

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:

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

Parameter: 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.

By the way: The same is true for your /etc/fstab. I recommend to label your partitions if you have a GPT disk. I did this with:

root #parted /dev/sda name 1 Boot

and now I use these:

FILE /etc/fstab
PARTLABEL=Boot          /boot           vfat    defaults,noauto,noatime                 1 2
PARTLABEL=Root          /               ext4    defaults,noatime,iversion               0 1
PARTLABEL=Swap          none            swap    sw                                      0 0

Of course you can use also "PARTUUID=" or "UUID=", but dont use "LABEL=" for a GPT disk. See more here: fstab#UUIDs_and_labels

Parameter: quiet

With this command line parameter you can suppress most output of your kernel when booting. If you still see some warnings and think this parameter does not work then read this kernel bug report: