Hey guys and welcome back. So in this scale what I want to talk to you about is all about
the subject of storage. Now one big subject that we have to understand for the purposes
of the LPIC2 examination is the concept of RAID. Now RAID stands for a redundant array
of independent disks and it is primarily focused around fault tolerance. Now I say primarily
because not all RAID devices actually are fault tolerant which may be a little bit confusing
but we'll get to see what that means very very shortly. Now two big concepts we really
want to have distinguished right here. We have the ability to invoke hardware RAID and
when we're talking about hardware RAID this is controlled by a hardware controller and
when we're talking about hardware RAID this is also going to be a more expensive implementation.
Now alternatively we have the option to invoke what is called software RAID and this is really
what we're going to be primarily focused on. So what we're talking about when we mention
software RAID ultimately what we're doing is we're talking about when the kernel itself
actually does the job of the hardware RAID controller. Now the advantage here is that
when we invoke software RAID there is absolutely no need for any type of special hardware. Simply
put we can just do this all within our Linux based system and it is very very good. Now
if you know anything about RAID if you have some awareness of it you will know that we
have different RAID levels and these ultimately provide to us different abilities with respect
to performance and with respect to fault tolerance. So let's talk about some of these different
RAID levels that we have available to us and what are their advantages and disadvantages
when you would want to use one or the other. Now the first RAID level is called RAID 0.
This is otherwise known as striping. So if you hear the term striping you want to be
thinking about RAID level 0. Now remember when I said RAID was primarily about fault
tolerance but not always. In fact with RAID you may have no level of fault tolerance.
What I'm talking about is this level right here. The way I like to remember RAID is that
it gives you zero fault tolerance. So the data is copied zero times. So why in earth
would anyone want to use RAID 0 if it does not provide us fault tolerance. Well RAID
0 is an example of RAID whereby we are looking at performance. So let me show you how this
would kind of shake out. Let's imagine that we had two different hard disks. So we've
got disk one here and disk two one and two. Now if we happen to write data to a disk or
read data from a disk that does take some time of course. If we wrote the first piece
of data to disk one and then once that was done we could write the second piece of data
and then the third and then the fourth so on so forth. Now we absolutely could do this
and if we wanted to read that data we would read from this part of the disk and then read
this part and then read this part and then read this part. You kind of get the drift.
Now if we happen to invoke RAID 0 what would actually happen is we would utilize two different
disks here. So what we could actually do is we could write the first part of data to this
disk and write the second part to this disk and then write the third to this and then
write the fourth to this. Now ultimately what you're doing here is you are striping the data
across different disks. You're putting a little bit here and a little bit here and then a little
bit here and a little bit here. The effect of this is this improves performance like I say. It
improves the ability to read the data as well as it improves performance with respect to writing
data. The reason why this is is because the data can be read and written to concurrently.
So we can do things in parallel as opposed to sequentially. The problem though is that this
actually is not just giving us no fault tolerance. It's actually reducing our fault
tolerance because if we happen to have disk one here and disk two here we write the first part
here the next chunk of data here at the same time we write the third and then the fourth.
You kind of get the drift. Well if we happen to have some type of fault on this one disk and
this disk becomes unreadable and corrupted then because we have never actually written any full
data to one disk but only written little parts of that data ultimately the data here is also
unusable. Okay so we have two disks which are working for high performance but if only one
of those disks gets damaged the data which is being chopped up and spread across the two disks
is ultimately unusable. This one because the device itself is actually broken and this one
becomes unusable because you only have half the data you need stored on it so the data cannot be
recovered. As such because of this RAID 0 is rarely used. Now one other thing we also want to be
aware of with respect to RAID 0 is that both disks really should be the same size because if you
have disks which are different sizes acting as a RAID 0 array then ultimately what is going to happen
is that you're going to have wasted and unusable space on the larger disk so it isn't really
efficient at all to do such a thing. So you can imagine if you happen to have one disk which was
10 gigs and a larger disk which was 30 gigs and you put these two in a RAID 0 array you could only
use up to 10 gigabits. That would mean that whilst this part is used you're going to have 20 gig
unused on this disk and effectively just wasted. So another consideration to think about if you
happen to choose to go with a RAID 0 array. Now let's move on to the next one this one is called
RAID 1. Now RAID 1 actually does give us fault tolerance the way I like to think of RAID 1 is
that it gives us one full copy of our data this is otherwise known as mirroring because quite
simply what you're going to do is you're going to mirror the data across different disks. So think
about this if we happen to have let's say again disk number one and then disk number two when we
write some data to the first disk we would write an exact copy to the second disk so data piece one
here data piece one here and then we write data two then the second piece of data the exact copy
on the other disk and then three and three you kind of get the drift. Now you actually do get a little
bit of a performance advantage here using RAID 1 but only when talking about reading data the reason
why is that you can actually read data from different disks and actually involve some concurrency.
So you do get a performance increase for reading data but there is no increase with respect to
writing simply because you're just having to rewrite the same data over multiple locations.
Now the big advantage here though is that we absolutely do have redundancy here because if we
think about it if we go back to our analogy we have disk one here and disk two with data one
second piece of data and like you say the third one two three if this disk fails and completely
breaks well the good news is is that we have an exact replica on this disk and all the data is
still accessible. Now using software RAID 1 this is very common this is one of the more popular
implementations of RAID simply because hard disks are fairly cheap so it's inexpensive and it provides
you an easy way to have some fault tolerance with respect to your potentially very valuable data.
Next we have a very popular RAID implementation called RAID 5. Now RAID 5 is a very good option
because it gives us an increase in performance and it also gives us redundancy. The unfortunate part
here about RAID 5 though is that you need at least three disks as a minimum to be able to invoke RAID
5. So let's say we had these three disks here we've got disk one, disk two and then disk three.
So the way the data would be written is you could write the first part here to disk one and then the
second part to disk two and then the third part here to disk three and then you would add in
something called a parity block. Now what this parity data is it's simply just data that has
been derived from the other data stored on the other devices. Now I'll explain how that works
in a little second so after we write our parity block we continue on writing your data we would
write the fourth bit here and then the fifth bit and then the sixth bit and then we would write
another parity block and then they continue on writing the seventh bit of data the eighth the
ninth and then again a another parity block. Now you'll notice here that this behavior is
ultimately a round robin okay. What we're doing is we're splitting all the data gradually across
all the disks and this is the same for the parity block. Now the purpose of the parity block means
that if one disk happened to be destroyed we could actually still reconstruct the data because of
those parity values. Let me give you a rough analogy as to how this is happening. Let's say I had
three pieces of information here I say one plus five equals six okay that's three pieces of information
and you can imagine that spread across three different disks. Now let's say one disk was
destroyed this one here okay so now you no longer know what this number is but the reality is based
on the information we have on the other disks we can compare this information and we can actually
work out the value here we can say one plus something equals six well what does that actually mean
one plus five would equal six so even though this disk happens to be destroyed we can reconstruct it
and we would know the value here was five this is ultimately what is happening with respect to
our parity block we can reconstruct the data based on the other data on the other redundant disks
and like I say RAID five very very common indeed but like I say in order to be able to invoke this
type of parity analysis we need at least three different disks so next we would go to RAID 10
and the way you can think of RAID 10 as it's like RAID 1 plus RAID 0 so with respect to RAID 10
we get all the performance of RAID 0 so that includes both reading and writing so performance
both ways there and the redundancy of having a full mirror just like we get with RAID 1 so
how in earth is this actually invoked well one of the disadvantages of having to use RAID 10
is that you need a minimum of four different disks here so we'd have one two and then three and four
now the way this actually operates is that we can have straight data that is mirrored now that
sounds confusing but let me show you what I mean here so let's say we're writing our first piece
of data let's say data piece number one but we're only writing the first half of that data and we
mirror that onto our second disk so the first half of data so that data is now mirrored now we want
to write the other half of that data over here so 1b but we want to mirror that information so we
have 1b here then we can do 2a here and 2a here mirroring and like I say the data within here
is going to be striped with the data over here so we would do 2b here and mirror it to be here
so on so forth the point being is that if we happen to want to read let's say data number two
here we could read the first part from either of these disks and get the second part from either of
these disks so we can read concurrently and build the data now what would happen if one of these
devices got destroyed well now 2b is away and 1b is away but it isn't actually because we still have
a full copy of that data on an entire disk right here 1b and 2b and we can still use that to construct
the information we have striped across these two disks here so like I say a lot of advantages with
respect to raid 10 the problem is is that well you have to have a lot of disks to invoke this type
of raid setup now one distinction I just want to make here is that whilst I have been describing
this as using different disks you can absolutely use different partitions if you so choose now
remember when we were using fdisk to create a linux partition we could create a linux partition or
we could create something called a swap partition if we so choose we can also create a partition
with a very particular label known as 0x fd now what happens is that when we mark a partition
with this particular label what we are ultimately telling the system is hey I'm going to be
a raid partition so you can imagine if you happen to have let's say disk number one sda
partition one and you maybe have a second disk so sdb partition one you could mark both of these
partitions as 0x fd 0x fd so that we can signal to a linux system that we are indeed a raid
partition now here is the very cool thing here let's say we happen to have a particular server
and maybe we had three different disks in here or three different partitions whatever it may be
if they have that marking denoting them as a raid partition i.e. with the fd marking even if this
actual server here itself let's say some internal component blows and the server is not operational
what you could do is you could just open up this server grab these three devices which have been
marked as a raid arrays and you could just slip them in to another server that's running linux
and what that server will do it will automatically assemble these drives exactly as they were before
so this is super super handy because if you think about it if you happen to have three different
disks like i say and this was a debian server and for whatever reason this breaks you could pull
these three out no problem at all and even if you go over to some type of red hat distribution and
dump in those three disks automatically the system is going to detect they are raid arrays and
assemble them no problem at all even though they came from a completely different operating system
one being debian based one being red hat it does not matter so software raid really is a very very
useful and important solution with respect to improving performance and primarily improving
your resiliency to potential failures of your disk via redundancy so what we want to do now is to
look at some of the basic configurations of how we can set up software raids on our linux machines
that's what we'll be talking about in the very next nuggets i hope this has been informative for you
and i'd like to thank you for viewing