1
00:00:00,080 --> 00:00:01,500
In this lesson, we're going to walk through

2
00:00:01,500 --> 00:00:03,663
how to manage logical volumes.

3
00:00:04,770 --> 00:00:06,090
So, up to this point,

4
00:00:06,090 --> 00:00:09,000
we'll work directly with the physical devices.

5
00:00:09,000 --> 00:00:11,610
However, there's a way to further abstract these items

6
00:00:11,610 --> 00:00:14,160
and use them in a more efficient way.

7
00:00:14,160 --> 00:00:16,770
Linux uses a process called device mapping

8
00:00:16,770 --> 00:00:18,660
to help us accomplish this.

9
00:00:18,660 --> 00:00:22,560
In Linux, device mapper creates the virtual devices

10
00:00:22,560 --> 00:00:24,720
and passes data from that virtual device

11
00:00:24,720 --> 00:00:26,493
to one or more physical devices.

12
00:00:27,420 --> 00:00:29,520
One major application of the device mapper

13
00:00:29,520 --> 00:00:32,220
is the Logical Volume Manager.

14
00:00:32,220 --> 00:00:34,740
If you recall when we configured our virtual machines,

15
00:00:34,740 --> 00:00:38,550
the storage option was defaulted for us to use LVM.

16
00:00:38,550 --> 00:00:41,880
LVM maps whole physical devices and partitions

17
00:00:41,880 --> 00:00:44,310
into one or more virtual containers

18
00:00:44,310 --> 00:00:46,530
called volume groups.

19
00:00:46,530 --> 00:00:50,730
Within these volume groups are one or more logical volumes.

20
00:00:50,730 --> 00:00:53,370
Ultimately, the logical volumes become the storage devices

21
00:00:53,370 --> 00:00:56,370
that the system, user, and the applications

22
00:00:56,370 --> 00:00:57,360
will end up working with.

23
00:00:57,360 --> 00:00:59,100
So, first thing we want to do, let's identify

24
00:00:59,100 --> 00:01:01,750
the current logical volumes that's on the system now.

25
00:01:03,240 --> 00:01:04,712
We'll do /dev/mapper.

26
00:01:07,410 --> 00:01:09,270
Again, from when we created the virtual machine,

27
00:01:09,270 --> 00:01:13,980
we see that the system created centos-root and centos-swap.

28
00:01:13,980 --> 00:01:15,780
Those are the logical volumes

29
00:01:15,780 --> 00:01:17,630
that we currently have on the system.

30
00:01:23,340 --> 00:01:25,260
Now, what we're going to do is we're going to scan the system

31
00:01:25,260 --> 00:01:28,500
for the current physical volumes,

32
00:01:28,500 --> 00:01:30,660
volume groups, and logical volumes.

33
00:01:30,660 --> 00:01:32,910
There's commands for those.

34
00:01:32,910 --> 00:01:33,813
Scan here.

35
00:01:35,430 --> 00:01:38,163
See we have one from the creation with CentOS?

36
00:01:41,730 --> 00:01:45,060
We're going to use the pvdisplay command.

37
00:01:45,060 --> 00:01:47,040
That's going to also show us

38
00:01:47,040 --> 00:01:48,210
a little bit more detailed information

39
00:01:48,210 --> 00:01:50,910
about the physical volumes that are currently on the system.

40
00:01:50,910 --> 00:01:52,200
Remember, the physical volumes are ones

41
00:01:52,200 --> 00:01:54,300
that has been identified and associated

42
00:01:54,300 --> 00:01:55,803
with the device mapper.

43
00:02:00,360 --> 00:02:03,843
You want to do the same thing, vgscan.

44
00:02:06,120 --> 00:02:07,500
See the volume groups that's currently created,

45
00:02:07,500 --> 00:02:08,433
only the CentOS.

46
00:02:10,433 --> 00:02:11,983
Then, I'm going to do the display.

47
00:02:13,290 --> 00:02:15,300
Again, showing us more information about the volume groups

48
00:02:15,300 --> 00:02:16,950
that are currently on the system.

49
00:02:21,000 --> 00:02:23,433
Last one will be the logical volume scan.

50
00:02:28,620 --> 00:02:32,133
Once more, logical volume display.

51
00:02:34,710 --> 00:02:36,390
Give us, again, more detailed information

52
00:02:36,390 --> 00:02:39,120
about the current logical volumes

53
00:02:39,120 --> 00:02:40,920
that are associated with the system.

54
00:02:42,210 --> 00:02:43,257
Now, we're going to hop right into creating

55
00:02:43,257 --> 00:02:45,180
the physical volumes.

56
00:02:45,180 --> 00:02:46,290
'Cause remember, we're going to layer this.

57
00:02:46,290 --> 00:02:48,559
So we're going to start with the physical volumes,

58
00:02:48,559 --> 00:02:50,340
then we're going to move to the volume groups,

59
00:02:50,340 --> 00:02:53,250
and then last the logical volumes.

60
00:02:53,250 --> 00:02:55,800
So let's start creating the physical volumes.

61
00:02:55,800 --> 00:02:58,740
So we want to do pvcreate.

62
00:02:58,740 --> 00:03:03,660
We want to use the hard disk that we used earlier

63
00:03:03,660 --> 00:03:04,760
that were partitioned.

64
00:03:06,450 --> 00:03:07,980
Sdb2.

65
00:03:07,980 --> 00:03:09,380
I partitioned these earlier.

66
00:03:11,160 --> 00:03:13,560
All right, looks like it's successfully created.

67
00:03:15,780 --> 00:03:17,793
Now, let's just verify that, pvdisplay.

68
00:03:21,390 --> 00:03:23,840
And now, we see we have the new physical volumes.

69
00:03:26,100 --> 00:03:27,450
Next, we're going to create a volume group

