1
00:00:00,000 --> 00:00:16,920
Hey guys and welcome back. So now what I'm going to do is I'm going to walk you through

2
00:00:16,920 --> 00:00:21,960
a basic setup of using software RAID on our Linux machine. So what I'm first going to

3
00:00:21,960 --> 00:00:26,640
do is I'm going to add two new disks to my machine right now. So what I will do is I'll

4
00:00:26,640 --> 00:00:32,719
click my device, I'll go to settings, I will go to storage and I already have a second

5
00:00:32,719 --> 00:00:38,159
disk but I'll just add another so go down to here and click this little icon and then

6
00:00:38,159 --> 00:00:43,200
choose hard disk. Now I'll create a disk, I'll just say next, next and I'll make the

7
00:00:43,200 --> 00:00:48,040
size pretty small, I'll just maybe make it around half a gig maybe, let's create you

8
00:00:48,040 --> 00:00:53,719
and I'll scroll down, select it and click choose. So now that has been added, what I'll

9
00:00:53,719 --> 00:00:59,039
now do is do the same thing once again, just add another, I'll create again, just make

10
00:00:59,039 --> 00:01:04,400
one of the same size and I'll just choose this. Okay, perfect. So I'll say okay and

11
00:01:04,400 --> 00:01:09,359
now I'll start my machine up with these two new disks added. Okay, so I have logged back

12
00:01:09,359 --> 00:01:16,799
into my machine. If I do an LS on my dev SD drives and I do well card, we can actually

13
00:01:16,799 --> 00:01:23,560
see we've added these two new devices SDC and SDD, neither of which have been partitioned

14
00:01:23,560 --> 00:01:28,280
though. Now one particular file location that we absolutely want to be remembering that

15
00:01:28,280 --> 00:01:34,400
we can use to verify that a RAID device has been created is by looking at the contents

16
00:01:34,400 --> 00:01:42,280
of the proc MD stat file. This file MD stat stands for multiple disks, so MD stat multiple

17
00:01:42,280 --> 00:01:49,560
disk statistics. If I say cat proc MD stat, notice here that right now we have no information

18
00:01:49,560 --> 00:01:54,359
here, meaning that we do not have any RAID devices. What I'm now going to do is I'm going

19
00:01:54,359 --> 00:02:00,320
to use F disk to partition those new drives I just added. So what I'll do is I'll say

20
00:02:00,320 --> 00:02:07,159
pseudo F disk and the first device is going to be SDC. So I'll hit enter, I will say N

21
00:02:07,159 --> 00:02:11,920
to create a new partition, I will say P for the primary partition, partition number will

22
00:02:11,920 --> 00:02:18,439
be one and I'll just hit enter, enter for my default sectors. Now one thing to note here

23
00:02:18,439 --> 00:02:24,280
is that it says here it's created one partition of type Linux. Now remember what we talked

24
00:02:24,280 --> 00:02:30,560
about in the previous nugget, there is actually a particular label we want to give this partition

25
00:02:30,560 --> 00:02:35,280
to denote it that it is a RAID partition. So if we want to change the type, what I can

26
00:02:35,280 --> 00:02:41,240
do is say T to change the type and I want to list the actual hex codes, so I'll do capital

27
00:02:41,240 --> 00:02:47,079
L and this will show me all my different codes. Now the one I want to do is this one right

28
00:02:47,080 --> 00:02:53,640
here FD which is a Linux RAID auto partition. This will give it that FD marking we were

29
00:02:53,640 --> 00:02:59,320
talking about. So now I will say FD and it's now changing the partition type from a regular

30
00:02:59,320 --> 00:03:05,480
Linux that we would use for a regular partition to a Linux RAID auto detect partition. Now

31
00:03:05,480 --> 00:03:11,520
that I've done this, I will say W to write that information and now that has been written

32
00:03:11,520 --> 00:03:17,640
to and saved. So we want to do the same thing but we want to do it for SDD this time. So

