Mdadm

From ISPWiki

Jump to: navigation, search

Contents

Description

It is a Linux utility for the software RAID management. RAID 0/1/4/5/6, LINEAR, MULTIPATH are supported.

For a cluster storage you'd better use:

  1. RAID1 is a mirroring among several devices.
  2. RAID5 is a disk for an unlimited number of devices (3 disks of 10 Gb provide 20 Gb space allowing one disk to fail, 10 disks provide 90 Gb allowing one device to fail)
  3. RAID6 is similar to RAID5, however it allows 2 disks to fail (minimum of 4 devices are required)

Creating RAID5

For example, there are /dev/sdb, /dev/sdc and /dev/sdd devices of the same size. Use them to create an array /dev/md0:

mdadm --create /dev/md0 --auto md --level 5 --raid-devices=3 --spare-devices=0 /dev/sdv /dev/sdc /dev/sdd

Replacing disks

/dev/sdd disk is considered as faulty (RAID specifies it as faulty, or you know this). First, delete the disk from the array:

mdadm --remove /dev/md0 /dev/sdd

From that moment RAID starts operating in the extreme mode. Add a new one:

mdadm --add /dev/md0 /dev/sdd

Enlarging the array

Suppose, you have insufficient disk space and you want to enlarge the array. Add one more disk and then add it to the array:

mdadm --add /dev/md0 /dev/sde

In case of redundancy in the array, the disk will be added in a spare mode ("spare" disk). Use it to enlarge the array:

mdadm --grow /dev/md0 -n4

4 means that four disks should be used for the array.

Viewing array information

You can use the commands below to view the array information :

mdadm -D /dev/md0

The lines that are normally used:

# array size:
    Array Size : 435409536 (415.24 GiB 445.86 GB)
# Used device size:
 Used Dev Size : 217704768 (207.62 GiB 222.93 GB)
...
# used devices
   Number   Major   Minor   RaidDevice State
      0       8       48        0      active sync   /dev/sdd
      1       8       16        1      active sync   /dev/sdb
      2       8       32        2      active sync   /dev/sdc

The device can have one of the following statuses:

active sync - the device is running

faulty - the device is considered faulty and is not used.

spare rebuilding - added disk is used, data synchronization in progress (you cannot take out other devices, as the array is operating in the extreme mode!)

removed - administrator has removed the device from the array.

mdadm -Q /dev/md0

Get the array's summary.

cat /proc/mdstat

Brief information about the system arrays. If the array synchronizing in progress, the process information and expected execution time will be displayed.

Viewing array elements information

mdadm -E /dev/sdb

Information about the array according to the data from this device (you will see something like this "mdadm -D /dev/md0") will be shown.

Was this helpful? Yes | No
Personal tools