WEBVTT

1
00:00.000 --> 00:05.390
So friends, let's talk about another story solution, this one known as LVM, Log

2
00:05.390 --> 00:06.400
ical Volume

3
00:06.400 --> 00:10.670
Management. This happens to be one of my favourite technologies in all of Linux

4
00:10.670 --> 00:12.320
, so let's just dive

5
00:12.320 --> 00:16.630
in. So, you know the problem with storage, everyone wants more storage no

6
00:16.630 --> 00:18.080
matter how much you buy,

7
00:18.080 --> 00:22.800
eventually you always seem to run out. So the question is, is that when we

8
00:22.800 --> 00:24.000
happen to run out,

9
00:24.000 --> 00:28.120
how do we address that particular problem? Well, very often what you might do

10
00:28.120 --> 00:29.280
is just go and,

11
00:29.280 --> 00:34.480
you know, buy more storage that might be an external hard drive, maybe it's a
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

11
00:29.280 --> 00:34.480
you know, buy more storage that might be an external hard drive, maybe it's a

12
00:34.480 --> 00:35.040
USB pin,

13
00:35.040 --> 00:39.140
whatever it may be. Who knows, maybe you need a ton of storage and you go and

14
00:39.140 --> 00:40.800
buy a massive server.

15
00:40.800 --> 00:44.960
Now all of these are certainly viable options, they definitely do work, they

16
00:44.960 --> 00:46.480
will solve your problem,

17
00:46.480 --> 00:51.250
but is it the most efficient way to go about solving that particular problem?

18
00:51.250 --> 00:52.000
Let me give you a

19
00:52.000 --> 00:55.840
simple example, let's maybe say in your home you happen to have a spare drive

20
00:55.840 --> 00:57.200
that happens to have

21
00:57.200 --> 01:02.840
50 gigabytes on it. Now for whatever reason, you maybe need an additional 100
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

21
00:57.200 --> 01:02.840
50 gigabytes on it. Now for whatever reason, you maybe need an additional 100

22
01:02.840 --> 01:03.760
gig of storage,

23
01:03.760 --> 01:08.980
so as it stands right now, this particular storage device is not going to be

24
01:08.980 --> 01:09.920
good enough

25
01:09.920 --> 01:14.810
to handle the request or the requirement should I say of the 100 gig. So the

26
01:14.810 --> 01:16.240
temptation might be to

27
01:16.240 --> 01:20.610
think that the 50 gigabyte one is useless and what you might have to do is to

28
01:20.610 --> 01:21.760
go and buy a brand

29
01:21.760 --> 01:27.290
new fresh 100 gig bit of storage via an external hard drive via a USB whatever

30
01:27.290 --> 01:28.640
it may be. Now what

31
01:28.640 --> 01:34.250
if I told you that even though the 50 gig by itself is not sufficient to cover
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

31
01:28.640 --> 01:34.250
if I told you that even though the 50 gig by itself is not sufficient to cover

32
01:34.250 --> 01:35.440
all your storage

33
01:35.440 --> 01:40.180
needs, but it can be used in conjunction to support that particular solution

34
01:40.180 --> 01:41.440
that you're looking for?

35
01:41.440 --> 01:45.680
Well, I'm actually hinting at the use of LVM because that is going to allow us

36
01:45.680 --> 01:46.560
to make use of

37
01:46.560 --> 01:51.770
disparate physical storage devices and effectively aggregate them and it is

38
01:51.770 --> 01:53.280
this type of aggregation

39
01:53.280 --> 01:57.120
that is going to allow us to make use of in the example we just saw the 50 gig

40
01:57.120 --> 01:58.480
abyte storage device

41
01:58.480 --> 02:02.320
that would ultimately be rather useless. So you're now here that you can make
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

41
01:58.480 --> 02:02.320
that would ultimately be rather useless. So you're now here that you can make

42
02:02.320 --> 02:03.280
use of these old

43
02:03.280 --> 02:07.870
storage devices. You go rummaging through your house and you find even more old

44
02:07.870 --> 02:09.120
storage devices.

45
02:09.120 --> 02:15.210
So like I say you have your 50 gig storage device, maybe you find three more 10

46
02:15.210 --> 02:15.840
gigabyte

47
02:15.840 --> 02:22.230
ones. So in reality what we actually have here is a total of 80 gig of storage

48
02:22.230 --> 02:23.040
space that is not

49
02:23.040 --> 02:27.280
being used. So as opposed to having to go out and buy one contiguous block of

50
02:27.280 --> 02:29.200
100 gig storage space,

