Grub2 File Overview (Demo)

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hello Cybrarians and welcome back to
00:00
the Linux plus course here in Cybrary.
00:00
I'm your instructor Rob Dells and in today's lesson,
00:00
we'll be discussing GRUB2 files and directories.
00:00
Upon completion of this lesson,
00:00
you will be able to locate GRUB2 files in CentOS and
00:00
Ubuntu and we'll discuss
00:00
the contents of GRUB2 files and directories.
00:00
Demo time. Let's move on over
00:00
to our demonstration environment and take a look.
00:00
Let's take a look at GRUB2
00:00
using the newest CentOS Distro,
00:00
which is CentOS 8,
00:00
you can see that here, rob@centos8.
00:00
Just from past experience,
00:00
I can tell you that in order to go
00:00
ahead and look inside of
00:00
these files and even just list the contents
00:00
of the boot GRUB2 directory, we need to become root.
00:00
Now normally I would not recommend doing so.
00:00
Certainly if you can't always
00:00
run escalated privileges temporarily,
00:00
but just to speed things up here,
00:00
we're going to become root
00:00
temporarily and we're going to go ahead and we're going
00:00
to take a look inside of the
00:00
boot grub.2 or GRUB2 directory,
00:00
so let's go ahead and do that.
00:00
I'm going to navigate to cd boot grub2 and then we're
00:00
going to run an ls -al so
00:00
that we can see the contents of this directory.
00:00
Look, we see grub.cfg.
00:00
Now, this is the replacement for
00:00
grub.conf that we had in grub.
00:00
In GRUB2, it's called
00:00
grub.cfg and we can
00:00
look at that file by just doing a less,
00:00
so we'll do less grub.cfg.
00:00
Inside this, well, the first thing we see
00:00
at the top of this is a big scary message,
00:00
do not edit this file.
00:00
Well, we see that it's automatically
00:00
generated by GRUB2 make config,
00:00
that command is used to
00:00
generate this file and it generates it
00:00
using templates from the etc grub.d directory,
00:00
and settings from etc default grub.
00:00
Well, let's take a look at those files.
00:00
Let's do less etc default grub and what's in here?
00:00
Well, this is pretty much what
00:00
we were used to seeing before.
00:00
We see the timeout value
00:00
and we see some information about
00:00
the distributor and console output, etc.
00:00
These are all default variables
00:00
that are used when configuring GRUB2.
00:00
We'll get more into this in a little bit down the road.
00:00
Let's also take a look at that
00:00
etc grub.d directory I was talking about,
00:00
and inside of this directory,
00:00
if we run an ls, we can see that it has
00:00
scripts that we have here that are
00:00
used to create the grub menu,
00:00
different scripts for different purposes and
00:00
we'll talk about that in a few minutes.
00:00
We also see that we can create custom scripts here,
00:00
so we see 40_custom that's used
00:00
>> to create custom scripts.
00:00
>> Then once we were to create
00:00
those custom scripts and
00:00
maybe modify it as the default grub,
00:00
we can run that GRUB2 make
00:00
config command to update our grub boot loader.
00:00
Now let's go ahead and move over to Ubuntu.
00:00
If we look at Ubuntu here,
00:00
we need to change directory to
00:00
boot grub instead of GRUB2,
00:00
that's just because things are
00:00
a little bit different when
00:00
you're discussing different distributions.
00:00
If you're talking about Ubuntu,
00:00
even though it's GRUB2, you're going to
00:00
find things and boot grub.
00:00
If you're on CentOS, you'll find them in boot GRUB2.
00:00
Let's go ahead and do an ls -al in this directory
00:00
and here we can also see our grub.cfg file.
00:00
If we open up that file,
00:00
we can see our base Gary message again,
00:00
do not edit this file.
00:00
It's automatically generated by grub-make config.
00:00
Well, but we see that it still uses the templates
00:00
from etc grub.d and settings from etc default grub.
00:00
Let's take a look at etc default grub
00:00
and see what's going on here.
00:00
Well, what's up with that? If we get
00:00
into etc default grub,
00:00
we see that it says if you change this file,
00:00
run update grub afterwards,
00:00
update boot grub, grub.cfg,
00:00
this.cfg file we were just looking at a minute ago.
00:00
We can still see all the default values here,
00:00
but this is weird.
00:00
What is this update grub?
00:00
Well, remember in Linux,
00:00
everything is a file,
00:00
so we can actually find out what update grub does.
00:00
The first thing we want to do is find out,
00:00
well, what is update grub?
00:00
Where is it? Where can we find it,
00:00
and where can we interrogate it?
00:00
If we do a which command,
00:00
it'll tell us the location of update grub
00:00
and that is in user sbin update grub and we could
00:00
do less user sbin update grub
00:00
and then what we'll see inside of this file
00:00
here is that it's actually just running
00:00
exec grub dash make config
00:00
and the output is going to boot grub.cfg,
00:00
which we know is that default file that
00:00
says it's the boot loader in GRUB2.
00:00
Really the big thing to remember is
00:00
>> if you are in CentOS,
00:00
>> you're running GRUB2 everywhere,
00:00
GRUB2 for the commands, GRUB2 for the directory path.
00:00
But if you're on Ubuntu you're going
00:00
>> to be running grub.
00:00
>> Don't ask me why,
00:00
it just boils down to it
00:00
depends which version of the
00:00
>> operating system you're on,
00:00
>> which distro you're using.
00:00
Let's take a look though back at etc default grub.
00:00
Let's get a little bit further into
00:00
the weeds in terms of what is in here.
00:00
Now, in etc default grub as previously mentioned,
00:00
this is going to contain
00:00
our configuration variables so we're
00:00
going to see grub default which
00:00
indicates the default operating system in the use.
00:00
Again, that's a zero value index,
00:00
so the first entry
00:00
is the one that's used even though it's zero,
00:00
it starts at zero so that's the first one.
00:00
We'll also see that grub timeout style is hidden,
00:00
which means that it's going to have a blank screen for
00:00
the time period that is set for grub timeout.
00:00
In this case, grub timeout is zero,
00:00
so for zero seconds
00:00
it'll be blank and then it'll start loading
00:00
a splash screen and you'll see
00:00
the abundance splash screen startup in this system.
00:00
The grub distributor line is used when creating
00:00
menu titles so that
00:00
describes kind of what we saw previously,
00:00
is going to describe different distributions,
00:00
different operating systems that were maybe
00:00
running on this system, on this hardware,
00:00
and grub command line Linux
00:00
is used to set Linux kernel parameters.
00:00
We said the other piece of this puzzle
00:00
though is our directory.
00:00
Let's go and take a look at etc grub.d.
00:00
If we look inside of here,
00:00
this is the directory that contains the scripts we
00:00
use to build the grub menu in GRUB2.
00:00
I'll just tell you a little bit about these scripts.
00:00
You can certainly take a look at them
00:00
yourself if you wanted to navigate into
00:00
this directory and you have
00:00
a test machine you want to play with.
00:00
But 00 header is
00:00
the script that's used to load
00:00
>> all those grubs settings,
00:00
>> those lovely configuration settings,
00:00
those default variables we set in etc default grub,
00:00
10_linux identifies
00:00
the different kernels that are out there.
00:00
The Linux kernels that you use to
00:00
boot from so as you update your system,
00:00
you might have older kernels,
00:00
you might want to roll back to those.
00:00
Well, those are all found by that script and
00:00
identified so that you can
00:00
select them from the bootloader,
00:00
30_os-prober searches for non-Linux
00:00
operating systems and puts the result into memory.
00:00
If for some reason you're dual-booting
00:00
a bunch of Windows, which some people do,
00:00
you'll be able to see Windows as
00:00
a boot option from the GRUB2 bootloader menu.
00:00
Then 40_custom as I said,
00:00
this is a custom template that you can use.
00:00
Generally, you would copy this template
00:00
and then use that to create custom menu entries.
00:00
Basically, we don't want to touch any
00:00
of these except for 40_custom,
00:00
which we can copy and modify as need be.
00:00
But with that being said in this lesson,
00:00
we covered where to find GRUB2 files in CentOS,
00:00
where to find GRUB2 files in Ubuntu,
00:00
we talked about the contents of grub and
00:00
GRUB2 files and how
00:00
they're a little bit different in GRUB2,
00:00
and we also looked at the directories.
00:00
With that being said, thank you very much
00:00
>> for being here
00:00
>> and I look forward to seeing you in the next lesson.
Up Next