mdadm

From RaySoft

mdadm is a Linux utility by Neil Brown that is used to manage software RAID devices, previously known as mdctl. Besides managing, it can create, delete, or monitor Linux software RAID. Available under version 2 or later of the GNU General Public License, mdadm is free software.[1]

Documentation

Subcommands & Parameters

For create, build, or grow

-B, --build
Build a legacy array without superblocks.
-C, --create
Create a new array.
-G, --grow
Change the size or shape of an active array.
-c SIZE, --chunk=SIZE
Specify chunk size of kibobytes. The default when creating an array is 512KB.
-l LEVEL, --level=LEVEL
Set raid LEVEL. When used with --create, options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid4, 4, raid5, 5, raid6, 6, raid10, 10, multipath, mp, faulty. Obviously some of these are synonymous.
-n NUMBER, --raid-devices=NUMBER
Specify the NUMBER of active devices in the array. This, plus the number of spare devices must equal the number of component-devices (including "missing" devices) that are listed on the command line for --create. Setting a value of 1 is probably a mistake and so requires that --force be specified first. A value of 1 will then be allowed for linear, multipath, raid0 and raid1. It is never allowed for raid4 or raid5.
-x NUMBER, --spare-devices=NUMBER
Specify the NUMBER of spare devices in the initial array. Spares can also be added and removed later. The number of component devices listed on the command line must equal the number of raid devices plus the number of spare devices.
-z AMOUNT, --size=AMOUNT
AMOUNT (in Kibobytes) of space to use from each drive in RAID levels 1/4/5/6. This must be a multiple of the chunk size, and must leave about 128Kb of space at the end of the drive for the RAID superblock.

For assemble

-A, --assemble
Assemble a pre-existing array.

For manage

-a, --add
Hot-add listed devices.
-f, --fail, --set-faulty
Mark listed devices as faulty.
-r, --remove
Remove listed devices. They must not be active. i.e. they should be failed or spare devices.

Misc

-D, --detail
Print detail of one or more devices.
-R, --run
Start a partially built array.
-S, --stop
Deactivate array, releasing all resources.

Examples

Create a new software RAID 5
mdadm --create '/dev/md0' --level=5 --raid-devices=4 \
   '/dev/hda1' '/dev/hdb1' '/dev/hdc1' '/dev/hdd1'
Print detail of one device
mdadm --detail '/dev/md0'
Remove a defect disk from the array
mdadm --set-faulty '/dev/md0' '/dev/sda1'
mdadm --remove '/dev/md0' '/dev/sda1'
Add a new disk to the array
fdisk '/dev/sda'
mdadm --add '/dev/md0' '/dev/sda1'

References