51
02:29.200 --> 02:33.790
what if we just jump out and buy a fairly cheap 20 gig storage device?
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

51
02:29.200 --> 02:33.790
what if we just jump out and buy a fairly cheap 20 gig storage device?

52
02:33.790 --> 02:34.080
Certainly more

53
02:34.080 --> 02:38.760
but cheaper than the 100 gig and all we will do is we will use this new

54
02:38.760 --> 02:40.640
purchase in conjunction

55
02:40.640 --> 02:45.490
with remaining 80 gig storage that we just found laying about the house. So

56
02:45.490 --> 02:46.560
like I have hinted

57
02:46.560 --> 02:50.400
that this is all going to be enabled via logical volume management but we have

58
02:50.400 --> 02:51.360
to understand the

59
02:51.360 --> 02:55.770
constituent concepts that make up the LVM architecture. Now the first concept

60
02:55.770 --> 02:56.400
we have to

61
02:56.400 --> 03:01.760
understand is something known as a PV otherwise known as a physical volume. Now
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

61
02:56.400 --> 03:01.760
understand is something known as a PV otherwise known as a physical volume. Now

62
03:01.760 --> 03:02.720
the PV's are the

63
03:02.720 --> 03:07.100
actual physical discs that we're going to use for storage. So in my case here

64
03:07.100 --> 03:08.240
my 50 gig storage

65
03:08.240 --> 03:13.700
device would become an LVM physical volume. Same with the 310 gig and the newly

66
03:13.700 --> 03:15.280
purchased 20 gig

67
03:15.280 --> 03:19.070
storage device they would all be my physical volumes. That's the first concept

68
03:19.070 --> 03:20.320
in the architecture.

69
03:20.320 --> 03:25.570
The next concept is the VG. This is known as the volume group. Now the volume

70
03:25.570 --> 03:26.320
group is quite

71
03:26.320 --> 03:32.310
simply the aggregation of those physical volumes. So realistically the volume
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

71
03:26.320 --> 03:32.310
simply the aggregation of those physical volumes. So realistically the volume

72
03:32.310 --> 03:33.440
group is going to be

73
03:33.440 --> 03:37.510
the combined result of the physical volumes grouped together. It's going to

74
03:37.510 --> 03:39.760
give us one big logical

75
03:39.760 --> 03:45.660
blob of storage. So imagine it like this. Here is our 50 gig storage device,

76
03:45.660 --> 03:46.800
here is our 20 gig

77
03:46.800 --> 03:52.270
storage device and then we have our 310 gig storage devices. Individually they

78
03:52.270 --> 03:54.160
are all physical volumes

79
03:54.160 --> 03:59.640
but via the technology of LVM logically what they become is this big contiguous

80
03:59.640 --> 04:00.880
chunk of storage
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

80
03:59.640 --> 04:00.880
chunk of storage

81
04:00.880 --> 04:05.040
at 100 gig. That would be the volume group. Now that is just two components of

82
04:05.040 --> 04:05.760
the architecture.

83
04:05.760 --> 04:09.520
We have one more component we have to understand and that is how we are going

84
04:09.520 --> 04:11.600
to effectively subdivide

85
04:11.600 --> 04:16.800
this volume group because just because we have aggregated these physical discs.

86
04:16.800 --> 04:21.420
And to one big blob doesn't mean we have to use it as one big blob we can

87
04:21.420 --> 04:22.400
logically subdivide

88
04:22.400 --> 04:27.770
this into many smaller chunks. We could effectively chop it up into equal sizes

89
04:27.770 --> 04:28.800
if we so wish.

90
04:28.800 --> 04:33.100
Let's say we wanted to quarter it. Then we could have four equally sized
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

90
04:28.800 --> 04:33.100
Let's say we wanted to quarter it. Then we could have four equally sized

91
04:33.100 --> 04:34.800
partitions made up of all

92
04:34.800 --> 04:40.470
of these asymmetric physical volumes. A 50 and a 20 and a 10 10 10 suddenly

93
04:40.470 --> 04:42.240
been able to be subdivided

94
04:42.240 --> 04:47.990
into 425 gig partitions. These particular partitions carved out of the volume

95
04:47.990 --> 04:48.960
group would be the

96
04:48.960 --> 04:53.020
logical volumes. Now one thing to note is that we don't actually have to subdiv

97
04:53.020 --> 04:54.080
ide these in a

98
04:54.080 --> 04:58.490
symmetric manner. What we could do is I could maybe create one partition space

99
04:58.490 --> 05:00.640
of 75 gig and then
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

