Managing RAID on Linux - Derek Vadala [71]
Options
-C, --create
Creates a new array.
-B, --build
Creates an old-style array without a RAID superblock.
-c, --chunk=
Sets the array chunk-size in kilobytes. The chunk-size is a power of two between 4 and 4096. For example, -c128 or --chunk=128 sets a chunk-size of 128 KB. The default is 64 KB.
--rounding=
Sets the rounding factor, which linear mode uses to align I/O operations. The rounding factor is similar to chunk-size, with the exception that it does not distribute operations across multiple disks. The default value of 64 KB should be fine for most users. The same rules that apply to chunk-size apply to rounding (for example, --rounding=8 for 8 KB rounding).
-l, --level=
Specifies the RAID level: linear, RAID-0, RAID-1, RAID-4, or RAID-5. For Build mode, only linear and RAID-0 are supported. For example, type -l5 or --level=5 for RAID-5.
-p, --parity=, --layout=
Sets the parity algorithm for RAID-5. The parity algorithm options are left-asymmetric, right-asymmetric, left-symmetric, or right-symmetric. The best choice is left-symmetric (which is also the default). Choices may also be abbreviated as la, ra, ls, and rs. Examples include -pls, --parity=left-symmetric, or --layout=left-symmetric.
-n, --raid-disks=
Defines the number of member disks in an array. This is equivalent to nr-raid-disks when working with /etc/raidtab and raidtools. Like nr-raid-disks, it does not include spare disks. For example, type -n5 or --raid-disks=5 for five member disks.
-x, --spare-disks=
Defines the number of spare disks in an array (equivalent to nr-spare-disks in /etc/raidtab). For example, enter -x1 or --spare-disks=1 for a single spare disk.
-z, --size=
Manually sets the size in kilobytes of member disks in a RAID-1, RAID-4, or RAID-5. By default, the size is automatically computed by mdadm. The --size must be a multiple of the --chunk-size and must leave at least 128 KB at the end of each device for the RAID superblock. This is useful when working with disks of varying sizes. It's also useful if the sizes of your disks are incorrectly calculated. For example, with a chunk size of 64 KB, -z16000 or --size=16000 sets the size of each component disk to 1 GB (64 KB * 16,000).
-f, --force
Normally when a RAID-5 is created, mdadm builds the array with a missing disk and then inserts the remaining disk into the array. This induces recovery, instead of the slower resynchronization process. The --force option causes mdadm to create an array the traditional way, using resynchronization instead of recovery to initialize the array.
--run
Starts the array even if mdadm detects problems. Using --run will prevent mdadm from requiring confirmation for potentially dangerous operations. For example, if mdadm detects an existing filesystem or RAID superblock on a member disk, --run will nonetheless force the array online, possibly destroying data.
--readonly
Starts the new array as read-only.
Example usage
All --create and --build operations must contain at least --raid-disks and --level options. The following creates a RAID-0 at /dev/md0 with a chunk-size of 128 KB and two member disks.
# mdadm --create /dev/md0 --level=0 --chunk=128 --raid-disks=2 /dev/sda1 /dev/sdb1
The following commands use the short form of mdadm to create a four-disk RAID-0 at /dev/md1. We don't need to specify the chunk-size because the default chunk-size of 64 K is what we want.
# mdadm -C /dev/md1 -l0 -n4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
The list of component disks can be abbreviated using standard shell expansions. Consult the manual pages for the particular shell you use to be sure you are using the proper semantics. I use the Bourne-again shell (bash).
# mdadm -C /dev/md1 -l0 -n4 /dev/sd[a-d]1
# mdadm -C /dev/md1 -l0 -n4 -c64 /dev/sd{a,b,c,d}1
The three previous examples are equivalent. The list of devices is expanded from left to right, so /dev/sda1 becomes the first member disk in the array and /dev/sdd1 becomes the last.