Kernel/Command-line parameters

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

This article mentions some of more commonly useful tuning knobs which can be passed to the Linux kernel at boot time. These are defined by upstream as "command-line parameters".

Configuration

Available options

A full list of parameters for the latest Linux kernel is provided at: https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html

Linux kernel commandline options
Parameter Options Notes
debug= N/A Enable kernel debug events.
mitigations off, auto (default option), auto,nosmt Disables or adjusts protections against known CPU vulnerabilities, but can provide speed improvements for certain CPUs or systems when trading security for speed is desired.
loglevel= 0 (lowest output), 1, 2, 3, 4, 5, 6, 7, 8 (highest output) Useful for adjusting the kernel's ring buffer output verbosity. The higher the number, the greater the verbosity. Be careful, high levels of verbosity can quickly consume high amounts of disk space!
root= PARTUUID="<UUID>", PARTLABEL="<label_name>", /dev/sda, /dev/sda1, etc. A block device specifier can be passed via this parameter such as a UUID of a device partition label (PARTUUID="<UUID>"), a partition label (PARTLABEL="<label_name>"), a device number of a disk (/dev/<disk_name>), a device number of a partition (/dev/<disk_name><decimal>), etc. See the full list here.
Note
Using UUID="<UUID>" is not supported by the kernel.
rootdelay= N (where N is an integer number) A delay in seconds the kernel should wait before attempting to mount the rootfs. Adding a delay here can be very useful for an uncommonly slow drive, like when running the rootfs off a USB drive.
earlyprintk= vga, sclp, serial[,ttySn[,baudrate]], Provides an alternate output location for the kernel's printk messages. Useful in the event at the main display crashes before any kernel messages can be read from the output.
module_blacklist= <module_name>, <module_name_2>, etc. A comma separated list of module names to block from loading during the kernel boot process. Useful if a certain module is causing a problem; such as accidentally loading a debug kernel module with spews millions of messages into the printk output, therefore making information difficult to find.
nomodule N/A An option to prevent all modules from loading during the kernel boot process.

Passing parameters to the kernel

There are different ways to pass parameters to the kernel. The Kconfig option is suitable for those who manually configure and compile the kernel. The UEFI variant can be used with a kernel distributed in binary form, but is only suitable for UEFI systems. The Bootloaders option is non-deterministic and depends on the bootloader.

Kconfig (AMD64)

For the x86 architecture, the parameters can be set via menuconfig as follows:

KERNEL AMD64
Processor type and features  --->
    [*] Built-in kernel command line
    () Built-in kernel command string

Or by directly specifying the corresponding settings:

FILE .config
CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE=""

Kconfig (ARM64)

For the ARM architecture, the parameters can be set via menuconfig as follows:

KERNEL ARM64
Boot options  --->
    () Default kernel command string

Or by directly specifying the corresponding setting:

FILE .config
CONFIG_CMDLINE=""

UEFI

The kernel parameters can be written into UEFI entries, for example by using the --unicode argument of the efibootmgr program. See this article for more information.

Bootloaders

Each bootloader has its own way of passing parameters to the kernel. The most popular bootloaders and their options are presented below.

GRUB
Note
Don't forget to run update-grub afterwards.

The kernel parameters can be set via the GRUB setting GRUB_CMDLINE_LINUX. See this article for more information.

LILO

See this article to pass the kernel parameters via LILO.

systemd-boot

The kernel parameters can be set via the options setting. See this article for more information.

Usage

Current boot parameters

Command-line parameters for the currently running kernel are exposed via the proc API at /proc/cmdline:

user $cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-6.3.3-gentoo-x86_64 ro init=/usr/lib/systemd/systemd pcie_aspm=off pcie_port_pm=off pcie_pme=nomsi iommu=1 amd_iommu=on

See also

  • Kernel — the core of the operating system.