1
00:00:00,000 --> 00:00:17,879
Hey guys and welcome back. So in this scale what I want to talk to you about is all about

2
00:00:17,879 --> 00:00:23,519
the subject of storage. Now one big subject that we have to understand for the purposes

3
00:00:23,519 --> 00:00:30,559
of the LPIC2 examination is the concept of RAID. Now RAID stands for a redundant array

4
00:00:30,559 --> 00:00:37,640
of independent disks and it is primarily focused around fault tolerance. Now I say primarily

5
00:00:37,640 --> 00:00:44,000
because not all RAID devices actually are fault tolerant which may be a little bit confusing

6
00:00:44,000 --> 00:00:49,359
but we'll get to see what that means very very shortly. Now two big concepts we really

7
00:00:49,359 --> 00:00:56,359
want to have distinguished right here. We have the ability to invoke hardware RAID and

8
00:00:56,359 --> 00:01:01,960
when we're talking about hardware RAID this is controlled by a hardware controller and

9
00:01:01,960 --> 00:01:08,200
when we're talking about hardware RAID this is also going to be a more expensive implementation.

10
00:01:08,200 --> 00:01:14,319
Now alternatively we have the option to invoke what is called software RAID and this is really

11
00:01:14,319 --> 00:01:19,239
what we're going to be primarily focused on. So what we're talking about when we mention

12
00:01:19,239 --> 00:01:24,319
software RAID ultimately what we're doing is we're talking about when the kernel itself

13
00:01:24,319 --> 00:01:29,319
actually does the job of the hardware RAID controller. Now the advantage here is that

14
00:01:29,319 --> 00:01:35,919
when we invoke software RAID there is absolutely no need for any type of special hardware. Simply

15
00:01:35,919 --> 00:01:41,919
put we can just do this all within our Linux based system and it is very very good. Now

16
00:01:41,919 --> 00:01:46,359
if you know anything about RAID if you have some awareness of it you will know that we

17
00:01:46,359 --> 00:01:52,959
have different RAID levels and these ultimately provide to us different abilities with respect

18
00:01:52,959 --> 00:01:58,120
to performance and with respect to fault tolerance. So let's talk about some of these different

19
00:01:58,120 --> 00:02:04,039
RAID levels that we have available to us and what are their advantages and disadvantages

20
00:02:04,039 --> 00:02:11,120
when you would want to use one or the other. Now the first RAID level is called RAID 0.

21
00:02:11,120 --> 00:02:17,000
This is otherwise known as striping. So if you hear the term striping you want to be

22
00:02:17,000 --> 00:02:23,240
thinking about RAID level 0. Now remember when I said RAID was primarily about fault

23
00:02:23,240 --> 00:02:29,280
tolerance but not always. In fact with RAID you may have no level of fault tolerance.

24
00:02:29,280 --> 00:02:35,040
What I'm talking about is this level right here. The way I like to remember RAID is that

25
00:02:35,159 --> 00:02:42,879
it gives you zero fault tolerance. So the data is copied zero times. So why in earth

26
00:02:42,879 --> 00:02:48,759
would anyone want to use RAID 0 if it does not provide us fault tolerance. Well RAID

27
00:02:48,759 --> 00:02:55,199
0 is an example of RAID whereby we are looking at performance. So let me show you how this

28
00:02:55,199 --> 00:03:01,280
would kind of shake out. Let's imagine that we had two different hard disks. So we've

29
00:03:01,280 --> 00:03:10,960
got disk one here and disk two one and two. Now if we happen to write data to a disk or

30
00:03:10,960 --> 00:03:16,599
read data from a disk that does take some time of course. If we wrote the first piece

31
00:03:16,599 --> 00:03:22,680
of data to disk one and then once that was done we could write the second piece of data

32
00:03:22,680 --> 00:03:28,920
and then the third and then the fourth so on so forth. Now we absolutely could do this

33
00:03:28,959 --> 00:03:33,239
and if we wanted to read that data we would read from this part of the disk and then read

34
00:03:33,239 --> 00:03:37,560
this part and then read this part and then read this part. You kind of get the drift.

35
00:03:37,560 --> 00:03:44,839
Now if we happen to invoke RAID 0 what would actually happen is we would utilize two different

36
00:03:44,839 --> 00:03:50,199
disks here. So what we could actually do is we could write the first part of data to this

37
00:03:50,199 --> 00:03:57,000
disk and write the second part to this disk and then write the third to this and then

38
00:03:57,039 --> 00:04:02,800
write the fourth to this. Now ultimately what you're doing here is you are striping the data