99
04:58.490 --> 05:00.640
of 75 gig and then

100
05:00.640 --> 05:04.770
for the remaining 25 gig I could create another partition which is only 10 in

101
05:04.770 --> 05:06.320
size and another

102
05:06.320 --> 05:13.120
which is 15 in size. Now we effectively have three partitions of varying size

103
05:13.120 --> 05:14.160
of carved out from

104
05:14.160 --> 05:20.050
the 100 gigabyte volume group. This is the type of flexibility that we get with

105
05:20.050 --> 05:20.400
LVM.

106
05:20.400 --> 05:24.090
So with that primer out the way let's dive in and begin it seeing how we can

107
05:24.090 --> 05:24.560
automate this

108
05:24.560 --> 05:29.370
particular process. So if you search for the Ansible LVM module if we click

109
05:29.370 --> 05:30.800
this link right here once
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

109
05:29.370 --> 05:30.800
this link right here once

110
05:30.800 --> 05:34.580
again this is going to be part of the Ansible Community General module

111
05:34.580 --> 05:36.160
collection. And notice

112
05:36.160 --> 05:41.150
here what this particular module does it allows you to create remove or resize

113
05:41.150 --> 05:42.480
volume groups that

114
05:42.480 --> 05:47.110
has our VGs. So once again you can go through all of the particular parameters

115
05:47.110 --> 05:48.000
to see how we can

116
05:48.000 --> 05:52.530
actually use this particular option. Notice we have this PVS option here. And

117
05:52.530 --> 05:53.040
this allows us to

118
05:53.040 --> 05:57.910
specify which physical volumes i.e. which actual disks should be combined to

119
05:57.910 --> 05:59.440
make the volume group.

120
05:59.440 --> 06:04.330
And this is going to be accepted in the form of a list comprising of strings.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

120
05:59.440 --> 06:04.330
And this is going to be accepted in the form of a list comprising of strings.

121
06:04.330 --> 06:05.520
Notice the very

122
06:05.520 --> 06:10.220
important option here specifying VG. This is a require parameter and this is

123
06:10.220 --> 06:11.600
going to be the name

124
06:11.600 --> 06:14.680
of the volume group. So here is what I'm going to do. I'm first going to shut

125
06:14.680 --> 06:15.600
down my blue box

126
06:15.600 --> 06:19.100
right now. I'm going to add in some new devices once again. So I'll go to my

127
06:19.100 --> 06:20.160
options here. Click

128
06:20.160 --> 06:24.670
settings. I'm going to go to hard disk and then I will choose add a device and

129
06:24.670 --> 06:25.600
I'll choose a new

130
06:25.600 --> 06:30.570
hard disk and then select add. I'm going to give this one a size of let's maybe
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

130
06:25.600 --> 06:30.570
hard disk and then select add. I'm going to give this one a size of let's maybe

131
06:30.570 --> 06:31.840
say 3GB and I will

132
06:31.840 --> 06:36.720
choose apply. If I go back to show all I can choose hard disk again. Select add

133
06:36.720 --> 06:37.760
a device. Choose

134
06:37.760 --> 06:41.890
another new hard disk. Add it. And let's just maybe make this one 4GB so it's a

135
06:41.890 --> 06:42.800
little bit different

136
06:42.800 --> 06:46.520
okay. So let's apply this to kill. So if I parallel this back on again give it

137
06:46.520 --> 06:47.520
a moment to boot up.

138
06:47.520 --> 06:52.480
So now if I log into this device. So if I just say so though parted dash L and

139
06:52.480 --> 06:53.440
type in the password

140
06:53.440 --> 06:58.630
for the user. As we can see we have dev NVMe 0n3. We have the actual size right

141
06:58.630 --> 06:59.680
here. And if I

142
06:59.680 --> 07:05.980
just scroll on up a little bit further we can actually see NVMe 0n4 which has a
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

142
06:59.680 --> 07:05.980
just scroll on up a little bit further we can actually see NVMe 0n4 which has a

143
07:05.980 --> 07:07.360
different storage

144
07:07.360 --> 07:11.320
capacity. These are the two physical disks that I'm going to combine to make a

145
07:11.320 --> 07:12.080
volume group.

146
07:12.080 --> 07:15.520
So let's go back to my control machine here. So let's create a playbook called

147
07:15.520 --> 07:16.640
play3.yml.

148
07:16.640 --> 07:20.070
Going to insert mode have a three hyphens at the top give the playbook in name

149
07:20.070 --> 07:20.960
as per usual.

150
07:20.960 --> 07:25.520
I should call this play3lvmstuff. And all I'm going to do is I'll target the

