Create a RAID5 Array with mdadm on Linux
In this tutorial we will setup a RAID5 array, which is striping across multiple drives with distributed paritiy, which is good for redundancy. We will be using Ubuntu for our Linux Distribution, but the technique applies to other Linux Distributions as well.
What are we trying to achieve
We will run a server with one root disk and 6 extra disks, where we will first create our raid5 array with three disks, then I will show you how to expand your raid5 array by adding three other disks.
Things fail all the time, and it’s not fun when hard drives breaks, therefore we want to do our best to prevent our applications from going down due to hardware failures. To achieve data redundancy, we want to use three hard drives, which we want to add into a raid configuration that will proviide us:
striping, which is the technique of segmenting logically sequential data, so that consecutive segments are stored on different physical storage devices.
distributed parity, where parity data are distributed between the physical disks, where there is only one parity block per disk, this provide protection against one physical disk failure, where the minimum number of disks are three.
This is how a RAID5 array looks like

Hardware Overview
We will have a Linux server with one root disk and six extra disks:

Dependencies
We require mdadm to create our raid configuration:
sudo apt update sudo apt install mdadm -y
Format Disks
First we will format and partition the following disks: /dev/xvdb, /dev/xvdc, /dev/xvdd, I will demonstrate the process for one disk, but repeat them for the other as well:

Create RAID5 Array
Using mdadm, create the /dev/md0 device, by specifying the raid level and the disks that we want to add to the array:
mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/xvdb1 /dev/xvdc1 /dev/xvdd1

Now that our device has been added, we can monitor the process:
cat /proc/mdstat

As you can see, currently its at 11.5%, give it some time to let it complete, you should treat the following as a completed state:

We can also inspect devices with mdadm:

To get information about your raid5 device:

Create Filesystems
We will use our /dev/md0 device and create a ext4 filesystem:
We can then verify that by looking at our block devices using lsblk: