Difference between revisions of "Kernel parameters"

From ArchWiki
Jump to: navigation, search
m (removed a gap from the beginning of the article)
m (rEFInd: typo)
 
(46 intermediate revisions by 20 users not shown)
Line 1: Line 1:
 
[[Category:Kernel]]
 
[[Category:Kernel]]
[[en:Kernel parameters]]
 
 
[[es:Kernel parameters]]
 
[[es:Kernel parameters]]
[[ja:Kernel parameters]]
+
[[ja:カーネルパラメータ]]
 +
[[ru:Kernel parameters]]
 
[[zh-CN:Kernel parameters]]
 
[[zh-CN:Kernel parameters]]
 
There are three ways to pass options to the kernel and thus control its behaviour:
 
There are three ways to pass options to the kernel and thus control its behaviour:
  
# When building the kernel.
+
# When building the kernel. See [[Kernel Compilation]] for details.
 
# When starting the kernel (usually, when invoked from a boot loader).
 
# When starting the kernel (usually, when invoked from a boot loader).
# At runtime (through the files in {{ic|/proc}} and {{ic|/sys}}).
+
# At runtime (through the files in {{ic|/proc}} and {{ic|/sys}}). See [[sysctl]] for details.
  
 
This page now explains in more detail the second method and shows a list of most used kernel parameters in Arch Linux.
 
This page now explains in more detail the second method and shows a list of most used kernel parameters in Arch Linux.
  
 
== Configuration ==
 