33
00:03:17,640 --> 00:03:23,320
we'll do the same, we'll create a new partition, make it a primary partition, number one default

34
00:03:23,320 --> 00:03:28,520
sectors. The type is going to be as we can see here Linux, we have to change that so

35
00:03:28,520 --> 00:03:33,920
we'll say T again, check the code, it's going to be FD. That is now being changed, we'll

36
00:03:33,920 --> 00:03:40,760
say W to write and that has also been written to. Now if we happen to cat our proc MD stat

37
00:03:40,759 --> 00:03:46,039
file, notice that nothing has actually changed quite just yet. We still have to use some

38
00:03:46,039 --> 00:03:51,439
particular commands to create these RAID partitions. Now the command that we want to be using is

39
00:03:51,439 --> 00:03:58,439
one called MDADM. This is the multiple disks admin tool. So like I say right now, if I

40
00:03:58,439 --> 00:04:05,519
go into my dev directory and just list everything, we can see these new devices with new partition

41
00:04:05,520 --> 00:04:12,920
SDD1, SDC1 but notice there is not one called MD0 quite just yet. This is one we're actually

42
00:04:12,920 --> 00:04:18,300
going to create and we'll do so using the MDADM command. So if I clear the screen and I say

43
00:04:18,300 --> 00:04:24,639
man MDADM. Oh, we do not have this. This is because I have forgotten to install it. So

44
00:04:24,639 --> 00:04:31,120
I'll have to install MDADM. There we go. And I'll say yes. That will go through the installation.

45
00:04:31,240 --> 00:04:37,319
Okay, so let's try that man page one more time. Now it does appear. So we can see this tool

46
00:04:37,319 --> 00:04:43,639
here, this utility is to manage Linux software RAID and we can get our big description about

47
00:04:43,639 --> 00:04:48,160
all this information. But if we scroll on down, we can see the different options we have available

48
00:04:48,160 --> 00:04:53,519
to us. We can do the dash capital C or dash dash create to create a new array. This is

49
00:04:53,519 --> 00:04:58,079
something we definitely want to be doing. Now another important thing we want to specify

50
00:04:58,159 --> 00:05:04,319
here, we can also do dash V or dash dash verbose so that we can actually print out what is

51
00:05:04,319 --> 00:05:10,039
happening as the array is being created. A very, very important one is this one here dash L or

52
00:05:10,039 --> 00:05:17,279
dash dash level. This is the option that we can use to specify the RAID level we want to invoke.

53
00:05:17,279 --> 00:05:23,000
So remember in the previous nugget, we said we could have things like RAID 0 or RAID 1 or RAID 10,

54
00:05:23,079 --> 00:05:29,079
RAID 5. There actually are even more RAID levels which we can see here RAID 4, for example. But

55
00:05:29,079 --> 00:05:34,680
for the purposes of the examination, 0, 1, 5 and 10 are the main ones that we want to focus on.

56
00:05:34,680 --> 00:05:41,079
So with this option, we can specify a particular array that we want to invoke. Let's say I want

57
00:05:41,079 --> 00:05:47,959
to invoke a mirrored array. So we have perfect redundancy, i.e. each disk has a carbon copy

58
00:05:47,959 --> 00:05:54,439
of the data. We can use RAID level 1. So that is what we will do right now if I press Q here

59
00:05:54,439 --> 00:06:01,079
and I clear my screen. What I'll do is I'll say MDADM. In fact, I will use my SuperUser privileges.

60
00:06:01,079 --> 00:06:06,679
I'll say MDADM and I will say dash dash create or I could do dash C as we saw and I'll say

61
00:06:07,240 --> 00:06:13,240
dash dash verbose so we can see the outputs. And now what I want to do is I want to specify

62
00:06:13,240 --> 00:06:20,199
the name of the array, the partition that we want to create. So I'll say in dev, we'll have one called

63
00:06:20,199 --> 00:06:27,319
MD0. So multiple disk 0. 0 being the very first one we create. If we create another one, we could

