]> git.ipfire.org Git - thirdparty/mdadm.git/blame - md.4
Change MAJOR() etc to major() etc
[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 17supports RAID levels 1 (mirroring) 4 (striped array with parity
98c6faba
NB
18device), 5 (striped array with distributed parity information) and 6
19(striped array with distributed dual redundancy information.) If a
20some number of underlying devices fails while using one of these
21levels, the array will continue to function; this number is one for
22RAID levels 4 and 5, two for RAID level 6, and all but one (N-1) for
23RAID level 1.
56eb10c0
NB
24.PP
25.B md
e0d19036 26also supports a number of pseudo RAID (non-redundant) configurations
56eb10c0
NB
27including RAID0 (striped array), LINEAR (catenated array) and
28MULTIPATH (a set of different interfaces to the same device).
29
11a3e71d 30.SS MD SUPER BLOCK
56eb10c0 31With the exception of Legacy Arrays described below, each device that
e0d19036 32is incorporated into an MD array has a
56eb10c0
NB
33.I super block
34written towards the end of the device. This superblock records
35information about the structure and state of the array so that the
11a3e71d 36array can be reliably re-assembled after a shutdown.
56eb10c0
NB
37
38The superblock is 4K long and is written into a 64K aligned block that
11a3e71d 39starts at least 64K and less than 128K from the end of the device
56eb10c0
NB
40(i.e. to get the address of the superblock round the size of the
41device down to a multiple of 64K and then subtract 64K).
11a3e71d 42The available size of each device is the amount of space before the
56eb10c0
NB
43super block, so between 64K and 128K is lost when a device in
44incorporated into an MD array.
45
46The superblock contains, among other things:
47.TP
48LEVEL
11a3e71d
NB
49The manner in which the devices are arranged into the array
50(linear, raid0, raid1, raid4, raid5, multipath).
56eb10c0
NB
51.TP
52UUID
53a 128 bit Universally Unique Identifier that identifies the array that
54this device is part of.
55
11a3e71d
NB
56.SS LEGACY ARRAYS
57Early versions of the
58.B md
59driver only supported Linear and Raid0 configurations and so
2d465520 60did not use an MD superblock (as there is no state that needs to be
11a3e71d
NB
61recorded). While it is strongly recommended that all newly created
62arrays utilise a superblock to help ensure that they are assembled
63properly, the
64.B md
65driver still supports legacy linear and raid0 md arrays that
66do not have a superblock.
67
56eb10c0 68.SS LINEAR
11a3e71d
NB
69
70A linear array simply catenates the available space on each
71drive together to form one large virtual drive.
72
73One advantage of this arrangement over the more common RAID0
74arrangement is that the array may be reconfigured at a later time with
75an extra drive and so the array is made bigger without disturbing the
76data that is on the array. However this cannot be done on a live
77array.
78
79
56eb10c0 80.SS RAID0
11a3e71d
NB
81
82A RAID0 array (which has zero redundancy) is also known as a
83striped array.
e0d19036
NB
84A RAID0 array is configured at creation with a
85.B "Chunk Size"
c913b90e 86which must be a power of two, and at least 4 kibibytes.
e0d19036 87
2d465520 88The RAID0 driver assigns the first chunk of the array to the first
e0d19036 89device, the second chunk to the second device, and so on until all
2d465520 90drives have been assigned one chunk. This collection of chunks forms
e0d19036
NB
91a
92.BR stripe .
93Further chunks are gathered into stripes in the same way which are
94assigned to the remaining space in the drives.
95
2d465520
NB
96If devices in the array are not all the same size, then once the
97smallest device has been exhausted, the RAID0 driver starts
e0d19036
NB
98collecting chunks into smaller stripes that only span the drives which
99still have remaining space.
100
101
56eb10c0 102.SS RAID1
e0d19036
NB
103
104A RAID1 array is also known as a mirrored set (though mirrors tend to
5787fa49 105provide reflected images, which RAID1 does not) or a plex.
e0d19036
NB
106
107Once initialised, each device in a RAID1 array contains exactly the
108same data. Changes are written to all devices in parallel. Data is
109read from any one device. The driver attempts to distribute read
110requests across all devices to maximise performance.
111
112All devices in a RAID1 array should be the same size. If they are
113not, then only the amount of space available on the smallest device is
114used. Any extra space on other devices is wasted.
115
56eb10c0 116.SS RAID4
e0d19036
NB
117
118A RAID4 array is like a RAID0 array with an extra device for storing
aa88f531
NB
119parity. This device is the last of the active devices in the
120array. Unlike RAID0, RAID4 also requires that all stripes span all
e0d19036
NB
121drives, so extra space on devices that are larger than the smallest is
122wasted.
123
124When any block in a RAID4 array is modified the parity block for that
125stripe (i.e. the block in the parity device at the same device offset
126as the stripe) is also modified so that the parity block always
127contains the "parity" for the whole stripe. i.e. its contents is
128equivalent to the result of performing an exclusive-or operation
129between all the data blocks in the stripe.
130
131This allows the array to continue to function if one device fails.
132The data that was on that device can be calculated as needed from the
133parity block and the other data blocks.
134
56eb10c0 135.SS RAID5
e0d19036
NB
136
137RAID5 is very similar to RAID4. The difference is that the parity
138blocks for each stripe, instead of being on a single device, are
139distributed across all devices. This allows more parallelism when
140writing as two different block updates will quite possibly affect
141parity blocks on different devices so there is less contention.
142
143This also allows more parallelism when reading as read requests are
144distributed over all the devices in the array instead of all but one.
145
98c6faba
NB
146.SS RAID6
147
148RAID6 is similar to RAID5, but can handle the loss of any \fItwo\fP
149devices without data loss. Accordingly, it requires N+2 drives to
150store N drives worth of data.
151
152The performance for RAID6 is slightly lower but comparable to RAID5 in
153normal mode and single disk failure mode. It is very slow in dual
154disk failure mode, however.
155
11a3e71d 156.SS MUTIPATH
e0d19036
NB
157
158MULTIPATH is not really a RAID at all as there is only one real device
159in a MULTIPATH md array. However there are multiple access points
160(paths) to this device, and one of these paths might fail, so there
161are some similarities.
162
2d465520
NB
163A MULTIPATH array is composed of a number of logical different
164devices, often fibre channel interfaces, that all refer the the same
165real device. If one of these interfaces fails (e.g. due to cable
166problems), the multipath driver to attempt to redirect requests to
167another interface.
e0d19036 168
b5e64645
NB
169.SS FAULTY
170The FAULTY md module is provided for testing purposes. A faulty array
171has exactly one component device and is normally assembled without a
172superblock, so the md array created provides direct access to all of
173the data in the component device.
174
175The FAULTY module may be requested to simulate faults to allow testing
176of other md levels or of filesystem. Faults can be chosen to trigger
177on read requests or write requests, and can be transient (a subsequent
178read/write at the address will probably succeed) or persistant
179(subsequent read/write of the same address will fail). Further, read
180faults can be "fixable" meaning that they persist until a write
181request at the same address.
182
183Fault types can be requested with a period. In this case the fault
184will recur repeatedly after the given number of request of the
185relevant time. For example if persistent read faults have a period of
186100, then ever 100th read request would generate a fault, and the
187faulty sector would be recorded so that subsequent reads on that
188sector would also fail.
189
190There is a limit to the number of faulty sectors that are remembered.
191Faults generated after this limit is exhausted are treated as
192transient.
193
194It list of faulty sectors can be flushed, and the active list of
195failure modes can be cleared.
e0d19036
NB
196
197.SS UNCLEAN SHUTDOWN
198
98c6faba 199When changes are made to a RAID1, RAID4, RAID5 or RAID6 array there is a
e0d19036
NB
200possibility of inconsistency for short periods of time as each update
201requires are least two block to be written to different devices, and
202these writes probably wont happen at exactly the same time.
2d465520 203Thus if a system with one of these arrays is shutdown in the middle of
e0d19036
NB
204a write operation (e.g. due to power failure), the array may not be
205consistent.
206
2d465520 207To handle this situation, the md driver marks an array as "dirty"
e0d19036 208before writing any data to it, and marks it as "clean" when the array
98c6faba
NB
209is being disabled, e.g. at shutdown. If the md driver finds an array
210to be dirty at startup, it proceeds to correct any possibly
211inconsistency. For RAID1, this involves copying the contents of the
212first drive onto all other drives. For RAID4, RAID5 and RAID6 this
213involves recalculating the parity for each stripe and making sure that
214the parity block has the correct data. This process, known as
215"resynchronising" or "resync" is performed in the background. The
216array can still be used, though possibly with reduced performance.
217
218If a RAID4, RAID5 or RAID6 array is degraded (missing at least one
219drive) when it is restarted after an unclean shutdown, it cannot
220recalculate parity, and so it is possible that data might be
221undetectably corrupted. The 2.4 md driver
e0d19036 222.B does not
5787fa49 223alert the operator to this condition. The 2.5 md driver will fail to
e0d19036
NB
224start an array in this condition without manual intervention.
225
226.SS RECOVERY
227
98c6faba
NB
228If the md driver detects any error on a device in a RAID1, RAID4,
229RAID5 or RAID6 array, it immediately disables that device (marking it
230as faulty) and continues operation on the remaining devices. If there
231is a spare drive, the driver will start recreating on one of the spare
232drives the data what was on that failed drive, either by copying a
233working drive in a RAID1 configuration, or by doing calculations with
234the parity block on RAID4, RAID5 or RAID6.
e0d19036 235
2d465520 236While this recovery process is happening, the md driver will monitor
e0d19036
NB
237accesses to the array and will slow down the rate of recovery if other
238activity is happening, so that normal access to the array will not be
239unduly affected. When no other activity is happening, the recovery
240process proceeds at full speed. The actual speed targets for the two
241different situations can be controlled by the
242.B speed_limit_min
243and
244.B speed_limit_max
245control files mentioned below.
246
5787fa49
NB
247.SS KERNEL PARAMETERS
248
249The md driver recognised three different kernel parameters.
250.TP
251.B raid=noautodetect
252This will disable the normal detection of md arrays that happens at
253boot time. If a drive is partitioned with MS-DOS style partitions,
254then if any of the 4 main partitions has a partition type of 0xFD,
255then that partition will normally be inspected to see if it is part of
256an MD array, and if any full arrays are found, they are started. This
257kernel paramenter disables this behaviour.
258
259.TP
260.BI md= n , dev , dev ,...
261This tells the md driver to assemble
262.B /dev/md n
263from the listed devices. It is only necessary to start the device
264holding the root filesystem this way. Other arrays are best started
265once the system is booted.
266
267.TP
268.BI md= n , l , c , i , dev...
269This tells the md driver to assemble a legacy RAID0 or LINEAR array
270without a superblock.
271.I n
272gives the md device number,
273.I l
274gives the level, 0 for RAID0 or -1 for LINEAR,
275.I c
276gives the chunk size as a base-2 logarithm offset by twelve, so 0
277means 4K, 1 means 8K.
278.I i
279is ignored (legacy support).
e0d19036 280
56eb10c0
NB
281.SH FILES
282.TP
283.B /proc/mdstat
284Contains information about the status of currently running array.
285.TP
286.B /proc/sys/dev/raid/speed_limit_min
287A readable and writable file that reflects the current goal rebuild
288speed for times when non-rebuild activity is current on an array.
289The speed is in Kibibytes per second, and is a per-device rate, not a
290per-array rate (which means that an array with more disc will shuffle
291more data for a given speed). The default is 100.
292
293.TP
294.B /proc/sys/dev/raid/speed_limit_max
295A readable and writable file that reflects the current goal rebuild
296speed for times when no non-rebuild activity is current on an array.
297The default is 100,000.
298
299.SH SEE ALSO
300.BR mdadm (8),
301.BR mkraid (8).