== Configuration ==
 +
 +
{{Note|
 +
* You can check the parameters your system was booted up with by running {{ic|$ cat /proc/cmdline}} and see if it includes your changes.
 +
* The Arch Linux [https://www.archlinux.org/download/ installation medium] uses [[Syslinux]] for [[Wikipedia:BIOS|BIOS]] systems, and [[systemd-boot]] for [[UEFI]] systems.}}
  
 
Kernel parameters can be set either temporarily by editing the boot menu when it shows up, or by modifying the boot loader's configuration file.
 
Kernel parameters can be set either temporarily by editing the boot menu when it shows up, or by modifying the boot loader's configuration file.
  
Here we are adding the parameters {{ic|quiet}} and {{ic|splash}} to [[Syslinux]], [[GRUB]], [[GRUB Legacy]] and [[LILO]].
+
The following examples add the {{ic|quiet}} and {{ic|splash}} parameters to [[Syslinux]], [[systemd-boot]], [[GRUB]], [[GRUB Legacy]], [[LILO]], and [[rEFInd]].
  
==== Syslinux ====
+
=== Syslinux ===
  
* Press {{Keypress|Tab}} when the menu shows up and add them at the end of the string:
+
* Press {{ic|Tab}} when the menu shows up and add them at the end of the string:
  
: {{bc|1=> .linux ../vmlinuz-linux root=/dev/sda3 ro initrd=../initramfs-linux.img ''quiet splash''}}
+
: {{bc|1=linux /boot/vmlinuz-linux root=/dev/sda3 initrd=/boot/initramfs-linux.img ''quiet splash''}}
  
: Press {{Keypress|Enter}} to boot with these parameters.
+
: Press {{ic|Enter}} to boot with these parameters.
  
 
* To make the change persistent after reboot, edit {{ic|/boot/syslinux/syslinux.cfg}} and add them to the {{ic|APPEND}} line:
 
* To make the change persistent after reboot, edit {{ic|/boot/syslinux/syslinux.cfg}} and add them to the {{ic|APPEND}} line:
  
: {{bc|1=APPEND root=/dev/sda3 ro ''quiet splash''}}
+
: {{bc|1=APPEND root=/dev/sda3 ''quiet splash''}}
  
 
For more information on configuring Syslinux, see the [[Syslinux]] article.
 
For more information on configuring Syslinux, see the [[Syslinux]] article.
  
==== GRUB ====
+
=== systemd-boot ===
  
* Press {{Keypress|e}} when the menu shows up and add them on the {{ic|linux}} line:
+
* Press {{ic|e}} when the menu appears and add the parameters to the end of the string:
  
: {{bc|1=linux  /boot/vmlinuz-linux root=UUID=978e3e81-8048-4ae1-8a06-aa727458e8ff ro  ''quiet splash''}}
+
: {{bc|1=initrd=\initramfs-linux.img root=/dev/sda2 ''quiet splash''}}
  
: Press {{Keypress|b}} to boot with these parameters.
+
: Press {{ic|Enter}} to boot with these parameters.
  
* To make the change persistent after reboot, while you ''could'' manually edit {{ic|/boot/grub/grub.cfg}} with the exact line from above, for beginners it's recommended to:
+
{{Note|If you have not set a value for menu timeout, you will need to hold {{ic|Space}} while booting for the systemd-boot menu to appear.}}
 +
 
 +
* To make the change persistent after reboot, edit {{ic|/boot/loader/entries/arch.conf}} (assuming you set up your [[Unified Extensible Firmware Interface#EFI System Partition|EFI System Partition]] and configuration files according to the instructions in the [[Beginners' guide#UEFI_motherboards|Beginners' Guide]]) and add them to the {{ic|options}} line:
 +
 
 +
: {{bc|1=options root=/dev/sda2 ''quiet splash''}}
 +
 
 +
For more information on configuring systemd-boot, see the [[systemd-boot]] article.
 +
 
 +
=== GRUB ===
 +
 
 +
* Press {{ic|e}} when the menu shows up and add them on the {{ic|linux}} line:
 +
 
 +
: {{bc|1=linux /boot/vmlinuz-linux root=UUID=978e3e81-8048-4ae1-8a06-aa727458e8ff ''quiet splash''}}
 +
 
 +
: Press {{ic|b}} to boot with these parameters.
 +
 
 +
* To make the change persistent after reboot, while you ''could'' manually edit {{ic|/boot/grub/grub.cfg}} with the exact line from above, the best practice is to:
  
 
:Edit {{ic|/etc/default/grub}} and append your kernel options to the {{ic|GRUB_CMDLINE_LINUX_DEFAULT}} line:
 
:Edit {{ic|/etc/default/grub}} and append your kernel options to the {{ic|GRUB_CMDLINE_LINUX_DEFAULT}} line:
Line 52: Line 72:
 
For more information on configuring GRUB, see the [[GRUB]] article.
 
For more information on configuring GRUB, see the [[GRUB]] article.
  
==== GRUB Legacy ====
+
=== GRUB Legacy ===
  
* Press {{Keypress|e}} when the menu shows up and add them on the {{ic|kernel}} line:
+
* Press {{ic|e}} when the menu shows up and add them on the {{ic|kernel}} line:
  
: {{bc|1=kernel /boot/vmlinuz-linux root=/dev/sda3 ro ''quiet splash''}}
+
: {{bc|1=kernel /boot/vmlinuz-linux root=/dev/sda3 ''quiet splash''}}
  
: Press {{Keypress|b}} to boot with these parameters.
+
: Press {{ic|b}} to boot with these parameters.
  
 
* To make the change persistent after reboot, edit {{ic|/boot/grub/menu.lst}} and add them to the {{ic|kernel}} line, exactly like above.
 
* To make the change persistent after reboot, edit {{ic|/boot/grub/menu.lst}} and add them to the {{ic|kernel}} line, exactly like above.
Line 64: Line 84:
 
For more information on configuring GRUB Legacy, see the [[GRUB Legacy]] article.
 
For more information on configuring GRUB Legacy, see the [[GRUB Legacy]] article.
  
==== LILO ====
+
=== LILO ===
  
 
* Add them to {{ic|/etc/lilo.conf}}:
 
* Add them to {{ic|/etc/lilo.conf}}:
Line 75: Line 95:
 
For more information on configuring LILO, see the [[LILO]] article.
 
For more information on configuring LILO, see the [[LILO]] article.
  
== Parameters list ==
+
=== rEFInd ===
  
{{Expansion|The list needs more parameters.}}
+
* To make the change persistent after reboot, edit {{ic|/boot/EFI/arch/refind_linux.conf}} (ie. refind_linux.conf in the folder your kernel is located in) and append them to all/required lines, for example
 +
 
 +
: {{bc|1="Boot to X"  "root=PARTUUID=978e3e81-8048-4ae1-8a06-aa727458e8ff ''quiet splash''"}}
 +
 
 +
* If you have disabled auto-detection of OS's in rEFInd and are defining OS stanzas instead in {{ic|/boot/EFI/refind/refind.conf}} to load your OS's, you can edit it like:
 +
 
 +
: {{bc|<nowiki>
 +
menuentry "Arch" {
 +
loader /EFI/arch/vmlinuz-arch.efi
 +
options "root=PARTUUID=978e3e81-8048-4ae1-8a06-aa727458e8ff quiet splash"
 +
</nowiki>}}
 +
 
 +
For more information on configuring kernel parameters in rEFInd, see [http://www.rodsbooks.com/refind/linux.html Configuring the rEFInd Bootmanager]
 +
 
 +
=== EFISTUB/efibootmgr ===
 +
 
 +
See [[EFISTUB#Using UEFI directly (efibootmgr)]].
 +
 
 +
=== Hijacking cmdline ===
 +
 
 +
Even without access to your bootloader it is possible to change your kernel parameters to enable debugging (if you have root access). This can be accomplished by overwriting {{ic|/proc/cmdline}} which stores the kernel parameters. However {{ic|/proc/cmdline}} is not writable even as root, so this hack is accomplished by using a bind mount to mask the path.
 +
 
 +
First create a file containing the desired kernel parameters
 +
 
 +
{{hc|/root/cmdline|2=root=/dev/disk/by-label/ROOT ro console=tty1 logo.nologo debug}}
 +
 
 +
Then use a bind mount to overwrite the parameters
 +
 
 +
# mount -n --bind -o ro /root/cmdline /proc/cmdline
 +
 
 +
The {{ic|-n}} option skips adding the mount to {{ic|/etc/mtab}}, so it will work even if root is mounted read-only. You can {{ic|cat /proc/cmdline}} to confirm that your change was successful.
 +
 
 +
== Parameter list ==
 +
 
 +
Parameters always come in {{ic|parameter}} or {{ic|1=parameter=value}}. All of these parameters are case-sensitive.
  
 
{{Note|Not all of the listed options are always available. Most are associated with subsystems and work only if the kernel is configured with those subsystems built in. They also depend on the presence of the hardware they are associated with.}}
 
{{Note|Not all of the listed options are always available. Most are associated with subsystems and work only if the kernel is configured with those subsystems built in. They also depend on the presence of the hardware they are associated with.}}
  
{| border="1"
+
{| class="wikitable"
![[SysVinit]]!![[systemd]]!!Description
+
!parameter!!Description
 
|-
 
|-
| {{ic|3}} || {{ic|1=systemd.unit=multi-user}} || Boot to a specified runlevel (3, in this case). Works with 1-6.
+
| root= || Root filesystem.
 
|-
 
|-
| {{ic|1}}  || {{ic|1=systemd.unit=rescue}} || Boot to Single-user mode (root).
+
| ro || Mount root device read-only on boot (default<sup>1</sup>).
 
|-
 
|-
| {{ic|nomodeset}} || {{ic|nomodeset}} || Disable [[Kernel Mode Setting]].
+
| rw || Mount root device read-write on boot.
 
|-
 
|-
| {{ic|1=loglevel=3}} || {{ic|1=loglevel=3}} || Removes "misaligned reg" and "unknown connector type" messages during boot with the [[Nouveau]] driver. See [https://bbs.archlinux.org/viewtopic.php?id=137509 this] topic.
+
| initrd=|| Specify the location of the initial ramdisk.
 
|-
 
|-
| -- || {{ic|1=init=/usr/lib/systemd/systemd}} || Boot using [[Systemd#Installation|systemd]] instead of SysVinit.
+
| init= || Run specified binary instead of {{ic|/sbin/init}} (symlinked to [[systemd]] in Arch) as init process.
 
|-
 
|-
| {{ic|1=init=/bin/sh rw}}  || {{ic|1=init=/bin/sh rw}} || Boot to Shell.
+
| init=/bin/sh || Boot to shell.
 
+
|-
 +
| systemd.unit= ||
 +
|-
 +
| systemd.unit=multi-user || Boot to a specified runlevel.
 +
|-
 +
| systemd.unit=rescue || Boot to single-user mode (root).
 +
|-
 +
| nomodeset || Disable [[Kernel mode setting]].
 +
|-
 +
| zswap.enabled || Enable [[Zswap]].
 +
|-
 +
| video=<videosetting> || Override framebuffer video defaults.
 
|}
 
|}
  
All of these parameters are case-sensitive.
+
<sup>1</sup> [[mkinitcpio]] uses {{ic|ro}} as default value when neither {{ic|rw}} or {{ic|ro}} is set by the [[boot loader]]. Boot loaders may set the value to use, for example GRUB uses {{ic|rw}} by default (see {{Bug|36275}} as a reference).
  
For a complete list of all known options, please see the [https://www.kernel.org/doc/Documentation/kernel-parameters.txt kernel documentation].
+
For a complete list of all options, please see the [https://www.kernel.org/doc/Documentation/kernel-parameters.txt kernel documentation].
  
== See Also ==
+
== See also ==
  
* [[sysctl]]
+
* [https://www.kernel.org/doc/Documentation/kernel-parameters.txt Linux "Kernel Parameters" documentation]
 +
* [[Power saving#Kernel parameters]]
 
* [http://files.kroah.com/lkn/lkn_pdf/ch09.pdf List of kernel parameters with further explanation and grouped by similar options]
 
* [http://files.kroah.com/lkn/lkn_pdf/ch09.pdf List of kernel parameters with further explanation and grouped by similar options]

Latest revision as of 04:45, 15 February 2016

There are three ways to pass options to the kernel and thus control its behaviour:

  1. When building the kernel. See Kernel Compilation for details.
  2. When starting the kernel (usually, when invoked from a boot loader).
  3. At runtime (through the files in /proc and /sys). See sysctl for details.

This page now explains in more detail the second method and shows a list of most used kernel parameters in Arch Linux.

Configuration

Note:

Kernel parameters can be set either temporarily by editing the boot menu when it shows up, or by modifying the boot loader's configuration file.

The following examples add the quiet and splash parameters to Syslinux, systemd-boot, GRUB, GRUB Legacy, LILO, and rEFInd.

Syslinux

  • Press Tab when the menu shows up and add them at the end of the string:
linux /boot/vmlinuz-linux root=/dev/sda3 initrd=/boot/initramfs-linux.img quiet splash
Press Enter to boot with these parameters.
  • To make the change persistent after reboot, edit /boot/syslinux/syslinux.cfg and add them to the APPEND line:
APPEND root=/dev/sda3 quiet splash

For more information on configuring Syslinux, see the Syslinux article.

systemd-boot

  • Press e when the menu appears and add the parameters to the end of the string:
initrd=\initramfs-linux.img root=/dev/sda2 quiet splash
Press Enter to boot with these parameters.
Note: If you have not set a value for menu timeout, you will need to hold Space while booting for the systemd-boot menu to appear.
  • To make the change persistent after reboot, edit /boot/loader/entries/arch.conf (assuming you set up your EFI System Partition and configuration files according to the instructions in the Beginners' Guide) and add them to the options line:
options root=/dev/sda2 quiet splash

For more information on configuring systemd-boot, see the systemd-boot article.

GRUB

  • Press e when the menu shows up and add them on the linux line:
linux /boot/vmlinuz-linux root=UUID=978e3e81-8048-4ae1-8a06-aa727458e8ff quiet splash
Press b to boot with these parameters.
  • To make the change persistent after reboot, while you could manually edit /boot/grub/grub.cfg with the exact line from above, the best practice is to:
Edit /etc/default/grub and append your kernel options to the GRUB_CMDLINE_LINUX_DEFAULT line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
And then automatically re-generate the grub.cfg file with:
# grub-mkconfig -o /boot/grub/grub.cfg

For more information on configuring GRUB, see the GRUB article.

GRUB Legacy

  • Press e when the menu shows up and add them on the kernel line:
kernel /boot/vmlinuz-linux root=/dev/sda3 quiet splash
Press b to boot with these parameters.
  • To make the change persistent after reboot, edit /boot/grub/menu.lst and add them to the kernel line, exactly like above.

For more information on configuring GRUB Legacy, see the GRUB Legacy article.

LILO

  • Add them to /etc/lilo.conf:
image=/boot/vmlinuz-linux
        ...
        quiet splash

For more information on configuring LILO, see the LILO article.

rEFInd

  • To make the change persistent after reboot, edit /boot/EFI/arch/refind_linux.conf (ie. refind_linux.conf in the folder your kernel is located in) and append them to all/required lines, for example
"Boot to X"   "root=PARTUUID=978e3e81-8048-4ae1-8a06-aa727458e8ff quiet splash"
  • If you have disabled auto-detection of OS's in rEFInd and are defining OS stanzas instead in /boot/EFI/refind/refind.conf to load your OS's, you can edit it like:
menuentry "Arch" {
	loader /EFI/arch/vmlinuz-arch.efi
	options "root=PARTUUID=978e3e81-8048-4ae1-8a06-aa727458e8ff quiet splash"

For more information on configuring kernel parameters in rEFInd, see Configuring the rEFInd Bootmanager

EFISTUB/efibootmgr

See EFISTUB#Using UEFI directly (efibootmgr).

Hijacking cmdline

Even without access to your bootloader it is possible to change your kernel parameters to enable debugging (if you have root access). This can be accomplished by overwriting /proc/cmdline which stores the kernel parameters. However /proc/cmdline is not writable even as root, so this hack is accomplished by using a bind mount to mask the path.

First create a file containing the desired kernel parameters

/root/cmdline
root=/dev/disk/by-label/ROOT ro console=tty1 logo.nologo debug

Then use a bind mount to overwrite the parameters

# mount -n --bind -o ro /root/cmdline /proc/cmdline

The -n option skips adding the mount to /etc/mtab, so it will work even if root is mounted read-only. You can cat /proc/cmdline to confirm that your change was successful.

Parameter list

Parameters always come in parameter or parameter=value. All of these parameters are case-sensitive.

Note: Not all of the listed options are always available. Most are associated with subsystems and work only if the kernel is configured with those subsystems built in. They also depend on the presence of the hardware they are associated with.
parameter Description
root= Root filesystem.
ro Mount root device read-only on boot (default1).
rw Mount root device read-write on boot.
initrd= Specify the location of the initial ramdisk.
init= Run specified binary instead of /sbin/init (symlinked to systemd in Arch) as init process.
init=/bin/sh Boot to shell.
systemd.unit=
systemd.unit=multi-user Boot to a specified runlevel.
systemd.unit=rescue Boot to single-user mode (root).
nomodeset Disable Kernel mode setting.
zswap.enabled Enable Zswap.
video=<videosetting> Override framebuffer video defaults.

1 mkinitcpio uses ro as default value when neither rw or ro is set by the boot loader. Boot loaders may set the value to use, for example GRUB uses rw by default (see FS#36275 as a reference).

For a complete list of all options, please see the kernel documentation.

See also