In this video, you'll learn about troubleshooting LVM. I will show you what you can do if at
any time a logical volume has got lost, because you can easily repair it using vgcfgv4. Let's
check it out!
Now, the nice thing about LVM is that LVM automatically writes text-based backups of
your volume group metadata, and it does so to the etc LVM backup directory. In this directory,
you can see that for each of the volume groups that I have on my system, there is a file.
And if we check that file there, you can see information about what it has done in there.
So the volume group, and we can see the physical volumes in there, and the device IDs, and
the different swap volumes, and everything is in there. Now, these backups are created
automatically, and normally, after all changes, a backup is made automatically. So there's
nothing that you need to do about it. The only thing that you need to do is vgcfgrestore
minus L on your volume group. So here we can see what it looks like for the CS volume group,
which is a default volume group. So it created before executing a VG change, and after executing
a VG change, auto-activation, and that seems to be at installation time. Now, what I'm
going to do, I'm going to remove a logical volume. So I'm using LVS, and there we can
see LV lab. So I'm going to use LV remove minus F for force on dev VG lab LV lab, and
that should get rid of it. Oh no, now my logical volume is lost. Well, let's check out what
you can do with vgcfgrestore. Step one, vgcfgrestore minus L on VG lab. And what do we see? We
see created before executing LV remove and created after executing LV remove. So the
thing that I care about is this one, and we need the file name, because this file name
contains the state that I want to restore. So I'm going to copy this file name. But before
doing anything, LVS is confirming that the logical volume is really gone. So now I'm
using vgcfgrestore followed by minus F and this specific file name, followed by the name
of the volume group, VG lab, that is. And there we can see that it restored the volume
group VG lab. So LVS is showing. Now look at that. LVS is showing that LV lab is already
present. But there's one tiny little thing. We don't see the A for active in the LV lab
logical volume. So I'm going to use LV change minus AY, which is for active, yes. And I'm
going to change that on VG lab dash slash LV lab. And now LVS is showing that LV lab
is available. So my logical volume is back. Now, if it was already mounted, I would advise
you reboot to make sure that the mount is made the right way through etcfsap or mounted
manually or whatever. But at this point, you have successfully recovered your logical volume.