[LINUX] I summarized how to change the boot parameters of GRUB and GRUB2

Introduction

I thought there was only one way to change the boot parameters in GRUB2 Actually, there were two patterns. (Maybe there are more) It's a big deal, so I'll try to summarize it.

First, let's start with the story of GRUB.

GRUB story

In GRUB, *** / boot / grub / grub.conf *** I edited it directly with the vi command and used it.

Editing this file directly is very dangerous. If you insert extra spaces or delete line breaks That alone will prevent the system from starting up. (/ Boot is a delicate part because it contains files related to booting.)

The story of GRUB2

Therefore, "Since the configuration file is under / etc, let's change / etc / default / grub with the vi command etc." And the operation method was changed.

However, what is actually used at startup is *** / etc / grub2 / grub.cfg ***. How to reflect in this file Use the grub2-mkconfig command.

# grub2-mkconfig -o /boot/grub2/grub.cfg

Verification

We will check with CentOS 8.2.2004.

First, make a backup of grub.cfg.

# cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bk

Check the default boot parameters.

# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true

Try removing "rhgb" and "quiet" from the GRUB_CMDLINE value. By the way, if you delete these two strings, You can display the boot log when the OS starts. (The default is to suppress the display of the boot log.)

# vi /etc/default/grub

# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
#GRUB_CMDLINE_LINUX="resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"
GRUB_CMDLINE_LINUX="resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true

As it is, it is not reflected in the grub.cfg file.

# grep kernelopts /boot/grub2/grub.cfg
set default_kernelopts="root=/dev/mapper/cl-root ro resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet "

Reflect it in the grub.cfg file.

# grub2-mkconfig -o /boot/grub2/grub.cfg

# grep kernelopts /boot/grub2/grub.cfg
set default_kernelopts="root=/dev/mapper/cl-root ro resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap "

It was reflected safely.

Can be changed without using / etc / default / grub

It's finally the main subject. ~~ I wanted to write this ~~

How to edit / etc / default / grub It came out in Linux certification exams such as LPIC and LinuC.

Alternatively, you can use the *** grub2-editenv *** command.

Verification

Now let's change it using the grub2-editenv command. What I want to do is add the "rhgb" and "quiet" that I deleted earlier.

First, check in the same way as before.

# grep kernelopts /boot/grub2/grub.cfg
set default_kernelopts="root=/dev/mapper/cl-root ro resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap "

You can also check it with grub2-editenv.

# grub2-editenv list | grep kernelopts
kernelopts=root=/dev/mapper/cl-root ro resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root 

Boot parameter information is stored in / boot / grub2 / grubenv.

# grep kernelopts /boot/grub2/grubenv
kernelopts=root=/dev/mapper/cl-root ro resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap

Change the boot parameters.

# grub2-editenv - set "kernelopts=root=/dev/mapper/cl-root ro resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"

Check if you could change it.

# grub2-editenv list | grep kernel
kernelopts=root=/dev/mapper/cl-root ro resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet

I was able to change it! !!

Supplement

In CentOS6, the boot loader uses GRUB. The configuration file is /etc/grub/grub.conf.

In CentOS7 and later, GRUB2 is used as the boot loader. The configuration file is /etc/grub2/grub.cfg.

Summary

In GRUB2, I confirmed that there are two ways to change the boot parameters.

The first one How to edit / etc / default / grub and reflect it with grub2-mkconfig

The second is How to run grub2-editenv and change the value of kernelopts This had the feature that it did not run grub2-mkconfig -o /boot/grub2/grub.cfg.

Recommended Posts

I summarized how to change the boot parameters of GRUB and GRUB2
I want to know the features of Python and pip
I want to manually assign the training parameters of the [Pytorch] model
How to change the log level of Azure SDK for Python
How to change the color of just the button pressed in Tkinter
[EC2] How to install chrome and the contents of each command
I tried to build the SD boot image of LicheePi Nano
[Python] How to get the first and last days of the month
How to check the version of Django
[Python] How to specify the window display position and size of matplotlib
I tried to visualize the age group and rate distribution of Atcoder
What I did to keep track of the humidity and temperature of the archive
I tried how to improve the accuracy of my own Neural Network
I tried to extract and illustrate the stage of the story using COTOHA
I tried to verify and analyze the acceleration of Python by Cython
I want to analyze the emotions of people who want to meet and tremble
How to calculate the volatility of a brand
How to find the area of the Voronoi diagram
[Python] How to change the date format (display format)
I tried to touch the API of ebay
Change the color of Fabric errors and warnings
I tried to correct the keystone of the image
I read and implemented the Variants of UKR
I want to customize the appearance of zabbix
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
How to make VS Code aware of the venv environment and its benefits
I tried to notify the update of "Hamelin" using "Beautiful Soup" and "IFTTT"
I want to visualize where and how many people are in the factory
How to count the number of elements in Django and output to a template
How to change the appearance of unselected Foreign Key fields in Django's ModelForm
The tree.plot_tree of scikit-learn was very easy and convenient, so I tried to summarize how to use it easily.
How to know the port number of the xinetd service
[Linux] I learned LPIC lv1 in 10 days and tried to understand the mechanism of Linux.
How to get the number of digits in Python
I tried to summarize how to use matplotlib of python
I tried to notify the update of "Become a novelist" using "IFTTT" and "Become a novelist API"
I want to grep the execution result of strace
[Blender] How to get the selection order of vertices, edges and faces of an object
How to visualize the decision tree model of scikit-learn
I tried to understand how to use Pandas and multicollinearity based on the Affairs dataset.
I checked out the versions of Blender and Python
I want to fully understand the basics of Bokeh
How to use the grep command and frequent samples
How to confirm the Persival theorem using the Fourier transform (FFT) of matplotlib and scipy
I checked the default OS and shell of docker-machine
[Blender] How to dynamically set the selection of EnumProperty
I tried to visualize the spacha information of VTuber
How to change the behavior when loading / dumping yaml with PyYAML and its details
I tried to erase the negative part of Meros
How to use argparse and the difference between optparse
[Python] Summary of how to specify the color of the figure
How to hit the document of Magic Function (Line Magic)
How to access the global variable of the imported module
I just wanted to extract the data of the desired date and time with Django
I tried to make it easy to change the setting of authenticated Proxy on Jupyter
I tried to compare the processing speed with dplyr of R and pandas of Python
How to change the generated image of GAN to a high quality one to your liking
[Selenium] How to specify the relative path of chromedriver?
I tried to classify the voices of voice actors
I want to increase the security of ssh connections