Now we're going to move straight out to our command line on AlmaLinux.
We're going to take a look at creating RAID partition,
installing Software RAID, and creating a mirrored volume.
And here we are back on AlmaLinux 8,
and we're going to go through and make sure that
everything is set up the way that we need it.
We're going to go through the fallocate routine again,
creating ourselves a new disk file.
We're going to be creating one disk file just for speed and ease,
but the reality is, of course, if we're looking at fault tolerance,
we will want multiple disk files, and ideally,
they will be stored on different disks.
So this is just for demonstration purposes only.
We can go through and create then our length to be 1 GB,
so the same size that we've been using so far.
And we're going to go through then and create the new file, disk1.
Now with that done, we can go through and use losetup to use the next available,
and show me what it is, but it's going to be loop1,
and link it through to my disk, disk1.
So we're going to have now our new device that we can use.
And we're going to look at partitioning with parted again.
We'll take it a little bit slowly running through.
So we're going to go through and create our new label.
So making sure we've got the correct device,
we go ahead with our mklabel and msdos.
Now, having done that, we can then go back,
take out our mklabel, and run our mkpart to create a partition.
So we're going to go through and create our partition with mkpart.
And, of course, we're using primary partitions.
We can start at the beginning of the disk,
but we know that's going to be offset,
so it's not actually going to be the beginning of the disk.
So we can put 0%, and going through to 50% of the disk,
so we're creating it in the same way as we've done our other partitions.
We'll go through now and print this, and we can see it's 536 MB.
It's ending on 537 MB.
Now this time when we go and create our next partition,
we're going to do it slightly different.
We're going to start on 537 MB.
We want our partitions to be exactly the same size,
so we're going to go through and set 537 MB,
and our ending, we're just going to add then 536 MB to 537 MB.
Now in simple math, that's going to work out to be 1073 MB.
And if we go now and print, we can see they're exactly the same size.
So when we're using RAID and mirroring or anything other than linear partitions,
we need to make sure that our partitions or disks are the same size.
We can then go through and set partition 1 to be
RAID and partition 2 to be RAID.
So, setting the correct flags.
Again, when I go through and print, we can see now we've got the flags set.
Now, I don't particularly need to do that,
but again,
it hints to the operating system to give an idea of what
the partitions are being used for.
But the importance there,
we're making sure that we've got the same partition sizes.
Now,
our next step is to go through and install our MDM package if we don't have it,
so yum install ‑y mdadm.
We can allow that to run through.
It happens quite quickly.
I can go through and double‑check that we don't have any devices.
We know we won't, we've just installed it,
but take a look at the proc/mdstat file.
We're going to come back to this in any case,
but look, we've got nothing being used at the moment.
So now we know we've got a clean system,
we can go through and use our mdadm command to
create ourselves our RAID devices.
We do this manually to begin with, but then we can save it in a configuration.
So ‑‑create ‑‑verbose so we can see what's going on.
We don't have any devices, so I can create dev/md0.
Our level, we want this to be mirroring.
So whatever we write to one partition, we're writing to the other partition.
So this gives me great fault tolerance.
Again, assuming they were actually separate physical disks.
And we can then specify the devices that we're going to
incorporate into this as being then our two partitions.
And we can specify /dev/loop1p1 and loop1p2.
So the two partitions that we've just created.
Again, double‑check your systems if they differ from mine.
Hitting the Enter key,
we get a little bit of feedback coming back saying that
it's not suitable for a boot device, but that's fine.
We don't need to use it as a boot device,
but obviously, pay attention if we need to mount this to the /boot directory.
We can say yes, we want to go ahead, and now we've started our md0.
If we go back and look at the mdstat file inside of proc,
we can see now that we have got our RAID device up and running.
So this is a good sign.
We can go through and format it.
Don't forget, this is now just a block device file,
really, that we're looking at.
So, of course, we've got to add our file system to it.
I'm adding ext4.
Now, irrelevant of the file system,
just in the fact that we've got our RAID device,
we will have then the correct RAID device driver loaded in‑memory.
Lsmod will show me all of the kernel drivers I've got,
but if I go through and search for RAID,
we can see then that we've got the RAID1 kernel module loaded.
So all of this is handled by the kernel itself.
Now if I try and take a look inside of the /etc directory and the mdadm.conf,
using tab completion there, well, I don't have the file.
We haven't created the configuration.
Now, the reality is,
we want to create that configuration so that we can
create our RAID devices on boot.
So we use mdadm ‑‑detail ‑‑scan to create it.
Now here we're printing to the screen,
but if I redirect this through to the file,
I'm appending out of good habit, we know the file isn't there,
but it's always good habit to append to your file.
So /etc/mdadm.conf.
Remember, on Ubuntu systems, it has its own separate subdirectory,
mdadm in the /etc directory.
We can now show that we can auto‑build it by stopping our RAID device,
so /dev/md0.
And now with it stopped, to restart the device,
we use our mdadm command and ‑‑assemble ‑‑scan.
It reads in from our configuration file,
and we can see there that it's created our device.
So we've seen how we can create our own Software RAID devices,
and how we can format that device.
We're going to now move back to our slides, so we might take a little bit of a look at our btr