39
00:04:02,800 --> 00:04:07,439
across different disks. You're putting a little bit here and a little bit here and then a little

40
00:04:07,439 --> 00:04:13,560
bit here and a little bit here. The effect of this is this improves performance like I say. It

41
00:04:13,560 --> 00:04:20,120
improves the ability to read the data as well as it improves performance with respect to writing

42
00:04:20,120 --> 00:04:26,920
data. The reason why this is is because the data can be read and written to concurrently.

43
00:04:27,480 --> 00:04:33,639
So we can do things in parallel as opposed to sequentially. The problem though is that this

44
00:04:33,639 --> 00:04:39,280
actually is not just giving us no fault tolerance. It's actually reducing our fault

45
00:04:39,280 --> 00:04:46,319
tolerance because if we happen to have disk one here and disk two here we write the first part

46
00:04:46,360 --> 00:04:51,599
here the next chunk of data here at the same time we write the third and then the fourth.

47
00:04:51,599 --> 00:04:57,159
You kind of get the drift. Well if we happen to have some type of fault on this one disk and

48
00:04:57,159 --> 00:05:03,199
this disk becomes unreadable and corrupted then because we have never actually written any full

49
00:05:03,199 --> 00:05:09,439
data to one disk but only written little parts of that data ultimately the data here is also

50
00:05:09,439 --> 00:05:16,240
unusable. Okay so we have two disks which are working for high performance but if only one

51
00:05:16,240 --> 00:05:21,439
of those disks gets damaged the data which is being chopped up and spread across the two disks

52
00:05:21,439 --> 00:05:27,040
is ultimately unusable. This one because the device itself is actually broken and this one

53
00:05:27,040 --> 00:05:32,639
becomes unusable because you only have half the data you need stored on it so the data cannot be

54
00:05:32,639 --> 00:05:40,079
recovered. As such because of this RAID 0 is rarely used. Now one other thing we also want to be

55
00:05:40,079 --> 00:05:46,079
aware of with respect to RAID 0 is that both disks really should be the same size because if you

56
00:05:46,079 --> 00:05:53,039
have disks which are different sizes acting as a RAID 0 array then ultimately what is going to happen

57
00:05:53,039 --> 00:05:58,719
is that you're going to have wasted and unusable space on the larger disk so it isn't really

58
00:05:58,719 --> 00:06:04,079
efficient at all to do such a thing. So you can imagine if you happen to have one disk which was

59
00:06:04,079 --> 00:06:11,680
10 gigs and a larger disk which was 30 gigs and you put these two in a RAID 0 array you could only

60
00:06:11,680 --> 00:06:19,439
use up to 10 gigabits. That would mean that whilst this part is used you're going to have 20 gig

61
00:06:19,439 --> 00:06:25,439
unused on this disk and effectively just wasted. So another consideration to think about if you

62
00:06:25,439 --> 00:06:31,680
happen to choose to go with a RAID 0 array. Now let's move on to the next one this one is called

63
00:06:31,680 --> 00:06:38,000
RAID 1. Now RAID 1 actually does give us fault tolerance the way I like to think of RAID 1 is

64
00:06:38,000 --> 00:06:44,800
that it gives us one full copy of our data this is otherwise known as mirroring because quite

65
00:06:44,800 --> 00:06:49,920
simply what you're going to do is you're going to mirror the data across different disks. So think

66
00:06:49,920 --> 00:06:56,560
about this if we happen to have let's say again disk number one and then disk number two when we

67
00:06:56,560 --> 00:07:03,600
write some data to the first disk we would write an exact copy to the second disk so data piece one

68
00:07:03,600 --> 00:07:10,240
here data piece one here and then we write data two then the second piece of data the exact copy

69
00:07:10,240 --> 00:07:17,840
on the other disk and then three and three you kind of get the drift. Now you actually do get a little

70
00:07:17,840 --> 00:07:24,400
bit of a performance advantage here using RAID 1 but only when talking about reading data the reason

71
00:07:24,400 --> 00:07:30,080
why is that you can actually read data from different disks and actually involve some concurrency.

72
00:07:30,079 --> 00:07:37,599
So you do get a performance increase for reading data but there is no increase with respect to

73
00:07:37,599 --> 00:07:43,759
writing simply because you're just having to rewrite the same data over multiple locations.

74
00:07:43,759 --> 00:07:50,240
Now the big advantage here though is that we absolutely do have redundancy here because if we

75
00:07:50,240 --> 00:07:57,599
think about it if we go back to our analogy we have disk one here and disk two with data one

76
00:07:57,600 --> 00:08:04,400
second piece of data and like you say the third one two three if this disk fails and completely

