Now within the default GRUB file,
we can also see options that are passed by default
through to all of our Linux entries.
These include resume. Well, this is really for hibernation.
So if our system went into hibernation, where do we resume from, which partition?
Well,
it's not really a feature that we're going to be using or
needing to implement on a server. And then rhgb.
Now, if you work a little bit in graphics,
you might know of RGB, or red, green, and blue,
but it's nothing to do with this.
It's the Red Hat graphical boot, so just a graphical boot screen that we
see rather than text. But really, no one really cares on a server. You're
not going to be there during the boot phase.
Similarly, with quiet. With quiet,
we don't output anything through to the screen during the boot phase; however,
we're not there to see it, so it doesn't really
matter whether we display it or not.
But if we are watching a server,
presumably we're watching the server because we want to debug the
boot, and we would like to see this information.
So these are not options we would particularly be working
with on a server. If we want to change this,
we can go through and take a look from a root
perspective at the /boot/grub2/grubenv file,
the GRUB environment. This is generated when we go through and
create our GRUB entries, and we'll be able to see then the
default kernel options from that.
We can go through and take a look at each individual entry in the
bootloader by looking at the /boot/loader/entries directory.
There'll be a lot of .conf files there relating to the different
kernels that we can boot to.
Using the grubby command, we can either remove those entries from the
grubenv command using ‑‑update‑kernel and ALL, or we can go through and
choose a specific kernel to remove arguments.
So let's go through and take a look on our command line at
the kernel options and using grubby.
So here we are on our command line. Let's give ourselves a little bit of
root privileges and go through and take a look inside our grubenv file.
So grubenv file is written to when we run a grub.config and we have our
default options for our kernel.
If I look in /boot/grub2 and then the file, grubenv, it's the kernel
options that we are interested in. And we can see towards the end of
this, we have then resume, rhgb, and quiet.
These are all options that are not particularly useful on a server, so we can
go through and choose which options we want to include.
Now we could go through and remove them from the default file, but changing
them directly with grubby means that we don't need to go through and run our
grub2‑mkconfig. We can edit the files directly.
So I'm going to go through using the grubby editor.
Yes, grubby is a name. And as I go through, I can go through and specify to
‑‑update. And if I have =ALL, then we are really writing into that
environment file, so all of our kernels. We can use ‑‑remove‑args= and then
in quotes the arguments that we want. It can be a single argument, or it can
be a space‑separated list of options for our kernel. Here, let's just take
out our Red Hat graphical boot.
Now, when I go through and take a look now at the GRUB environment, we can
see that we have resume and quiet, but we have lost the rhgb. But as well
as writing through to all of our configurations, we can choose to write to
a single configuration if we want.
If I take a look inside of /boot/loader/entries, then each one of those
menu options is shown within the entries directory.
If I want to work with my current kernel, I can see that would be 35bf
and then ending 4.18. If I look inside this configuration file, and
included in that, we've got then our kernel options. We've got options,
and $kernelopts, and our $tuned_params.
So it's just coming from the grubenv file because we have not set anything
explicitly for this kernel. Now if we wanted to, we can go through and choose
which options we want to include or exclude from this file. So we can go
through and use grubby. And then the same thing as we saw before, the
‑‑update‑kernel, but instead of =ALL, we specify the path through to the
kernel, so /boot/vmlinuz‑ and then our current running kernel. Don't worry, we
don't need to remember that.
We can actually use the output of the uname ‑r command. And then, of
course, we can then say the arguments that we want.
So for example, if we wanted the rhgb to be included, we could add it,
but just for this one kernel. So I can hit then Enter on that, and we
would set that. However, if we wanted to remove all of those arguments
that we don't need, those three arguments, we can specify ‑‑remove‑args=.
And remember, I was saying whether we're adding arguments or whether
we're removing them, it's actually just going to be then a
space‑separated list.
So we have then resume. We want to take out the hibernation,
the graphical boot screen, and the quiet, so we're verbose during the
boot phase and not hidden behind the graphical screen.
Now with that done, if I go back and look at the configuration file for that
entry, for that kernel, so again, going back into our boot/loader/entry
subdirectory and then going through pulling up my 35,
I can use tab completion, so I don't need to worry about typing
it all, and then just 4 and tab completion.
We can see the options now are not coming from the
kernel options, but explicitly being set.
So we've got our root filesystem,
we've got read‑only, and we've got the tuned parameters, but we're not picking
up anything else from the GRUB environment. So we can go through now and take
a look at this. If we go through and power off,
we're resuming now by taking a look at the GRUB menu on the physical
VirtualBox machine, so we can see it counting down from the 10
seconds. As we load our entry, we're going to see straightaway a
verbose output. So we can see that we're no longer suppressing the
output through the quiet switch.
But as we go through and take a look at it,
we're also not hidden behind the graphical boot screen, so we are
booting up without those options. We're unable to go through and see
the process of the resume having been removed,
but we no longer have our hibernation partition.
So we've got our system set up now the way that we want,
and we've tuned our kernel to the parameters that are more suitable perhaps for a server.