The primary tool in Linux for managing and configuring RAID arrays is mdadm (Multiple Device Administration). Specifically, mdadm “is used for building, managing, and monitoring Linux md devices (aka RAID arrays)”

On the other hand, we can use /proc/mdstat to monitor the health of RAID arrays.

mdadm

This is used to assemble arrays, add or remove disks, and check RAID status.

Example

To create a RAID 1 array with two disks, we can use the following command:

sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc

/dev/md0 is the name of the RAID device that will be created.

To ensure that the new device will be recognized accross reboots we have to add the RAID configuration to the mdadm.conf file; with that, we can then update the initramfs filesystem so that the RAID array is assembled during boot. We can accomplish this with the following:

sudo mdadm --detail --scan >> /etc/mdadm/mdadm.conf
sudo update-initramfs -u

Once /dev/md0 is accessible, we then need to use something like mkfs to create a filesystem:

sudo mkfs.ext4 /dev/md0
sudo mkdir /mnt/raid
sudo mount /dev/md0 /mnt/raid

Note

The example above mounts the RAID array by manually passing the commands. To have it mount automatically at boot, we can use fstab:

"/dev/md0 /mnt/raid ext4 defaults 0 0" >> /etc/fstab

mdstat

mdstat has data regarding a RAID array, such as:

  • RAID level
  • Number of devices
  • Sync status
  • Array degradation