151
07:25.520 --> 07:26.560
blue box in this case

152
07:26.560 --> 07:30.260
here but not actually added the devices for the yellow box. And in the case
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

152
07:26.560 --> 07:30.260
here but not actually added the devices for the yellow box. And in the case

153
07:30.260 --> 07:31.120
here I will just say

154
07:31.120 --> 07:35.310
gather facts as false to keep things nice and fast. And now I'll begin defining

155
07:35.310 --> 07:36.160
my task of the first

156
07:36.160 --> 07:40.940
task. It's going to be create a vg. Now what we're going to use we're going to

157
07:40.940 --> 07:44.800
use the community.general.lvg

158
07:44.800 --> 07:48.350
module. And we're going to have to specify a few things. The first thing is I'm

159
07:48.350 --> 07:49.040
going to say that

160
07:49.040 --> 07:53.170
the state should be present. We have to specify the volume group name. I'll

161
07:53.170 --> 07:54.480
just call this nugget

162
07:54.480 --> 07:58.480
storage. And now I'll specify my physical volumes that are going to comprise of

163
07:58.480 --> 07:58.960
the script. Now

164
07:58.960 --> 08:02.950
remember it's going to be in the form of a list object. So here's my hyphen.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

164
07:58.960 --> 08:02.950
remember it's going to be in the form of a list object. So here's my hyphen.

165
08:02.950 --> 08:03.920
And the first disk

166
08:03.920 --> 08:12.280
is going to be dev nvm3. And the second one is going to be dev nvm4. So with

167
08:12.280 --> 08:13.280
that now done we

168
08:13.280 --> 08:18.460
should be able to create a volume group. So I will say answerable play3.yml and

169
08:18.460 --> 08:19.120
to enter.

170
08:19.120 --> 08:26.160
Oh and I have a typo right here. Let me go in. That should be nvm3. But silly

171
08:26.160 --> 08:27.040
there. Try that

172
08:27.040 --> 08:31.780
entirely again. Switch these around. Write the changes. Arrow up and try again.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

172
08:27.040 --> 08:31.780
entirely again. Switch these around. Write the changes. Arrow up and try again.

173
08:31.780 --> 08:32.560
And this looks

174
08:32.560 --> 08:36.400
a lot healthier. We have a change. So let's go here. Go back to the blue box.

175
08:36.400 --> 08:37.760
If I just say

176
08:37.760 --> 08:42.680
pseudo VGS, we can actually see the volume group that we have created. Check

177
08:42.680 --> 08:43.600
this out. Nugget

178
08:43.600 --> 08:47.580
storage. And we can see here the size is seven gig because we have one device

179
08:47.580 --> 08:48.800
that comprises of

180
08:48.800 --> 08:53.950
three gig storage. And another which comprises of four four and three gives us

181
08:53.950 --> 08:54.560
that logical

182
08:54.560 --> 08:59.450
grouping of seven gig storage space. Now right now we have a volume group. If

183
08:59.450 --> 09:00.480
you want to subdivide
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

183
08:59.450 --> 09:00.480
you want to subdivide

184
09:00.480 --> 09:04.840
that into our logical volumes, we have another module to do so. So if you

185
09:04.840 --> 09:06.000
search for answerable

186
09:06.000 --> 09:10.460
elvall, this particular module here once again from the same collection, this

187
09:10.460 --> 09:11.200
is going to allow

188
09:11.200 --> 09:15.590
us to create remove or resize logical volumes. So once again, we can go through

189
09:15.590 --> 09:16.160
all of the

190
09:16.160 --> 09:20.230
particular options, we can specify the name of the logical volume. We have

191
09:20.230 --> 09:21.280
options to resize

192
09:21.280 --> 09:25.360
file systems, that type of thing. We can specify should the state be present or

193
09:25.360 --> 09:26.400
absence. And notice

194
09:26.400 --> 09:30.230
very crucially, we have this required parameter of VG, which is going to take a
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

194
09:26.400 --> 09:30.230
very crucially, we have this required parameter of VG, which is going to take a

195
09:30.230 --> 09:31.280
string. Pretty much

196
09:31.280 --> 09:34.770
which volume group do we want to be carving up. Now one last thing, which is

197
09:34.770 --> 09:35.760
obviously important

198
09:35.760 --> 09:39.550
is the size of the logical volume. So we have our size parameter. And if we

199
09:39.550 --> 09:40.320
scroll on down,

200
09:40.320 --> 09:45.170
we can see some examples. So notice we can specify the size and units, i.e. we

