In this video, you 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 you 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-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 LVLAB.
So I'm going to use LVREMOVE-F for force on dev VGLAB LVLAB, 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-L on VGLAB. And what do we see? We see created before executing LVREMOVE
and created after executing LVREMOVE. 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, VGLAB, that is. And there we can see that it restored
the volume group VGLAB. So LVS is showing. Now look at that. LVS is showing that LVLAB is already
present. But there's one tiny little thing. We don't see the A for active in the LVLAB logical
volume. So I'm going to use LVCHANGE-AY, which is for active, yes. And I'm going to change that on
VGLAB-LVLAB. And now LVS is showing that LVLAB 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 mount it manually or whatever. But at this point,
you have successfully recovered your logical volume.