Linux Software RAID

Create a software raid


Locate your disks:

ls /dev/sd*

Partition the disks:

 fdisk /dev/sdb
 'n' = New partition
 'p' = Primary
 '1'
 accept the defaults
 't' = Change filesystem type
 'fd' = Linux RAID Autodetect
 'w' = write the changes

Once the disk is installed create a partition of type ‘Linux raid autodetect’ (type fd) that is the same size as the remaining drives in the raid.

mdadm --create /dev/md0 --level=6 --raid-devices=14 /dev/sd{b,c,d,e,f,g,h,i,j,k,l,m,n,o}1


Check the status of the RAID build:

watch cat /proc/mdstat


Replacing a failed disk

Start by replacing the bad disk with a replacement. The bad disk can be found by comparing serial numbers.

Once the disk is installed create a partition of type ‘Linux raid autodetect’ (type fd) that is the same size as the remaining drives in the raid.

Then simply add the disk to the raid:

 mdadm /dev/md0 --add /dev/sdb1


Check that the rebuild is underway:

 watch -n 1 cat /proc/mdstat




Recovering a failed software raid from LinuxForums.

[root@ornery ~]# cat /sys/block/md0/md/array_state
inactive
[root@ornery ~]# echo "clean" > /sys/block/md0/md/array_state
[root@ornery ~]# cat /sys/block/md0/md/array_state
clean
[root@ornery ~]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid6 sdc1[1] sdi1[7] sdh1[6] sdg1[5] sdf1[4] sde1[3] sdd1[2]
      2344252416 blocks level 6, 256k chunk, algorithm 2 [8/7] [_UUUUUUU]

unused devices: <none>
[root@ornery ~]# mount -o ro /dev/md0 /data
[root@ornery ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda2             226G   46G  168G  22% /
/dev/hda1             251M   52M  187M  22% /boot
/dev/shm              2.9G     0  2.9G   0% /dev/shm
/dev/sda2              65G   35G   27G  56% /var
/dev/md0              2.2T  307G  1.8T  15% /data
Posted in Knowledge and tagged , , .

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.