Skip to content

mdadm

Note

Don't forget to keep your mdadm.conf uptodate when creating, modifiying, deleting mdadm arrays.

Generate mdadm.conf

1
mdadm --detail --scan >> /etc/mdadm.conf

Grow RAID 5 to RAID 6

Danger

DON'T FORGET TO SPECIFY THE --backup-file=FILE for mdadm --grow operations!
Otherwise if the host is (forced) shutdowned (e.g., power failure), data can / will be lost.

(This "backup file" should be on different disk / storage, not on the mdadm array you are growing!)

Speed-up RAID rebuild

Note

This may or may not improve your mdadm RAID rebuild performance, as it the speed depends on many factors such as disk speeds, etc.

This assumes your disks are sda, sdb and sdc, and the RAID array is md0 (/dev/md0).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
for disk in sd{a..c}; do
    blockdev --setra 16384 "/dev/${disk}"
    echo 1024 > "/sys/block/${disk}/queue/read_ahead_kb"
    echo 256 > "/sys/block/${disk}/queue/nr_requests"
    # Disable NCQ on all disks.
    echo 1 > "/sys/block/${disk}/device/queue_depth"
done

# Set read-ahead to 64 MiB for /dev/md0
blockdev --setra 65536 /dev/md0

# Set stripe_cache_size to 16 MiB for /dev/md0
echo 16384 > /sys/block/md0/md/stripe_cache_size

References