- Alright, well sometimes you cannot boot into grip anymore.
Then what can you do?
You can use a rescue disk,
and I know I'm on a fully installed system here,
but that is because I want to show you
how to connect to the rescue disk
from the virtualization software.
This is one of the few cases where I do think
it's useful to know about a virtualization software
because you need to insert a disk, right?
How are you inserting a disk in virtualization?
Well, typically by going to your devices,
and by connecting your CD, DVD
which in VMWare Fusion is this option right here.
And you need to look for something similar
if you're also in virtualization.
Next, we need to get access to a boot prompt,
and that can be a little bit challenging
because while you see the boot logo
in my virtualization environment that'll be the VMware logo
I need to press a key, probably the escape key
with the exact key depends on your boot software.
Might be escape, might be F12,
might be F10, might be something else.
I'm going for escape and I'm going to show you right now.
Let's restart.
All right, so here we have the boot menu.
I finally got there by pressing escape at the right moment,
but my VMware BIOS is giving me a second or less.
So you really need to be fast,
and I'm selecting CD ROM drive.
And with the CD ROM drive connected, this is what I get.
So this time we are not going to install CentOS Stream 9,
no, I'm going to select troubleshooting.
No matter which distribution you are using,
on the installation disk, you will always have an option
to start a live system, or a troubleshooting system.
And if you're using Ubuntu,
and you want to start a live system from the DVD,
that's okay as well.
From the live system, you are going to access your disk,
and you can do your troubleshooting.
Now I am not going for install,
I am going for a rescue CentOS Stream system.
So at this point it is really booting from an initramfs
that is installed on the installation disk.
It's basically the same program
as what you use to install Linux.
Now what do we see?
We see that the rescue environment
will now attempt to find the Linux installation.
I don't wanna do that.
I want to make it a little bit harder for myself.
I'm going to use option three to skip to the shell,
and yet it's not mounting the system, that is right.
I wanna do it myself because I want to show you something
that works in all cases.
So here's my cell, a root shell.
I'm using lsblk for list block devices and what do we see?
Well, we see sda1 and sda2.
sda2 is the partition that has my lvm, oh boy lvm.
So lvs is what I wanna do, and fortunately;
lvs is showing me the logical volumes.
So I have my root logical volume that is visible.
So how am I going to access it?
mount /dev/cs, that's the volume group
as we can see in the vg column in the output of lvs,
/root /mnt I just need to mount it on a temporary directory,
and oh that's not going smoothly, I'm getting a message.
"Special device dev/cs/root does not exist."
So we need vgs to inspect the volume groups.
And that is interesting,
I do see the volume group with the name cs.
I do see the lv with the name root,
but I don't see it as a device.
So we need to further investigate.
lv display is what I'm going to do this time
because I want to check that it is available.
And what do we see in lv status
for both of them we see not available.
Well if that is what you get, you need to activate them.
And what is that?
vgchange, vgchange --help.
This is one of these commands
that most people don't use too often,
and oh boy, too much help output.
I'm just looking for what again whilst this syntax.
So the command that you need is vgchange -a y,
that is going to activate it.
And now if I use lvdisplay again
now I can see that my lvstatus is available.
That means that I can now repeat my mount command.
And there we go, in the mnt directory,
I now have access to my operating system.
Now next step in troubleshooting will be "chroot .",
which will make the current directory
your new root directory,
and from here you can do whatever you wanna do.
Well if you needed a rescue disk,
then most likely you need to use grub2 install
because if you needed to rescue this,
then your grub configuration was damaged.
But hey, in order to install grub to the boot loader,
we do also need access to the boot partition,
and ls /boot is giving me nothing.
Now, fortunately there is mount -a,
and now can we use grub to install on /dev/sda
to reinstall the grip boot loader,
and oh boy, I am getting,
"error: cannot find a device for /boot/grub2".
The thing is that I now have access
to my root file system, and the boot partition,
but my proc directory is still empty,
and my dev directory is still empty, that's not good.
The dev directory is the first thing that I need,
and I am going to use exit to take care of it
because in the rescue disk, we do have a dev directory.
This dev directory contains devices,
and this directory is dynamically generated
while you are booting.
And I'm going to use mount -o bind /dev /mnt/dev,
and that makes that within the /mnt/dev,
I now have my devices, so where am I?
I'm still in the mnt directory.
That's good, so I can go get back in my root environment.
Next I need mount proc proc proc.
Believe it or not, we want to mount the proc file system
on the proc directory with the option -t proc and okay,
I admit /proc makes it a little bit easier to understand,
but it's cool to type mount proc proc proc,
and actually it makes sense.
Now we have proc, we have dev, and that means that
I should be able to run my grub2 install at this point.
Okay, there we go, grub2, telling me no error report it.
Please ignore the the messages that you see.
You should be good and you should be able to reboot
back into a normal operating system right now.
Oops, get out of the to root environment,
then you can reboot and you should be good.
Oh no, we messed it up.
Well that means that we need to
try something else to repair it, let's do it.
I just restarted and I see grub, great then,
and I don't see anything else anymore, that's not good.
So what can we do from here?
Well we do have a grub boot menu,
and in the grub boot menu, we can try to troubleshoot.
Now this grub boot menu is a very rich environment.
The environment is so rich that I don't like it very much.
It's confusing and if I get problems like this,
then I am getting back to my rescue system.
So let's get back to the rescue system,
and see if we can get it going again.
So back to the CD-ROM Drive.
And on this CentOS system, there's another option
that's hidden in troubleshooting, boot from local drive.
This boot from local drive is making it a little bit easier,
and oh, not bringing me anywhere.
Okay then I need to go hardcore.
And back to the CD-ROM Drive,
and troubleshooting once more.
So I definitely need my rescue with CentOS Stream system
because with this grub boot prompt, we don't get very far.
So this time, I am going to use this option
where the rescue system is trying to load everything.
So that is option number one.
That's giving me access to a completely functional system,
and I like the idea of having
a completely functional system.
So it's telling me chroot /mnt/sysroot, sounds good.
So chroot /mnt/sysroot,
and there we have all these directories.
Now I need to do my checks, ls /boot.
We do have a boot.
ls /dev, we do have a dev,
ls /proc, that's not ls.
ls /proc, we do have a proc.
And last, ls /sys, we also do have a sys, that's all good.
So now I'm going to try to run my grub
to install on /dev/sda, again,
because that definitely filled in the first attempt.
So here we go, I don't have my errors anymore.
So that is looking all good.
Using exits to get out of the true deal
using a reboot to reboot.
And then what do I get?
I get access to my CentOS Stream, again,
and that means that this problem has been fixed.