64
00:06:27,319 --> 00:06:34,600
call it MD1 and then another one MD2 so on and so forth. So we will say MD0 and now I want to specify

65
00:06:34,600 --> 00:06:41,639
the level that we want to create. We want RAID 1 and now what I have to specify are what devices

66
00:06:41,719 --> 00:06:47,479
am I going to use within this RAID array? So I will say RAID devices equals 2 because we have

67
00:06:47,479 --> 00:06:53,079
two disks that we want to use. And now I'm going to supply as an argument these different disks. So

68
00:06:53,079 --> 00:07:01,000
we had SDC1 which was the partition we just created for the new disk as well as the other disk which

69
00:07:01,000 --> 00:07:08,680
was SDD1. Both of these partitions remember have been marked with that FD label. So I will hit

70
00:07:08,680 --> 00:07:15,400
ENTER. I will say yes, hit ENTER again and now the array has been created. So what I can do now is I

71
00:07:15,400 --> 00:07:23,000
can do LS and my dev directory. Notice now we have MD0 right here. Now what we can do here is treat

72
00:07:23,000 --> 00:07:29,319
this like a regular partition. So what we'll do is we'll use FDIS on dev MD0. I'll create a new

73
00:07:29,319 --> 00:07:35,800
partition. I'll make a primary partition. I'll hit ENTER and ENTER and ENTER. The partition type,

74
00:07:35,879 --> 00:07:42,360
this one is interesting. This time we're just going to leave it as the regular Linux because

75
00:07:42,360 --> 00:07:47,240
ultimately it's just going to store regular Linux information. So that is why we're just going to

76
00:07:47,240 --> 00:07:54,360
leave that. If I hit W, this is now going to be written to, if I want to add a file system,

77
00:07:54,360 --> 00:08:00,280
we can do that with the commands we have saw before, MKFS. So I will say sudo MKFS. So I'll

78
00:08:00,279 --> 00:08:09,399
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

79
00:08:09,399 --> 00:08:17,399
cat proc MDSTAT, we can see here we now actually have a RAID1 array and we can see what is actually

80
00:08:17,399 --> 00:08:25,399
active within this array. We have SDD1 and SDC1, the two partitions of the two different disks

81
00:08:25,399 --> 00:08:31,639
that we just added. Notice here we have this value uu. This denotes those physical disks,

82
00:08:31,639 --> 00:08:36,199
both of which are in the upstate. If one of those were broken, we would actually see a

83
00:08:36,199 --> 00:08:42,600
dot here instead of the actual u. So right now we have an active RAID array. This is very, very good.

84
00:08:42,600 --> 00:08:49,079
Now, here as a deal, if we happen to reboot our system, this RAID device is going to exist, but it

85
00:08:49,160 --> 00:08:55,800
will not be active any longer. The reboot will effectively deactivate it. Now you can just use

86
00:08:55,800 --> 00:09:02,120
the MDADM command to manually activate the RAID device every time you have a new boot, because

87
00:09:02,120 --> 00:09:08,280
like I say, it will boot up in an active state. But what you can do is you can create a configuration

88
00:09:08,280 --> 00:09:17,080
file for MDADM. So what I'll do here is I'll say MDADM-DETAIL-SCAN. Oh, and of course I need my

89
00:09:17,160 --> 00:09:25,240
super user privileges, so MDADM-DETAIL-SCAN. And this information here, we want to populate this

90
00:09:25,240 --> 00:09:31,960
information into the MDADM configuration file. So what I will do here is I'll actually just take

91
00:09:31,960 --> 00:09:41,800
this output and I'll redirect it into Etsy, mdadm.conf. Now try to remember that particular location.

92
00:09:41,879 --> 00:09:48,279
This is where we can store our configurations for MDADM-related configs, because ultimately,

93
00:09:48,279 --> 00:09:53,959
once we pipe in this information here that we're seeing into this configuration file,

94
00:09:53,959 --> 00:10:00,039
this is going to allow us to automatically enable the RAID device and activate it when it has been