70
00:03:27,450 --> 00:03:29,753
from the physical volumes that we just created.

71
00:03:31,200 --> 00:03:34,500
New volume group create, going to need the backup.

72
00:03:34,500 --> 00:03:37,020
Going to use ones we just created,

73
00:03:37,020 --> 00:03:38,043
sdb1,

74
00:03:39,379 --> 00:03:43,023
/dev/sdb2.

75
00:03:44,550 --> 00:03:47,430
All right, so we have the volume group successfully created,

76
00:03:47,430 --> 00:03:49,500
so let's display that here.

77
00:03:49,500 --> 00:03:50,973
Do the quick one, the scan,

78
00:03:52,230 --> 00:03:55,533
and then we can also do the display command.

79
00:03:59,460 --> 00:04:01,383
All right, we see that it's created.

80
00:04:02,400 --> 00:04:04,307
The last thing we want to do is create three logical volumes

81
00:04:04,307 --> 00:04:06,783
to associate it with the new volume group.

82
00:04:09,880 --> 00:04:10,833
lvcreate.

83
00:04:12,030 --> 00:04:13,860
Create the name here.

84
00:04:13,860 --> 00:04:15,243
Going to do a system backup.

85
00:04:17,490 --> 00:04:18,663
Size,

86
00:04:20,940 --> 00:04:22,089
just going to give 'em all

87
00:04:23,100 --> 00:04:24,363
two gigabytes for now.

88
00:04:26,730 --> 00:04:29,823
And we're going to associate it with the backup volume group.

89
00:04:32,370 --> 00:04:33,920
Yep, going to accept this warning.

90
00:04:35,490 --> 00:04:38,850
All right, looks like that was successfully created.

91
00:04:38,850 --> 00:04:40,260
Going to do one more.

92
00:04:40,260 --> 00:04:42,580
Going to change the name to the data backup

93
00:04:46,230 --> 00:04:50,853
Created one more for the log.

94
00:04:55,860 --> 00:04:56,693
Wipe it.

95
00:04:58,260 --> 00:04:59,280
Okay.

96
00:04:59,280 --> 00:05:00,573
Now let's do a scan,

97
00:05:03,810 --> 00:05:06,900
and now we can see they we're all successfully created.

98
00:05:06,900 --> 00:05:09,000
Sometimes it will be necessary to extend

99
00:05:09,000 --> 00:05:11,370
or reduce the volume size

100
00:05:11,370 --> 00:05:12,630
and to do this you want to simply use

101
00:05:12,630 --> 00:05:13,480
the lvextend

102
00:05:17,058 --> 00:05:18,330
and the -l option,

103
00:05:18,330 --> 00:05:21,000
this is what the new size is going to be.

104
00:05:21,000 --> 00:05:25,320
So we're going to extend the data backup to three gigabytes.

105
00:05:25,320 --> 00:05:26,153
Okay?

106
00:05:27,990 --> 00:05:28,823
Dev,

107
00:05:31,140 --> 00:05:32,117
data backup.

108
00:05:34,470 --> 00:05:36,413
All right, looks like that went through.

109
00:05:37,920 --> 00:05:41,070
Next, we want to reduce the log backup file.

110
00:05:41,070 --> 00:05:41,903
So we'll do

111
00:05:44,160 --> 00:05:46,440
reduce again.

112
00:05:46,440 --> 00:05:50,013
Want to reduce it to one gig.

113
00:05:51,690 --> 00:05:54,183
Device backup.

114
00:05:55,560 --> 00:05:56,703
Log back.

115
00:05:58,080 --> 00:06:00,390
All right, we'll accept the warning here,

116
00:06:00,390 --> 00:06:03,090
and we'll see it successfully changed from two to one.

117
00:06:03,090 --> 00:06:05,130
So let's just verify this really quick.

118
00:06:05,130 --> 00:06:05,963
Do

119
00:06:08,327 --> 00:06:09,160
display,

120
00:06:10,290 --> 00:06:15,090
and now we can see that the log backup is one gigabyte

121
00:06:15,090 --> 00:06:19,110
and the data backup is three gigabytes now.

122
00:06:19,110 --> 00:06:20,730
The last thing we want to do is

123
00:06:20,730 --> 00:06:23,460
to create a file system on these volumes

124
00:06:23,460 --> 00:06:24,960
that we just created.

125
00:06:24,960 --> 00:06:29,853
So we'll do make file system, use .xfs for the first one.

126
00:06:33,981 --> 00:06:34,814
Dev,

127
00:06:36,217 --> 00:06:38,717
for the /systemback

128
00:06:39,600 --> 00:06:41,450
Okay, that went through successfully.

129
00:06:43,350 --> 00:06:45,783
Going to make a file system using .ext4.

130
00:06:48,085 --> 00:06:49,803
Going to use that for the data backup.

131
00:06:55,260 --> 00:06:57,183
Data backup.

132
00:06:59,670 --> 00:07:01,020
Okay, that's went through successfully.

133
00:07:01,020 --> 00:07:03,900
We'll do the same thing for the log system.

134
00:07:03,900 --> 00:07:06,663
So we're going to scroll up, change this to log.

135
00:07:13,107 --> 00:07:16,080
And looks like that went through as well.

136
00:07:16,080 --> 00:07:20,190
So to summarize, we went through creating fiscal volumes,

137
00:07:20,190 --> 00:07:22,920
volume groups, and logical volumes.

138
00:07:22,920 --> 00:07:26,160
We also created file systems on those volumes

139
00:07:26,160 --> 00:07:27,270
and now we can use them just

140
00:07:27,270 --> 00:07:28,860
like they were a regular hard disc.

141
00:07:28,860 --> 00:07:30,660
And I'll see you in the next lesson.