77
00:08:04,400 --> 00:08:10,080
breaks well the good news is is that we have an exact replica on this disk and all the data is

78
00:08:10,080 --> 00:08:16,800
still accessible. Now using software RAID 1 this is very common this is one of the more popular

79
00:08:16,800 --> 00:08:23,840
implementations of RAID simply because hard disks are fairly cheap so it's inexpensive and it provides

80
00:08:23,839 --> 00:08:29,839
you an easy way to have some fault tolerance with respect to your potentially very valuable data.

81
00:08:29,839 --> 00:08:37,439
Next we have a very popular RAID implementation called RAID 5. Now RAID 5 is a very good option

82
00:08:37,439 --> 00:08:44,720
because it gives us an increase in performance and it also gives us redundancy. The unfortunate part

83
00:08:44,720 --> 00:08:51,039
here about RAID 5 though is that you need at least three disks as a minimum to be able to invoke RAID

84
00:08:51,599 --> 00:08:58,399
5. So let's say we had these three disks here we've got disk one, disk two and then disk three.

85
00:08:58,399 --> 00:09:03,439
So the way the data would be written is you could write the first part here to disk one and then the

86
00:09:03,439 --> 00:09:10,079
second part to disk two and then the third part here to disk three and then you would add in

87
00:09:10,639 --> 00:09:17,199
something called a parity block. Now what this parity data is it's simply just data that has

88
00:09:17,200 --> 00:09:22,720
been derived from the other data stored on the other devices. Now I'll explain how that works

89
00:09:22,720 --> 00:09:27,600
in a little second so after we write our parity block we continue on writing your data we would

90
00:09:27,600 --> 00:09:34,240
write the fourth bit here and then the fifth bit and then the sixth bit and then we would write

91
00:09:34,240 --> 00:09:41,040
another parity block and then they continue on writing the seventh bit of data the eighth the

92
00:09:41,039 --> 00:09:47,519
ninth and then again a another parity block. Now you'll notice here that this behavior is

93
00:09:47,519 --> 00:09:54,319
ultimately a round robin okay. What we're doing is we're splitting all the data gradually across

94
00:09:54,319 --> 00:10:00,159
all the disks and this is the same for the parity block. Now the purpose of the parity block means

95
00:10:00,159 --> 00:10:06,159
that if one disk happened to be destroyed we could actually still reconstruct the data because of

96
00:10:06,240 --> 00:10:12,719
those parity values. Let me give you a rough analogy as to how this is happening. Let's say I had

97
00:10:12,719 --> 00:10:20,719
three pieces of information here I say one plus five equals six okay that's three pieces of information

98
00:10:20,719 --> 00:10:26,159
and you can imagine that spread across three different disks. Now let's say one disk was

99
00:10:26,159 --> 00:10:32,639
destroyed this one here okay so now you no longer know what this number is but the reality is based

100
00:10:32,639 --> 00:10:38,799
on the information we have on the other disks we can compare this information and we can actually

101
00:10:38,799 --> 00:10:45,840
work out the value here we can say one plus something equals six well what does that actually mean

102
00:10:45,840 --> 00:10:52,799
one plus five would equal six so even though this disk happens to be destroyed we can reconstruct it

103
00:10:52,799 --> 00:10:58,000
and we would know the value here was five this is ultimately what is happening with respect to

104
00:10:58,080 --> 00:11:05,360
our parity block we can reconstruct the data based on the other data on the other redundant disks

105
00:11:05,360 --> 00:11:12,159
and like I say RAID five very very common indeed but like I say in order to be able to invoke this

106
00:11:12,159 --> 00:11:19,759
type of parity analysis we need at least three different disks so next we would go to RAID 10

107
00:11:19,759 --> 00:11:27,679
and the way you can think of RAID 10 as it's like RAID 1 plus RAID 0 so with respect to RAID 10

108
00:11:27,759 --> 00:11:34,399
we get all the performance of RAID 0 so that includes both reading and writing so performance

109
00:11:34,399 --> 00:11:40,879
both ways there and the redundancy of having a full mirror just like we get with RAID 1 so

110
00:11:40,879 --> 00:11:47,599
how in earth is this actually invoked well one of the disadvantages of having to use RAID 10

111
00:11:47,599 --> 00:11:55,039
is that you need a minimum of four different disks here so we'd have one two and then three and four

112
00:11:55,120 --> 00:12:02,000
now the way this actually operates is that we can have straight data that is mirrored now that

113
00:12:02,000 --> 00:12:06,079
sounds confusing but let me show you what I mean here so let's say we're writing our first piece