95
00:10:00,039 --> 00:10:05,399
rebooted. So if I hit Enter now, oh, and in fact, you know what, I should actually just change to my

96
00:10:05,399 --> 00:10:11,479
root because I have to write into my Etsy directory. So I'll just change to the root user and I'll just

97
00:10:11,480 --> 00:10:17,560
do that instead. So MDADM, that's a good little point to make aware of and pipe it into Etsy,

98
00:10:17,560 --> 00:10:25,320
mdadm.conf. If I hit Enter now and I go into this particular file, let me just use nano instead,

99
00:10:25,320 --> 00:10:31,159
this file is now populated with this information. And like I say, that will automatically activate

100
00:10:31,159 --> 00:10:36,519
and enable the RAID device even when you reboot it as opposed to having to manually issue the command

101
00:10:36,519 --> 00:10:42,679
every time the system has a new reboot. So we can now survive reboots. What we now want to be able

102
00:10:42,679 --> 00:10:48,679
to do is we would want to be able to mount this particular drive. So if we want to be able to

103
00:10:48,679 --> 00:10:53,480
create a mount point, what we will do is we will make a directory, let's just call it, I don't know,

104
00:10:53,480 --> 00:11:01,159
forward slash RAID perhaps. If I go to the root directory, do an LS, we now have this RAID directory.

105
00:11:01,159 --> 00:11:07,399
Now, can you remember the location of the file that we use in order to have persistent mounting

106
00:11:07,399 --> 00:11:12,919
of our file systems? If you said the Etsy FS tab file, that is absolutely correct. So that's the

107
00:11:12,919 --> 00:11:18,360
one we're going to modify. We're going to Etsy FS tab. And I'm just going to add this information

108
00:11:18,360 --> 00:11:25,159
right here. So what is the device I want to add? I want to add MD0. What is the location of the

109
00:11:25,159 --> 00:11:31,879
mount point? I will just say forward slash RAID. What is the file system type? It'll be EXT4.

110
00:11:31,879 --> 00:11:37,240
The options, I'll just give it the defaults. I'll have the dump value at zero and I'll make the

111
00:11:37,240 --> 00:11:43,639
past value priority three. So if I save this and exit out, I can now get this. This is now being

112
00:11:43,639 --> 00:11:50,279
updated. I can use my mount dash a command, which will mount everything that I have specified within

113
00:11:50,279 --> 00:11:57,480
the FS tab file. So now if I happen to say mounts and I grep for RAIDs, we can actually now see

114
00:11:57,480 --> 00:12:03,959
that this file system has been mounted and it is indeed a RAID array. If I do an LSBLK-F,

115
00:12:03,959 --> 00:12:13,399
we can also see this here. SDD, this is a Linux RAID member, as is SDC also a Linux RAID member.

116
00:12:13,399 --> 00:12:21,240
We can see the label, the label, notice the UUID here is absolutely identical here and absolutely

117
00:12:21,240 --> 00:12:28,360
identical down here. And we can see the mount point is at forward slash RAID and forward slash RAID.

118
00:12:28,360 --> 00:12:34,519
So really we saw here with the MDADM command, we can easily create a RAID array. We also understand

119
00:12:34,519 --> 00:12:40,919
we can find information relating to our multiple disk statistics with respect to a RAID array in

120
00:12:40,919 --> 00:12:46,839
the PROC directory with the MDSTAT command. This will show that we have an active RAID array.

121
00:12:46,839 --> 00:12:52,279
If we want our RAID array to be active after each reboot, we want to create a configuration file which

122
00:12:52,279 --> 00:12:58,519
can automate that process. And if we want our devices or our drives to be automatically mounted,

123
00:12:58,519 --> 00:13:05,639
we want to make an addition or an amendment to our SAFS tab file. Okay, so that is us for our

124
00:13:05,639 --> 00:13:10,279
introduction into our basic RAID configuration tools. I hope this has been informative for you

125
00:13:10,279 --> 00:13:14,279
and I'd like to thank you for viewing.

