User Tools

Site Tools


nas:build_a_linux_nas:create_a_software_raid_array

NAS - Build a Linux NAS - Create a Software RAID Array

Check the disk partitions to be used in the RAID

mdadm --examine /dev/sd[b-d]1
 
or
 
mdadm --examine /dev/sdb1 /dev/sdc1 /dev/sdd1

returns:

mdadm: No md superblock detected on /dev/sdb1
mdadm: No md superblock detected on /dev/sdc1
mdadm: No md superblock detected on /dev/sdd1

NOTE: There is no any defined RAID on the sdb1, sdc1 and sdd1 drives so far, which is why no superblocks are detected.


Create a Software RAID Array

sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1
 
or 
 
sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 --spare-devices=1 /dev/sd{b,c,d,e}1

NOTE: This created a new block device /dev/md0.

  • This device represents the RAID 5 of /dev/sdb1, /dev/sdc1 and /dev/sdd1.
  • Obviously other RAID types could be used instead.

If the following message is seen: Device or resource busy, then reboot the OS.


Ensure the RAID Array is reassembled automatically each time the system boots

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
 
or
 
sudo mdadm --detail --scan --verbose | sudo tee -a /etc/mdadm/mdadm.conf

returns:

ARRAY /dev/md/0 level=raid5 num-devices=3 metadata=1.2 spares=1 name=xenial:0 UUID=c7a2743d:f1e0d872:b2ad29cd:e2bee48c
      devices=/dev/sdb1,/dev/sdc1,/dev/sdd1

NOTE: This saves the RAID configuration in the /etc/mdadm/mdadm.conf file.

  • In the background, mdadm will sync the data of these disks.
  • This can take a very long time as it requires reading and writing a lot of data depending on the size of the disks.

Check the RAID Details

sudo mdadm --detail /dev/md0

returns:

 

NOTE: This also displays not only the health, but also the sync status.


Check Raid Status

cat /proc/mdstat 

returns:

Personalities : [raid6] [raid5] [raid4] 
md0 : active raid5 sdc1[4] sdd1[3](S) sdb1[1] sda1[0]
      1953520640 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [UU_]
      [>....................]  recovery =  4.3% (42161792/976760320) finish=215.1min speed=72409K/sec
nas/build_a_linux_nas/create_a_software_raid_array.txt · Last modified: 2021/09/26 13:00 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki