1
00:00:00,000 --> 00:00:10,960
In this video, you'll learn about troubleshooting LVM. I will show you what you can do if at

2
00:00:10,960 --> 00:00:18,320
any time a logical volume has got lost, because you can easily repair it using vgcfgv4. Let's

3
00:00:18,320 --> 00:00:19,320
check it out!

4
00:00:19,320 --> 00:00:24,480
Now, the nice thing about LVM is that LVM automatically writes text-based backups of

5
00:00:24,480 --> 00:00:31,440
your volume group metadata, and it does so to the etc LVM backup directory. In this directory,

6
00:00:31,440 --> 00:00:37,599
you can see that for each of the volume groups that I have on my system, there is a file.

7
00:00:37,599 --> 00:00:43,520
And if we check that file there, you can see information about what it has done in there.

8
00:00:43,520 --> 00:00:49,439
So the volume group, and we can see the physical volumes in there, and the device IDs, and

9
00:00:49,439 --> 00:00:55,919
the different swap volumes, and everything is in there. Now, these backups are created

10
00:00:55,919 --> 00:01:00,639
automatically, and normally, after all changes, a backup is made automatically. So there's

11
00:01:00,639 --> 00:01:10,559
nothing that you need to do about it. The only thing that you need to do is vgcfgrestore

12
00:01:10,559 --> 00:01:16,720
minus L on your volume group. So here we can see what it looks like for the CS volume group,

13
00:01:16,720 --> 00:01:23,599
which is a default volume group. So it created before executing a VG change, and after executing

14
00:01:23,599 --> 00:01:31,040
a VG change, auto-activation, and that seems to be at installation time. Now, what I'm

15
00:01:31,040 --> 00:01:36,720
going to do, I'm going to remove a logical volume. So I'm using LVS, and there we can

16
00:01:36,720 --> 00:01:48,400
see LV lab. So I'm going to use LV remove minus F for force on dev VG lab LV lab, and

17
00:01:48,400 --> 00:01:53,919
that should get rid of it. Oh no, now my logical volume is lost. Well, let's check out what

18
00:01:53,919 --> 00:02:08,320
you can do with vgcfgrestore. Step one, vgcfgrestore minus L on VG lab. And what do we see? We

19
00:02:08,320 --> 00:02:15,520
see created before executing LV remove and created after executing LV remove. So the

20
00:02:15,520 --> 00:02:20,960
thing that I care about is this one, and we need the file name, because this file name

21
00:02:20,960 --> 00:02:26,960
contains the state that I want to restore. So I'm going to copy this file name. But before

22
00:02:26,960 --> 00:02:32,639
doing anything, LVS is confirming that the logical volume is really gone. So now I'm

23
00:02:32,639 --> 00:02:42,320
using vgcfgrestore followed by minus F and this specific file name, followed by the name

24
00:02:42,320 --> 00:02:48,080
of the volume group, VG lab, that is. And there we can see that it restored the volume

25
00:02:48,080 --> 00:02:56,000
group VG lab. So LVS is showing. Now look at that. LVS is showing that LV lab is already

26
00:02:56,000 --> 00:03:03,360
present. But there's one tiny little thing. We don't see the A for active in the LV lab

27
00:03:03,360 --> 00:03:11,839
logical volume. So I'm going to use LV change minus AY, which is for active, yes. And I'm

28
00:03:11,839 --> 00:03:20,880
going to change that on VG lab dash slash LV lab. And now LVS is showing that LV lab

29
00:03:20,880 --> 00:03:27,039
is available. So my logical volume is back. Now, if it was already mounted, I would advise

30
00:03:27,039 --> 00:03:32,800
you reboot to make sure that the mount is made the right way through etcfsap or mounted

31
00:03:32,800 --> 00:03:38,240
manually or whatever. But at this point, you have successfully recovered your logical volume.

