How to set kernel boot parameters on Linux

The purpose of this tutorial is to show how to set kernel boot parameters in Linux. When a user boots their Linux system, the GRUB boot loader can set various parameters as it loads the Linux kernel. You can think of these parameters as arguments, the same type you are probably accustomed to using with commands in your terminal.

Kernel parameters can be set either temporarily or permanently, and will modify the behavior of your system as it boots up. Modifying kernel boot parameters can have a big impact, such as allowing you to reset the root password, or they can do minor things like show the logo of your Linux distro when your computer boots up.

Follow along with our step by step instructions below to see how to set kernel boot parameters either temporarily or permanently on Linux. Temporary parameters will only survive one boot, and then be erased for subsequent reboots. Permanently setting a parameter will ensure that it persists across all future reboots of the system.

In this tutorial you will learn:

  • How to set temporary kernel boot parameters
  • How to set permanent kernel boot parameters
  • How to view currently configured kernel boot parameters
How to set kernel boot parameters on Linux
How to set kernel boot parameters on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software GRUB boot loader
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user
DID YOU KNOW?
Kernel boot parameters are often just a single word, such as splash. Some parameters may also contain an equal sign, such as init=/bin/bash.

How to set temporary kernel boot parameters




Setting a temporary kernel boot parameter can be done directly from the GRUB boot menu. Follow the steps below to set one. In this example, we will set the splash parameter, which just shows a logo upon boot up, instead of the GRUB menu.

  1. Reboot your system and hold the Shift key as its first booting up, and you will be brough into the GRUB boot menu.
    GRUB boot menu
    GRUB boot menu
  2. Highlight the kernel you want to edit (probably the first selection in the menu) and press e on your keyboard to temporarily edit the boot parameters.
    Editing the boot parameters in GRUB
    Editing the boot parameters in GRUB
  3. Using the arrow keys on your keyboard, go down to the line that starts with linux. At the end of this line is where you should place your desired kernel boot parameters. Check the screenshot below where we have added the splash parameter. There are also several others present, such as ro, quiet, etc.

    Setting a temporary kernel boot parameter in GRUB menu
    Setting a temporary kernel boot parameter in GRUB menu



  4. Once you are satisfied with the changes, press Ctrl + X. Your system should then reboot and your configured boot parameter(s) will be used. As mentioned before, this change is only temporary and will reset for subsequent reboots.

How to set permanently kernel boot parameters

To permanently set a kernel boot parameter, we will edit the GRUB configuration file.

  1. Open a terminal and use nano or your preferred text editor to open the following configuration file with root privileges.
    $ sudo nano /etc/default/grub
    
  2. The GRUB_CMDLINE_LINUX_DEFAULT line contains your kernel boot parameters. Edit this line according to your needs. When done, you can exit the file while saving your changes. In the screenshot below, you can see our system has the splash and quiet parameters.
    The kernel boot parameters inside of the GRUB config file
    The kernel boot parameters inside of the GRUB config file
  3. Now for the changes to take effect, you will need to run the following command:
    $ sudo update-grub
    




That’s all there is to it. Your system will load these new boot parameters the next time your system boots up, and for every subsequent reboot after that. If you need to disable them in the future, just follow the same instructions but remove your parameter(s) as needed.

NOTE
You can always see your currently configured kernel boot parameters by executing this command: cat /proc/cmdline

Closing Thoughts

In this tutorial, we saw how to set kernel boot parameters in Linux. This included editing the GRUB boot menu to set temporary parameters, and editing the GRUB config file for permanent parameters. You also learned how to view the currently configured kernel boot parameters. In case your changes have any unintended side effect, simply remove them from the GRUB config file and run sudo update-grub when done.



Comments and Discussions
Linux Forum