]> git.ipfire.org Git - thirdparty/mdadm.git/blame - md.4
mdadm-1.0.0
[thirdparty/mdadm.git] / md.4
CommitLineData
56eb10c0
NB
1.TH MD 4
2.SH NAME
3md \- Multiple Device driver aka Linux Software Raid
4.SH SYNOPSIS
5.BI /dev/md n
6.br
7.BI /dev/md/ n
8.SH DESCRIPTION
9The
10.B md
11driver provides virtual devices that are created from one or more
e0d19036 12independent underlying devices. This array of devices often contains
56eb10c0 13redundancy, and hence the acronym RAID which stands for a Redundant
e0d19036 14Array of Independent Devices.
56eb10c0
NB
15.PP
16.B md
2d465520
NB
17supports RAID levels 1 (mirroring) 4 (striped array with parity
18device) and 5 (striped array with distributed parity information).
19If a single underlying device fails while using one of these levels,
20the array will continue to function.
56eb10c0
NB
21.PP
22.B md
e0d19036 23also supports a number of pseudo RAID (non-redundant) configurations
56eb10c0
NB
24including RAID0 (striped array), LINEAR (catenated array) and
25MULTIPATH (a set of different interfaces to the same device).
26
11a3e71d 27.SS MD SUPER BLOCK
56eb10c0 28With the exception of Legacy Arrays described below, each device that
e0d19036 29is incorporated into an MD array has a
56eb10c0
NB
30.I super block
31written towards the end of the device. This superblock records
32information about the structure and state of the array so that the
11a3e71d 33array can be reliably re-assembled after a shutdown.
56eb10c0
NB
34
35The superblock is 4K long and is written into a 64K aligned block that
11a3e71d 36starts at least 64K and less than 128K from the end of the device
56eb10c0
NB
37(i.e. to get the address of the superblock round the size of the
38device down to a multiple of 64K and then subtract 64K).
11a3e71d 39The available size of each device is the amount of space before the
56eb10c0
NB
40super block, so between 64K and 128K is lost when a device in
41incorporated into an MD array.
42
43The superblock contains, among other things:
44.TP
45LEVEL
11a3e71d
NB
46The manner in which the devices are arranged into the array
47(linear, raid0, raid1, raid4, raid5, multipath).
56eb10c0
NB
48.TP
49UUID
50a 128 bit Universally Unique Identifier that identifies the array that
51this device is part of.
52
11a3e71d
NB
53.SS LEGACY ARRAYS
54Early versions of the
55.B md
56driver only supported Linear and Raid0 configurations and so
2d465520 57did not use an MD superblock (as there is no state that needs to be
11a3e71d
NB
58recorded). While it is strongly recommended that all newly created
59arrays utilise a superblock to help ensure that they are assembled
60properly, the
61.B md
62driver still supports legacy linear and raid0 md arrays that
63do not have a superblock.
64
56eb10c0 65.SS LINEAR
11a3e71d
NB
66
67A linear array simply catenates the available space on each
68drive together to form one large virtual drive.
69
70One advantage of this arrangement over the more common RAID0
71arrangement is that the array may be reconfigured at a later time with
72an extra drive and so the array is made bigger without disturbing the
73data that is on the array. However this cannot be done on a live
74array.
75
76
56eb10c0 77.SS RAID0
11a3e71d
NB
78
79A RAID0 array (which has zero redundancy) is also known as a
80striped array.
e0d19036
NB
81A RAID0 array is configured at creation with a
82.B "Chunk Size"
c913b90e 83which must be a power of two, and at least 4 kibibytes.
e0d19036 84
2d465520 85The RAID0 driver assigns the first chunk of the array to the first
e0d19036 86device, the second chunk to the second device, and so on until all
2d465520 87drives have been assigned one chunk. This collection of chunks forms
e0d19036
NB
88a
89.BR stripe .
90Further chunks are gathered into stripes in the same way which are
91assigned to the remaining space in the drives.
92
2d465520
NB
93If devices in the array are not all the same size, then once the
94smallest device has been exhausted, the RAID0 driver starts
e0d19036
NB
95collecting chunks into smaller stripes that only span the drives which
96still have remaining space.
97
98
56eb10c0 99.SS RAID1
e0d19036
NB
100
101A RAID1 array is also known as a mirrored set (though mirrors tend to
102provide reflect images, which RAID1 does not) or a plex.
103
104Once initialised, each device in a RAID1 array contains exactly the
105same data. Changes are written to all devices in parallel. Data is
106read from any one device. The driver attempts to distribute read
107requests across all devices to maximise performance.
108
109All devices in a RAID1 array should be the same size. If they are
110not, then only the amount of space available on the smallest device is
111used. Any extra space on other devices is wasted.
112
56eb10c0 113.SS RAID4
e0d19036
NB
114
115A RAID4 array is like a RAID0 array with an extra device for storing
116parity. Unlike RAID0, RAID4 also requires that all stripes span all
117drives, so extra space on devices that are larger than the smallest is
118wasted.
119
120When any block in a RAID4 array is modified the parity block for that
121stripe (i.e. the block in the parity device at the same device offset
122as the stripe) is also modified so that the parity block always
123contains the "parity" for the whole stripe. i.e. its contents is
124equivalent to the result of performing an exclusive-or operation
125between all the data blocks in the stripe.
126
127This allows the array to continue to function if one device fails.
128The data that was on that device can be calculated as needed from the
129parity block and the other data blocks.
130
56eb10c0 131.SS RAID5
e0d19036
NB
132
133RAID5 is very similar to RAID4. The difference is that the parity
134blocks for each stripe, instead of being on a single device, are
135distributed across all devices. This allows more parallelism when
136writing as two different block updates will quite possibly affect
137parity blocks on different devices so there is less contention.
138
139This also allows more parallelism when reading as read requests are
140distributed over all the devices in the array instead of all but one.
141
11a3e71d 142.SS MUTIPATH
e0d19036
NB
143
144MULTIPATH is not really a RAID at all as there is only one real device
145in a MULTIPATH md array. However there are multiple access points
146(paths) to this device, and one of these paths might fail, so there
147are some similarities.
148
2d465520
NB
149A MULTIPATH array is composed of a number of logical different
150devices, often fibre channel interfaces, that all refer the the same
151real device. If one of these interfaces fails (e.g. due to cable
152problems), the multipath driver to attempt to redirect requests to
153another interface.
e0d19036
NB
154
155
156.SS UNCLEAN SHUTDOWN
157
2d465520 158When changes are made to a RAID1, RAID4, or RAID5 array there is a
e0d19036
NB
159possibility of inconsistency for short periods of time as each update
160requires are least two block to be written to different devices, and
161these writes probably wont happen at exactly the same time.
2d465520 162Thus if a system with one of these arrays is shutdown in the middle of
e0d19036
NB
163a write operation (e.g. due to power failure), the array may not be
164consistent.
165
2d465520 166To handle this situation, the md driver marks an array as "dirty"
e0d19036
NB
167before writing any data to it, and marks it as "clean" when the array
168is being disabled, e.g. at shutdown.
169If the md driver finds an array to be dirty at startup, it proceeds to
170correct any possibly inconsistency. For RAID1, this involves copying
171the contents of the first drive onto all other drives.
172For RAID4 or RAID5 this involves recalculating the parity for each
173stripe and making sure that the parity block has the correct data.
174
175If a RAID4 or RAID5 array is degraded (missing one drive) when it is
176restarted after an unclean shutdown, it cannot recalculate parity, and
177so it is possible that data might be undetectably corrupted.
178The md driver currently
179.B does not
180alert the operator to this condition. It should probably fail to
181start an array in this condition without manual intervention.
182
183.SS RECOVERY
184
185If the md driver detects any error on a device in a RAID1, RAID4, or
186RAID5 array, it immediately disables that device (marking it as faulty)
187and continues operation on the remaining devices. If there is a spare
188drive, the driver will start recreating on one of the spare drives the
189data what was on that failed drive, either by copying a working drive
190in a RAID1 configuration, or by doing calculations with the parity
191block on RAID4 and RAID5.
192
2d465520 193While this recovery process is happening, the md driver will monitor
e0d19036
NB
194accesses to the array and will slow down the rate of recovery if other
195activity is happening, so that normal access to the array will not be
196unduly affected. When no other activity is happening, the recovery
197process proceeds at full speed. The actual speed targets for the two
198different situations can be controlled by the
199.B speed_limit_min
200and
201.B speed_limit_max
202control files mentioned below.
203
204
56eb10c0
NB
205.SH FILES
206.TP
207.B /proc/mdstat
208Contains information about the status of currently running array.
209.TP
210.B /proc/sys/dev/raid/speed_limit_min
211A readable and writable file that reflects the current goal rebuild
212speed for times when non-rebuild activity is current on an array.
213The speed is in Kibibytes per second, and is a per-device rate, not a
214per-array rate (which means that an array with more disc will shuffle
215more data for a given speed). The default is 100.
216
217.TP
218.B /proc/sys/dev/raid/speed_limit_max
219A readable and writable file that reflects the current goal rebuild
220speed for times when no non-rebuild activity is current on an array.
221The default is 100,000.
222
223.SH SEE ALSO
224.BR mdadm (8),
225.BR mkraid (8).