201
09:45.170 --> 09:46.480
can specify megabytes

202
09:46.480 --> 09:50.980
in this case here, or the example below we can specify gigabytes. Or if we

203
09:50.980 --> 09:52.320
switch, we can specify

204
09:52.320 --> 09:57.120
the size as a percentage. One thing to note though, is if we happen to utilize

205
09:57.120 --> 09:58.160
a percentage as the

206
09:58.160 --> 10:02.920
size, the module is not going to act in an idempotent manner. So just be aware
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

206
09:58.160 --> 10:02.920
size, the module is not going to act in an idempotent manner. So just be aware

207
10:02.920 --> 10:04.080
of that if you choose

208
10:04.080 --> 10:07.740
to use that particular option. So let's go and see how this actually looks then

209
10:07.740 --> 10:08.640
. So what I will do

210
10:08.640 --> 10:13.630
is I'll go into my play three dot yml. And I'm going to have another task here.

211
10:13.630 --> 10:14.400
So let's give this a

212
10:14.400 --> 10:18.590
name. And I'll just say create first logical volume, the module will be

213
10:18.590 --> 10:20.720
community general, elvall,

214
10:20.720 --> 10:24.780
I'll specify that the VG I'm going to be targeting is going to be the nugget

215
10:24.780 --> 10:25.920
storage volume group.

216
10:25.920 --> 10:29.330
And I'll specify the name of this logical volume is going to be, let's just

217
10:29.330 --> 10:31.200
call it my first chunk.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

217
10:29.330 --> 10:31.200
call it my first chunk.

218
10:31.200 --> 10:36.310
Now specify the size of this logical volume. And let's say I want to create 512

219
10:36.310 --> 10:37.920
meg. So if I just

220
10:37.920 --> 10:41.910
happen to save this right here, and I run the playbook and to enter give it a

221
10:41.910 --> 10:42.960
moment. As we can

222
10:42.960 --> 10:46.160
see here, the volume group was already created, but we do have a change with

223
10:46.160 --> 10:47.280
respect to the logical

224
10:47.280 --> 10:51.750
volume. Let's go and inspect it. So we have our device, if I notice a pseudo V

225
10:51.750 --> 10:53.520
GS type in my password.

226
10:53.520 --> 10:58.400
Notice before the free space was pretty much seven gig. And now the free space

227
10:58.400 --> 11:00.240
is now 6.5 gig.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

227
10:58.400 --> 11:00.240
is now 6.5 gig.

228
11:00.240 --> 11:04.800
That's because if I now type the command pseudo LVS, we can actually see here I

229
11:04.800 --> 11:05.680
have created a

230
11:05.680 --> 11:10.480
logical volume called my first chunk carved out of the nugget storage volume

231
11:10.480 --> 11:13.520
group of the size 512

232
11:13.520 --> 11:17.160
meg. And if I wanted to create another chunk, what I could do is go back into

233
11:17.160 --> 11:18.080
the playbook.

234
11:18.080 --> 11:23.120
Let's give us a name. We'll just create second LV, use the same module specify

235
11:23.120 --> 11:24.000
we want to carve

236
11:24.000 --> 11:27.700
the next logical volume out of the same volume group. That is the nugget

237
11:27.700 --> 11:29.200
storage. I specify this

238
11:29.200 --> 11:35.280
logical volume here can be called, let's say my second bigger chunk. Okay. And
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

238
11:29.200 --> 11:35.280
logical volume here can be called, let's say my second bigger chunk. Okay. And

239
11:35.280 --> 11:36.320
this time the size

240
11:36.320 --> 11:41.140
is going to be what do we have left? We've got 6.5 left. Let's maybe go for a

241
11:41.140 --> 11:42.480
second volume of

242
11:42.480 --> 11:48.480
4G. Okay. So let's save this and run the playbook. Notice we have item potency

243
11:48.480 --> 11:49.760
on the first volume

244
11:49.760 --> 11:52.750
that was just skipped. But the creation of the second volume that actually

245
11:52.750 --> 11:53.760
invoked a change on

246
11:53.760 --> 11:58.360
the device. So let's go back. Now if I say pseudo VGS, the free space is now

247
11:58.360 --> 12:00.560
down to 2.5 gig. And if I
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

247
11:58.360 --> 12:00.560
down to 2.5 gig. And if I

248
12:00.560 --> 12:04.970
do pseudo LVS, notice we have a second logical volume once again carved out

249
12:04.970 --> 12:06.160
from the same storage

250
12:06.160 --> 12:08.480
chunk this time for gig and size.
