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.
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.)
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
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.
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.
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! !!
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.
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