Hey guys and welcome back. So now what I'm going to do is I'm going to walk you through
a basic setup of using software RAID on our Linux machine. So what I'm first going to
do is I'm going to add two new disks to my machine right now. So what I will do is I'll
click my device, I'll go to settings, I will go to storage and I already have a second
disk but I'll just add another so go down to here and click this little icon and then
choose hard disk. Now I'll create a disk, I'll just say next, next and I'll make the
size pretty small, I'll just maybe make it around half a gig maybe, let's create you
and I'll scroll down, select it and click choose. So now that has been added, what I'll
now do is do the same thing once again, just add another, I'll create again, just make
one of the same size and I'll just choose this. Okay, perfect. So I'll say okay and
now I'll start my machine up with these two new disks added. Okay, so I have logged back
into my machine. If I do an LS on my dev SD drives and I do well card, we can actually
see we've added these two new devices SDC and SDD, neither of which have been partitioned
though. Now one particular file location that we absolutely want to be remembering that
we can use to verify that a RAID device has been created is by looking at the contents
of the proc MD stat file. This file MD stat stands for multiple disks, so MD stat multiple
disk statistics. If I say cat proc MD stat, notice here that right now we have no information
here, meaning that we do not have any RAID devices. What I'm now going to do is I'm going
to use F disk to partition those new drives I just added. So what I'll do is I'll say
pseudo F disk and the first device is going to be SDC. So I'll hit enter, I will say N
to create a new partition, I will say P for the primary partition, partition number will
be one and I'll just hit enter, enter for my default sectors. Now one thing to note here
is that it says here it's created one partition of type Linux. Now remember what we talked
about in the previous nugget, there is actually a particular label we want to give this partition
to denote it that it is a RAID partition. So if we want to change the type, what I can
do is say T to change the type and I want to list the actual hex codes, so I'll do capital
L and this will show me all my different codes. Now the one I want to do is this one right
here FD which is a Linux RAID auto partition. This will give it that FD marking we were
talking about. So now I will say FD and it's now changing the partition type from a regular
Linux that we would use for a regular partition to a Linux RAID auto detect partition. Now
that I've done this, I will say W to write that information and now that has been written
to and saved. So we want to do the same thing but we want to do it for SDD this time. So
we'll do the same, we'll create a new partition, make it a primary partition, number one default
sectors. The type is going to be as we can see here Linux, we have to change that so
we'll say T again, check the code, it's going to be FD. That is now being changed, we'll
say W to write and that has also been written to. Now if we happen to cat our proc MD stat
file, notice that nothing has actually changed quite just yet. We still have to use some
particular commands to create these RAID partitions. Now the command that we want to be using is
one called MDADM. This is the multiple disks admin tool. So like I say right now, if I
go into my dev directory and just list everything, we can see these new devices with new partition
SDD1, SDC1 but notice there is not one called MD0 quite just yet. This is one we're actually
going to create and we'll do so using the MDADM command. So if I clear the screen and I say
man MDADM. Oh, we do not have this. This is because I have forgotten to install it. So
I'll have to install MDADM. There we go. And I'll say yes. That will go through the installation.
Okay, so let's try that man page one more time. Now it does appear. So we can see this tool
here, this utility is to manage Linux software RAID and we can get our big description about
all this information. But if we scroll on down, we can see the different options we have available
to us. We can do the dash capital C or dash dash create to create a new array. This is
something we definitely want to be doing. Now another important thing we want to specify
here, we can also do dash V or dash dash verbose so that we can actually print out what is
happening as the array is being created. A very, very important one is this one here dash L or
dash dash level. This is the option that we can use to specify the RAID level we want to invoke.
So remember in the previous nugget, we said we could have things like RAID 0 or RAID 1 or RAID 10,
RAID 5. There actually are even more RAID levels which we can see here RAID 4, for example. But
for the purposes of the examination, 0, 1, 5 and 10 are the main ones that we want to focus on.
So with this option, we can specify a particular array that we want to invoke. Let's say I want
to invoke a mirrored array. So we have perfect redundancy, i.e. each disk has a carbon copy
of the data. We can use RAID level 1. So that is what we will do right now if I press Q here
and I clear my screen. What I'll do is I'll say MDADM. In fact, I will use my SuperUser privileges.
I'll say MDADM and I will say dash dash create or I could do dash C as we saw and I'll say
dash dash verbose so we can see the outputs. And now what I want to do is I want to specify
the name of the array, the partition that we want to create. So I'll say in dev, we'll have one called
MD0. So multiple disk 0. 0 being the very first one we create. If we create another one, we could
call it MD1 and then another one MD2 so on and so forth. So we will say MD0 and now I want to specify
the level that we want to create. We want RAID 1 and now what I have to specify are what devices
am I going to use within this RAID array? So I will say RAID devices equals 2 because we have
two disks that we want to use. And now I'm going to supply as an argument these different disks. So
we had SDC1 which was the partition we just created for the new disk as well as the other disk which
was SDD1. Both of these partitions remember have been marked with that FD label. So I will hit
ENTER. I will say yes, hit ENTER again and now the array has been created. So what I can do now is I
can do LS and my dev directory. Notice now we have MD0 right here. Now what we can do here is treat
this like a regular partition. So what we'll do is we'll use FDIS on dev MD0. I'll create a new
partition. I'll make a primary partition. I'll hit ENTER and ENTER and ENTER. The partition type,
this one is interesting. This time we're just going to leave it as the regular Linux because
ultimately it's just going to store regular Linux information. So that is why we're just going to
leave that. If I hit W, this is now going to be written to, if I want to add a file system,
we can do that with the commands we have saw before, MKFS. So I will say sudo MKFS. So I'll
clear the screen. I'll say sudo MKFS EXT4 and we'll do it on dev MD0. I'll say yes. And now if I
cat proc MDSTAT, we can see here we now actually have a RAID1 array and we can see what is actually
active within this array. We have SDD1 and SDC1, the two partitions of the two different disks
that we just added. Notice here we have this value uu. This denotes those physical disks,
both of which are in the upstate. If one of those were broken, we would actually see a
dot here instead of the actual u. So right now we have an active RAID array. This is very, very good.
Now, here as a deal, if we happen to reboot our system, this RAID device is going to exist, but it
will not be active any longer. The reboot will effectively deactivate it. Now you can just use
the MDADM command to manually activate the RAID device every time you have a new boot, because
like I say, it will boot up in an active state. But what you can do is you can create a configuration
file for MDADM. So what I'll do here is I'll say MDADM-DETAIL-SCAN. Oh, and of course I need my
super user privileges, so MDADM-DETAIL-SCAN. And this information here, we want to populate this
information into the MDADM configuration file. So what I will do here is I'll actually just take
this output and I'll redirect it into Etsy, mdadm.conf. Now try to remember that particular location.
This is where we can store our configurations for MDADM-related configs, because ultimately,
once we pipe in this information here that we're seeing into this configuration file,
this is going to allow us to automatically enable the RAID device and activate it when it has been
rebooted. So if I hit Enter now, oh, and in fact, you know what, I should actually just change to my
root because I have to write into my Etsy directory. So I'll just change to the root user and I'll just
do that instead. So MDADM, that's a good little point to make aware of and pipe it into Etsy,
mdadm.conf. If I hit Enter now and I go into this particular file, let me just use nano instead,
this file is now populated with this information. And like I say, that will automatically activate
and enable the RAID device even when you reboot it as opposed to having to manually issue the command
every time the system has a new reboot. So we can now survive reboots. What we now want to be able
to do is we would want to be able to mount this particular drive. So if we want to be able to
create a mount point, what we will do is we will make a directory, let's just call it, I don't know,
forward slash RAID perhaps. If I go to the root directory, do an LS, we now have this RAID directory.
Now, can you remember the location of the file that we use in order to have persistent mounting
of our file systems? If you said the Etsy FS tab file, that is absolutely correct. So that's the
one we're going to modify. We're going to Etsy FS tab. And I'm just going to add this information
right here. So what is the device I want to add? I want to add MD0. What is the location of the
mount point? I will just say forward slash RAID. What is the file system type? It'll be EXT4.
The options, I'll just give it the defaults. I'll have the dump value at zero and I'll make the
past value priority three. So if I save this and exit out, I can now get this. This is now being
updated. I can use my mount dash a command, which will mount everything that I have specified within
the FS tab file. So now if I happen to say mounts and I grep for RAIDs, we can actually now see
that this file system has been mounted and it is indeed a RAID array. If I do an LSBLK-F,
we can also see this here. SDD, this is a Linux RAID member, as is SDC also a Linux RAID member.
We can see the label, the label, notice the UUID here is absolutely identical here and absolutely
identical down here. And we can see the mount point is at forward slash RAID and forward slash RAID.
So really we saw here with the MDADM command, we can easily create a RAID array. We also understand
we can find information relating to our multiple disk statistics with respect to a RAID array in
the PROC directory with the MDSTAT command. This will show that we have an active RAID array.
If we want our RAID array to be active after each reboot, we want to create a configuration file which
can automate that process. And if we want our devices or our drives to be automatically mounted,
we want to make an addition or an amendment to our SAFS tab file. Okay, so that is us for our
introduction into our basic RAID configuration tools. I hope this has been informative for you
and I'd like to thank you for viewing.