Managing RAID on Linux - Derek Vadala [72]
Linear mode uses a rounding factor instead of a chunk-size. This command creates a linear mode array with two disks and a rounding factor of 128 KB:
# mdadm -C /dev/md0 -llinear -n2 --rounding=128 /dev/hd{a,b}1
RAID-1 does not require a chunk-size:
# mdadm -C /dev/md0 -l1 -n2 /dev/sd{a,b}1
RAID-5 can take both both a chunk-size and a parity algorithm. The following example creates a five-disk RAID-5 at /dev/md0, using a chunk-size of 128 KB and the left-symmetric algorithm:
# mdadm -C /dev/md0 -l5 -c128 -pls -n5 /dev/sd[a-e]1
By default, RAID-5 will automatically choose the left-symmetric parity algorithm, and all levels that use striping default to a 64 KB chunk-size. So you don't need to specify either option on the command line if the defaults meet your needs.
Use the -x option to specify spare disks for arrays that support redundancy. In this example, a RAID-1 is created at /dev/md0 with /dev/sda1 and /dev/sdb1 as its member disks. /dev/sde1 is a spare disk. The last disk listed on the command line becomes the spare disk.
# mdadm -C /dev/md0 -l1 -n2 -x1 /dev/sd{a,b,e}1
RAID-5 can also use spare disks. Normally, the last disk listed on the command line becomes a spare disk (or the last two disks, if you specified -x2, and so on). However, because of the way that mdadm creates a RAID-5, this isn't always the case. I mentioned in earlier chapters that resynchronization occurs when an array is initialized and that recovery occurs when an array rebuilds after being in degraded mode. Under RAID-5, recovery is faster than resynchronization, so mdadm attempts to force recovery mode to synchronize disks, rather than using the slower resynchronization process.
To facilitate this, mdadm creates an array with N-1 member disks and X+1 spare disks, as specified by the --raid-disks (-n) and --spare-disks (-x) options. The kernel then initiates recovery when it notices the array is degraded and inserts one of the spare disks into the array. In the following example, a five-disk RAID-5 with one spare disk is created at /dev/md0. /dev/sdf1 becomes the spare disk because mdadm assembles the array using the first four disks and then inserts the last (/dev/sdf1) of the two spare disks. This induces recovery, and /dev/sde1 becomes the only remaining spare disk.
# mdadm -C /dev/md0 -l5 -n5 -x1 /dev/sd{a,b,c,d,e,f}1
To force mdadm to initialize a RAID-5 using resynchronization instead of recovery, while honoring the device order at it appears on the command line, use the --force or -f option:
# mdadm -C /dev/md0 -f -l5 -n5 -x1 /dev/sd{a,b,c,d,e,f}1
mdadm can also create hybrid arrays:
# mdadm -C /dev/md0 -l1 -n2 -x1 /dev/sd{a,b,c}1
# mdadm -C /dev/md1 -l1 -n2 -x1 /dev/sd{d,e,f}1
# mdadm -C /dev/md2 -l0 -c64 -n2 /dev/md{0,1}
This example creates two mirroring arrays, each with a spare disk (/dev/md0 and /dev/md1). The third command combines both of these arrays into a RAID-0 with a chunk-size of 64 KB.
Name
Assemble mode
Synopsis
mdadm --assemble mddevice [options] memberdevices
Assemble mode activates an array that has already been created using --create or --build. It might be helpful to think of Assemble mode as being similar to the raidstart command.
Options
-A, --assemble
Assembles (starts) an existing array.
-u, --uuid=
Specifies the UUID of an array to assemble. Disks are scanned for a RAID superblock containing the UUID and combined into an array.
-m, --super-minor=
Uses the minor number to identify which member disks belong to an array. All software arrays have a major number of 9. By default, each array has a minor number that corresponds to the number of its device special name. Thus, /dev/md1 has a minor number of 1, and /dev/md22 has a minor number of 22.
-s, --scan
Scans the configuration file /etc/mdadm.conf for information that could be used to assemble the array listed on the command line. This is useful for assembling arrays without having to remember their UUIDs, minor numbers, or component devices. See the /etc/mdadm.conf section, later in this chapter, for more information.