As there are multiple RAID technologies each best for a specific kind of application, it is very crucial in selecting the proper kind of RAID technology as that can seriously effect the performance of the whole application. In the proposed idea, RAID is used to retain the data even in the events of disk failure and to also give decent performance boost. The selected RAID Array should provide the following:
-
Storage efficiency should be high and Cost of implementation should be low to moderate
-
Recovery time in case of disk failure should be low
-
Both Redundancy and Disk Performance should be in good balance
As we need data redundancy for sure, RAID 0 can be ruled out of as it doesn’t offer any redundancy and is only intended for performance boost in the disks. The solution needs to be efficient in terms of storage and cost. RAID 50 and RAID 60 are ruled out as they require a minimum of 6 and 8 disks to be implemented which is not storage optimized. Also, these are not cost effective as the cost of implementing RAID 50 and RAID 60 is too high. RAID 5 and RAID 6 are rules out as they doesn’t offer significant performance boost for the drives (write speeds are low as they need to write the parity blocks along with the data). RAID 01 is not efficient in terms of recovery in case of disk failure as one disk failure will in turn disturb the whole stripped array.
The remaining options for selection are RAID 1 and RAID 10. Compared to RAID 1, RAID 10 offers better performance and good fault tolerance as we have the disadvantages of RAID 1 covered up by implementing it with RAID 0 in RAID 10.. Finally, RAID 10 is been selected as the main RAID technology which will be used in this solution.
Tools to implement RAID on Raspberry Pi 4:
Implementation of RAID on Raspberry Pi is not a simple task either. There are many tools which allow us to implement RAID on Raspberry Pi. Some of them are MDADM (Multiple Disk and Device Management), LVM (Logical Volume Management), ZFS (Zettabyte File System), etc. Out of all the available options, mostly used solutions are either MDADM or LVM. Both MDADM and LVM have a different kind of usage and architecture to them.
Very flexible disk space management is possible with LVM. In addition to allowing for the gathering of several physical hard disks and partitions into a single volume group that can then be further subdivided into logical volumes, it offers capabilities such as the ability to add disk space to a logical volume and its filesystem while that filesystem is mounted and operational. Reducing the disk space allotted to a logical volume is also possible with the volume manager, but there are a few restrictions. The volume needs to be unmounted first. Secondly, before the volume it lives on can be shrunk, the file-system itself needs to be shrunk in size.

Compared to LVM, MDADM mainly fits the application as it is lighter on the RAID and has a simpler architecture. MDADM is a Linux native tool used to manage multiple disks and devices and it enables users to deploy raid arrays in Linux [8-10]. Also, MDADM allows for nested RAID arrays as we have to apply RAID 10 in the Linux system (Raspberry Pi 4).
Implementation of RAID on Raspberry Pi:
Raspberry Pi 4 is first setup with Ubuntu 22 OS. Basic updates and upgrades are installed on Ubuntu. Then, MDADM is installed in Raspberry Pi 4 as it is used to create manage and maintain the RAID arrays. Before implementing RAID on Raspberry Pi, the drives have to be formatted and a new filesystem must be created on the drives. To make that possible, a script has been been made.

Here the disk is unmounted form their mounted path (if it is mounted) and then the file system in the disk is erased to create a new one. After the disk is clean without any file system in it, a new primary volume with 100% capacity are created in the disk, with the help of a Linux tool called “gdisk”. Same process is replicated for every drive till all the disks are ready to be included into a RAID array.
Now the disks are ready to be included in a RAID Array. A RAID 10 array cannot be created directly. First, two RAID 1 arrays has to be created and using those two RAID 1 arrays, a RAID 0 array is created which makes it a RAID 10 array. The newly created array is like a new drive without any filesystem. The next step would be to create a filesystem over the newly created RAID 10 array. All of this will be done using the below bash script:

Here, the packages in Ubuntu are updated and then upgraded to make sure all the packages are up to date. Then the tool used for RAID arrays deployment (MDADM = Multiple Disk and Device Management) is installed using the “apt install” command. Then the mdadm command is used to create three arrays. The attributes in the mdadm command which is used to create the array are as follows:
Attribute/Flags | Explanation |
|---|---|
--create | This option is used to initiate the creation of RAID array |
--verbose | This gives detailed output while creating the array |
--level | The RAID technology to be used |
--raid-devices | Number of RAID devices to be in the array |
Other attributes/flags that can be included in the mdadm create command are as follows:
Attribute/Flags | Explanation |
|---|---|
--name | Used to give the name to array so that it will be easy to identify the array in system configurations are other places |
--spare-devices | Some space devices can be added using this option so that they can replace the failed or corrupted disks in the main array |
--chunk | Defines the chunk size for the RAID Array (for RAID technologies included with striping) |
--layout | For RAID 10 arrays, you can specify the layout, which controls how data and mirror pairs are organized on the devices. Common layout options include 'near' and 'far' |
--size | Only used for RAID 0 array, defines the size of the array |