]> git.ipfire.org Git - thirdparty/mdadm.git/blame - md.4
mdadm-1.3.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
5787fa49 102provide reflected images, which RAID1 does not) or a plex.
e0d19036
NB
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
aa88f531
NB
116parity. This device is the last of the active devices in the
117array. Unlike RAID0, RAID4 also requires that all stripes span all
e0d19036
NB
118drives, so extra space on devices that are larger than the smallest is
119wasted.
120
121When any block in a RAID4 array is modified the parity block for that
122stripe (i.e. the block in the parity device at the same device offset
123as the stripe) is also modified so that the parity block always
124contains the "parity" for the whole stripe. i.e. its contents is
125equivalent to the result of performing an exclusive-or operation
126between all the data blocks in the stripe.
127
128This allows the array to continue to function if one device fails.
129The data that was on that device can be calculated as needed from the
130parity block and the other data blocks.
131
56eb10c0 132.SS RAID5
e0d19036
NB
133
134RAID5 is very similar to RAID4. The difference is that the parity
135blocks for each stripe, instead of being on a single device, are
136distributed across all devices. This allows more parallelism when
137writing as two different block updates will quite possibly affect
138parity blocks on different devices so there is less contention.
139
140This also allows more parallelism when reading as read requests are
141distributed over all the devices in the array instead of all but one.
142
11a3e71d 143.SS MUTIPATH
e0d19036
NB
144
145MULTIPATH is not really a RAID at all as there is only one real device
146in a MULTIPATH md array. However there are multiple access points
147(paths) to this device, and one of these paths might fail, so there
148are some similarities.
149
2d465520
NB
150A MULTIPATH array is composed of a number of logical different
151devices, often fibre channel interfaces, that all refer the the same
152real device. If one of these interfaces fails (e.g. due to cable
153problems), the multipath driver to attempt to redirect requests to
154another interface.
e0d19036
NB
155
156
157.SS UNCLEAN SHUTDOWN
158
2d465520 159When changes are made to a RAID1, RAID4, or RAID5 array there is a
e0d19036
NB
160possibility of inconsistency for short periods of time as each update
161requires are least two block to be written to different devices, and
162these writes probably wont happen at exactly the same time.
2d465520 163Thus if a system with one of these arrays is shutdown in the middle of
e0d19036
NB
164a write operation (e.g. due to power failure), the array may not be
165consistent.
166
2d465520 167To handle this situation, the md driver marks an array as "dirty"
e0d19036
NB
168before writing any data to it, and marks it as "clean" when the array
169is being disabled, e.g. at shutdown.
170If the md driver finds an array to be dirty at startup, it proceeds to
171correct any possibly inconsistency. For RAID1, this involves copying
172the contents of the first drive onto all other drives.
173For RAID4 or RAID5 this involves recalculating the parity for each
174stripe and making sure that the parity block has the correct data.
5787fa49
NB
175This process, known as "resynchronising" or "resync" is performed in
176the background. The array can still be used, though possibly with
177reduced performance.
e0d19036
NB
178
179If a RAID4 or RAID5 array is degraded (missing one drive) when it is
180restarted after an unclean shutdown, it cannot recalculate parity, and
181so it is possible that data might be undetectably corrupted.
5787fa49 182The 2.4 md driver
e0d19036 183.B does not
5787fa49 184alert the operator to this condition. The 2.5 md driver will fail to
e0d19036
NB
185start an array in this condition without manual intervention.
186
187.SS RECOVERY
188
189If the md driver detects any error on a device in a RAID1, RAID4, or
190RAID5 array, it immediately disables that device (marking it as faulty)
191and continues operation on the remaining devices. If there is a spare
192drive, the driver will start recreating on one of the spare drives the
193data what was on that failed drive, either by copying a working drive
194in a RAID1 configuration, or by doing calculations with the parity
195block on RAID4 and RAID5.
196
2d465520 197While this recovery process is happening, the md driver will monitor
e0d19036
NB
198accesses to the array and will slow down the rate of recovery if other
199activity is happening, so that normal access to the array will not be
200unduly affected. When no other activity is happening, the recovery
201process proceeds at full speed. The actual speed targets for the two
202different situations can be controlled by the
203.B speed_limit_min
204and
205.B speed_limit_max
206control files mentioned below.
207
5787fa49
NB
208.SS KERNEL PARAMETERS
209
210The md driver recognised three different kernel parameters.
211.TP
212.B raid=noautodetect
213This will disable the normal detection of md arrays that happens at
214boot time. If a drive is partitioned with MS-DOS style partitions,
215then if any of the 4 main partitions has a partition type of 0xFD,
216then that partition will normally be inspected to see if it is part of
217an MD array, and if any full arrays are found, they are started. This
218kernel paramenter disables this behaviour.
219
220.TP
221.BI md= n , dev , dev ,...
222This tells the md driver to assemble
223.B /dev/md n
224from the listed devices. It is only necessary to start the device
225holding the root filesystem this way. Other arrays are best started
226once the system is booted.
227
228.TP
229.BI md= n , l , c , i , dev...
230This tells the md driver to assemble a legacy RAID0 or LINEAR array
231without a superblock.
232.I n
233gives the md device number,
234.I l
235gives the level, 0 for RAID0 or -1 for LINEAR,
236.I c
237gives the chunk size as a base-2 logarithm offset by twelve, so 0
238means 4K, 1 means 8K.
239.I i
240is ignored (legacy support).
e0d19036 241
56eb10c0
NB
242.SH FILES
243.TP
244.B /proc/mdstat
245Contains information about the status of currently running array.
246.TP
247.B /proc/sys/dev/raid/speed_limit_min
248A readable and writable file that reflects the current goal rebuild
249speed for times when non-rebuild activity is current on an array.
250The speed is in Kibibytes per second, and is a per-device rate, not a
251per-array rate (which means that an array with more disc will shuffle
252more data for a given speed). The default is 100.
253
254.TP
255.B /proc/sys/dev/raid/speed_limit_max
256A readable and writable file that reflects the current goal rebuild
257speed for times when no non-rebuild activity is current on an array.
258The default is 100,000.
259
260.SH SEE ALSO
261.BR mdadm (8),
262.BR mkraid (8).