114
00:12:06,079 --> 00:12:11,679
of data let's say data piece number one but we're only writing the first half of that data and we

115
00:12:11,679 --> 00:12:18,399
mirror that onto our second disk so the first half of data so that data is now mirrored now we want

116
00:12:18,399 --> 00:12:25,439
to write the other half of that data over here so 1b but we want to mirror that information so we

117
00:12:25,439 --> 00:12:35,360
have 1b here then we can do 2a here and 2a here mirroring and like I say the data within here

118
00:12:35,360 --> 00:12:43,199
is going to be striped with the data over here so we would do 2b here and mirror it to be here

119
00:12:43,200 --> 00:12:49,440
so on so forth the point being is that if we happen to want to read let's say data number two

120
00:12:49,440 --> 00:12:56,160
here we could read the first part from either of these disks and get the second part from either of

121
00:12:56,160 --> 00:13:02,000
these disks so we can read concurrently and build the data now what would happen if one of these

122
00:13:02,000 --> 00:13:08,560
devices got destroyed well now 2b is away and 1b is away but it isn't actually because we still have

123
00:13:08,559 --> 00:13:15,359
a full copy of that data on an entire disk right here 1b and 2b and we can still use that to construct

124
00:13:15,359 --> 00:13:21,359
the information we have striped across these two disks here so like I say a lot of advantages with

125
00:13:21,359 --> 00:13:28,159
respect to raid 10 the problem is is that well you have to have a lot of disks to invoke this type

126
00:13:28,159 --> 00:13:34,559
of raid setup now one distinction I just want to make here is that whilst I have been describing

127
00:13:34,559 --> 00:13:40,159
this as using different disks you can absolutely use different partitions if you so choose now

128
00:13:40,159 --> 00:13:46,159
remember when we were using fdisk to create a linux partition we could create a linux partition or

129
00:13:46,159 --> 00:13:51,759
we could create something called a swap partition if we so choose we can also create a partition

130
00:13:51,759 --> 00:13:58,879
with a very particular label known as 0x fd now what happens is that when we mark a partition

131
00:13:58,879 --> 00:14:04,239
with this particular label what we are ultimately telling the system is hey I'm going to be

132
00:14:04,240 --> 00:14:10,240
a raid partition so you can imagine if you happen to have let's say disk number one sda

133
00:14:10,240 --> 00:14:16,720
partition one and you maybe have a second disk so sdb partition one you could mark both of these

134
00:14:16,720 --> 00:14:25,759
partitions as 0x fd 0x fd so that we can signal to a linux system that we are indeed a raid

135
00:14:25,759 --> 00:14:31,519
partition now here is the very cool thing here let's say we happen to have a particular server

136
00:14:31,519 --> 00:14:36,799
and maybe we had three different disks in here or three different partitions whatever it may be

137
00:14:36,799 --> 00:14:44,720
if they have that marking denoting them as a raid partition i.e. with the fd marking even if this

138
00:14:44,720 --> 00:14:50,879
actual server here itself let's say some internal component blows and the server is not operational

139
00:14:50,879 --> 00:14:56,480
what you could do is you could just open up this server grab these three devices which have been

140
00:14:56,480 --> 00:15:01,519
marked as a raid arrays and you could just slip them in to another server that's running linux

141
00:15:01,519 --> 00:15:08,159
and what that server will do it will automatically assemble these drives exactly as they were before

142
00:15:08,159 --> 00:15:13,120
so this is super super handy because if you think about it if you happen to have three different

143
00:15:13,120 --> 00:15:18,800
disks like i say and this was a debian server and for whatever reason this breaks you could pull

144
00:15:18,800 --> 00:15:24,879
these three out no problem at all and even if you go over to some type of red hat distribution and

145
00:15:24,879 --> 00:15:30,960
dump in those three disks automatically the system is going to detect they are raid arrays and

146
00:15:30,960 --> 00:15:36,480
assemble them no problem at all even though they came from a completely different operating system

147
00:15:36,480 --> 00:15:43,600
one being debian based one being red hat it does not matter so software raid really is a very very

148
00:15:43,600 --> 00:15:50,159
useful and important solution with respect to improving performance and primarily improving

149
00:15:50,159 --> 00:15:56,399
your resiliency to potential failures of your disk via redundancy so what we want to do now is to

150
00:15:56,399 --> 00:16:02,399
look at some of the basic configurations of how we can set up software raids on our linux machines

151
00:16:02,399 --> 00:16:06,559
that's what we'll be talking about in the very next nuggets i hope this has been informative for you

152
00:16:06,559 --> 00:16:12,799
and i'd like to thank you for viewing

