How to build a MDRAID on Linux

by

in

What is RAID?

RAID is “redundant array of inexpensive disks“. This is a technology that combines multiple physical disk drive components into one or more logical units. This is used for mainly increase fault tolerancy of the disk drive.

RAID levels

RAID0 (Striping)

RAID0 strips the data to all drives for increasing the performance of the drive. But it means that one drive failure causes all data loss. So this does not help the fault toreloncy at all.

RAID1 (Mirroring)

RAID1 mirrors the data to all drives for redunduncy. This helps the fault torelance a lot. But this uses double disk space of the data size.

RAID5

RAID5 consists of block-level striping with distributed parity.  This is made up with more than 3 drives. RAID5 increases a fault torelancy and save the disk spaces compared with RAID1.

How to configure RAID5 on MDRAID

Here I will show how to configure RAID5 on a linux server using MDRAID.

Partitioning

$ sudo gdisk /dev/sda
$ sudo gdisk /dev/sdb
$ sudo gdisk /dev/sdc

Hexcode of the partitions are fd00.

Notice: Leave 100MiB of unlocated space at the end of the each disk. This will help to absorb little differences of each disk spaces.

Build a RAID array

$ sudo mdadm --create --verbose --level=5 --metadata=1.2 --chunk=256 --raid-devices=3 /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1 --homehost=any

Check the progress

$ sudo cat /proc/mdstat

Notice: This command shows the status of the RAID drive. So you can do the health check by this command.

Partitoning the RAID array

$ sudo gdisk /dev/md0

Format the RAID array

$ sudo mkfs.btrfs -L home /dev/md0p1

Configure mkinitpcio

$ sudo vi /etc/mkinitcpio.conf
HOOKS=(base ... block mdadam_udev filesystem ...)
BINARIES=(mdmon)
$ sudo mkinitcpio -P

Conclusion

Here I show the overview of RAID system and how to build a RAID5 array on a Linux server using MDRAID.

Last Updated on August 27, 2024 by Kenn


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *