- All right, so previously we have talked
about the different phases in the boot procedure.
Now we need to talk about which tools you can use
in case anything goes wrong.
Well, if it goes wrong very early
like before you see the boot loader prompt
then there is only one option
and that is the rescue disk.
The rescue disk typically is the installation disk
of your Linux distribution and it allows you
to access a prompt from which you can access your hard drive
and actually fix it like reinstall grub 2.
If you do see grub 2 but you don't get to your kernel
you might have an option to get through the grub menu
and on the grub menu you might change parameters
to tell your kernel how to load.
If the kernel and the initramfs are doing okay,
well then still from the grub boot menu
you can do a couple of things.
You can use the option init = slash bin slash bash.
That is if you have a very early problem in System d.
It allows you to break into your system
before system d is actually loading.
Otherwise, there is the emergency target.
Which is a target in System d, and that allows you
to get into the System d procedure pretty early.
And if the problem is a little bit later
there's also the rescue.target.
The rescue target is also interrupting the boot procedure
and that allows you to get into System d
but a little bit later.
So if you have a problem loading your disk devices
for instance in System d
well then emergency target is more appropriate.
Rescue target is bringing you in
a little bit further in the procedure.
All of these options
are all parameters that are also entered
on the grub boot menu.
The difference is that here they are kernel arguments
and here if something is preventing you
from seeing the kernel, you might use the grub boot menu
to refer to another kernel.
So that is what you can do for troubleshooting.
Let's go check it out.
So I just pressed the shift key to enter the grub boot menu
on this CentOS Stream system
and we are going to use e for edit.
And I would like to get started by using the most minimal
of all init = slash bin slash bash,
which is making sure that we get into the system
before system d.
So what is so interesting about init = slash bin slash bash,
Do you see that?
I have a root prompt.
Who am I?
I'm root and I did not enter a password.
But the thing is that we are in a very minimal mode.
We don't even have system d.
So system ctl list units is giving me what?
It's giving me fail to connect to bus,
no such file or directory.
Init = bin bash means don't give me init,
which is the normal system d
give me bash, and that's where we are.
And if at this point
I want to get to the system d environment,
I need to use exec slash usr slash lib slash system d
slash system d.
Now what is this thing?
Well, exec, if you use it in order to start a program
you remove the current program from memory
you replace it with a target program
And that's exactly what we need
because system d needs to be pid 1.
If I would just start system d
then system d would become a child
of the current best process that's not working
and that's why I needed this
exec to usr lib system d, system d
which is the name of the system d binary.
Now we are back
and I can show you some more.
So let me restart again.
Shift key to enter the grub boot menu
and again e for for edit
where again I'm going to the end of the line
that reads Linux.
I'm removing rhgb and quiet and I'm using system d dot
unit = emergency.target cause that is where I wanna be.
Now where init = bin bash is letting you in
without entering any passwords here
you need to enter the root password.
So system ctl,
list units
showing all the units, we have 49 in total.
This is a minimal troubleshooting mode
as I've already shown you before.
Even your root valve system is in read-only mode
So you need mount minus o remount comma rw on slash
to make it reach right ball and then you can reboot.
I'm going to leave CentOS for now
and we are going to check out to Ubuntu.
So here we are on Ubuntu
pressing e to edit and looking for the line that ends Linux.
I am going to remove the quiet and splash.
And I would like to show you
system d dot unit = rescue dot target.
And control X to boot with that option.
So here we are in the in the rescue mode.
Now in Ubuntu it's pretty interesting
because in Ubuntu you don't have to enter a root password.
Why not? Well, Ubuntu root user doesn't have a password.
So we get free access, which makes it a bit vulnerable
but it's the way it is.
So I just press enter and I'm in a root shell
where I can use all of my troubleshooting skills
like system ctl list units.
That's not really troubleshooting
but I want you to get an idea
of the units that are currently loaded, 104.
On CentOS, it's about the same number.
The thing here is that the rescue target
is bringing you in a quite complete system.
An emergency target is only giving you a minimal system.
I think that's enough for troubleshooting.
Let's reboot and in the next video
you'll learn about using the rescue disk.