]> git.ipfire.org Git - thirdparty/mdadm.git/blame - mdmon.8
Provide a mdstat_ent to subarray helper
[thirdparty/mdadm.git] / mdmon.8
CommitLineData
7675959b 1.\" See file COPYING in distribution for details.
972ee725 2.TH MDMON 8 "" v3.1.4
7675959b
DW
3.SH NAME
4mdmon \- monitor MD external metadata arrays
5
6.SH SYNOPSIS
7
b5c727dc 8.BI mdmon " [--all] [--takeover] CONTAINER"
7675959b
DW
9
10.SH OVERVIEW
11The 2.6.27 kernel brings the ability to support external metadata arrays.
12External metadata implies that user space handles all updates to the metadata.
13The kernel's responsibility is to notify user space when a "metadata event"
14occurs, like disk failures and clean-to-dirty transitions. The kernel, in
15important cases, waits for user space to take action on these notifications.
16
17.SH DESCRIPTION
e0fe762a
N
18.SS Metadata updates:
19To service metadata update requests a daemon,
20.IR mdmon ,
21is introduced.
22.I Mdmon
23is tasked with polling the sysfs namespace looking for changes in
cd9a8b5c 24.BR array_state ,
7675959b
DW
25.BR sync_action ,
26and per disk
27.BR state
28attributes. When a change is detected it calls a per metadata type
29handler to make modifications to the metadata. The following actions
30are taken:
31.RS
32.TP
33.B array_state \- inactive
34Clear the dirty bit for the volume and let the array be stopped
35.TP
36.B array_state \- write pending
37Set the dirty bit for the array and then set
38.B array_state
39to
40.BR active .
41Writes
42are blocked until userspace writes
43.BR active.
44.TP
45.B array_state \- active-idle
46The safe mode timer has expired so set array state to clean to block writes to the array
47.TP
48.B array_state \- clean
49Clear the dirty bit for the volume
50.TP
51.B array_state \- read-only
e0fe762a
N
52This is the initial state that all arrays start at.
53.I mdmon
54takes one of the three actions:
7675959b
DW
55.RS
56.TP
571/
58Transition the array to read-auto keeping the dirty bit clear if the metadata
59handler determines that the array does not need resyncing or other modification
60.TP
612/
62Transition the array to active if the metadata handler determines a resync or
63some other manipulation is necessary
64.TP
653/
66Leave the array read\-only if the volume is marked to not be monitored; for
67example, the metadata version has been set to "external:\-dev/md127" instead of
68"external:/dev/md127"
69.RE
70.TP
71.B sync_action \- resync\-to\-idle
72Notify the metadata handler that a resync may have completed. If a resync
73process is idled before it completes this event allows the metadata handler to
74checkpoint resync.
75.TP
76.B sync_action \- recover\-to\-idle
77A spare may have completed rebuilding so tell the metadata handler about the
e0fe762a
N
78state of each disk. This is the metadata handler's opportunity to clear
79any "out-of-sync" bits and clear the volume's degraded status. If a recovery
7675959b
DW
80process is idled before it completes this event allows the metadata handler to
81checkpoint recovery.
82.TP
83.B <disk>/state \- faulty
84A disk failure kicks off a series of events. First, notify the metadata
85handler that a disk has failed, and then notify the kernel that it can unblock
86writes that were dependent on this disk. After unblocking the kernel this disk
e0fe762a 87is set to be removed+ from the member array. Finally the disk is marked failed
7675959b
DW
88in all other member arrays in the container.
89.IP
e0fe762a 90+ Note This behavior differs slightly from native MD arrays where
7675959b
DW
91removal is reserved for a
92.B mdadm --remove
93event. In the external metadata case the container holds the final
94reference on a block device and a
95.B mdadm --remove <container> <victim>
96call is still required.
97.RE
98
e0fe762a 99.SS Containers:
7675959b
DW
100.P
101External metadata formats, like DDF, differ from the native MD metadata
102formats in that they define a set of disks and a series of sub-arrays
103within those disks. MD metadata in comparison defines a 1:1
104relationship between a set of block devices and a raid array. For
105example to create 2 arrays at different raid levels on a single
106set of disks, MD metadata requires the disks be partitioned and then
107each array can created be created with a subset of those partitions. The
108supported external formats perform this disk carving internally.
109.P
110Container devices simply hold references to all member disks and allow
e0fe762a
N
111tools like
112.I mdmon
113to determine which active arrays belong to which
7675959b
DW
114container. Some array management commands like disk removal and disk
115add are now only valid at the container level. Attempts to perform
116these actions on member arrays are blocked with error messages like:
117.IP
118"mdadm: Cannot remove disks from a \'member\' array, perform this
119operation on the parent container"
120.P
121Containers are identified in /proc/mdstat with a metadata version string
122"external:<metadata name>". Member devices are identified by
123"external:/<container device>/<member index>", or "external:-<container
124device>/<member index>" if the array is to remain readonly.
125
126.SH OPTIONS
127.TP
128CONTAINER
129The
130.B container
b5c727dc
N
131device to monitor. It can be a full path like /dev/md/container, or a
132simple md device name like md127.
7675959b 133.TP
b5c727dc
N
134.B \-\-takeover
135This instructs
136.I mdmon
137to replace any active
138.I mdmon
139which is currently monitoring the array. This is primarily used late
140in the boot process to replace any
141.I mdmon
142which was started from an
143.B initramfs
144before the root filesystem was mounted. This avoids holding a
145reference on that
146.B initramfs
147indefinitely and ensures that the
148.I pid
149and
150.I sock
151files used to communicate with
152.I mdmon
153are in a standard place.
5d4d1b26 154.TP
b5c727dc
N
155.B \-\-all
156This tells mdmon to find any active containers and start monitoring
157each of them if appropriate. This is normally used with
158.B \-\-takeover
159late in the boot sequence.
eb49460b
LB
160A separate
161.I mdmon
162process is started for each container as the
163.B \-\-all
164argument is over-written with the name of the container. To allow for
165containers with names longer than 5 characters, this argument can be
166arbitrarily extended, e.g. to
167.BR \-\-all-active-arrays .
5d4d1b26 168
e0fe762a
N
169.PP
170Note that
171.I mdmon
172is automatically started by
173.I mdadm
174when needed and so does not need to be considered when working with
175RAID arrays. The only times it is run other that by
176.I mdadm
177is when the boot scripts need to restart it after mounting the new
178root filesystem.
7675959b 179
cd9a8b5c
N
180.SH START UP AND SHUTDOWN
181
182As
183.I mdmon
184needs to be running whenever any filesystem on the monitored device is
185mounted there are special considerations when the root filesystem is
186mounted from an
187.I mdmon
188monitored device.
ecdbb368
N
189Note that in general
190.I mdmon
191is needed even if the filesystem is mounted read-only as some
192filesystems can still write to the device in those circumstances, for
193example to replay a journal after an unclean shutdown.
cd9a8b5c
N
194
195When the array is assembled by the
196.B initramfs
197code, mdadm will automatically start
198.I mdmon
199as required. This means that
200.I mdmon
201must be installed on the
202.B initramfs
9fdcb471 203and there must be a writable filesystem (typically tmpfs) in which
cd9a8b5c
N
204.B mdmon
205can create a
206.B .pid
207and
208.B .sock
9fdcb471 209file. The particular filesystem to use is given to mdmon at compile
cd9a8b5c 210time and defaults to
7f5de63d 211.BR /dev/.mdadm .
cd9a8b5c 212
9fdcb471 213This filesystem must persist through to shutdown time.
cd9a8b5c
N
214
215After the final root filesystem has be instantiated (usually with
216.BR pivot_root )
cd9a8b5c
N
217.I mdmon
218should be run with
219.I "\-\-all \-\-takeover"
220so that the
221.I mdmon
222running from the
223.B initramfs
9fdcb471
N
224can be replaced with one running in the main root, and so the
225memory used by the initramfs can be released.
cd9a8b5c
N
226
227At shutdown time,
228.I mdmon
229should not be killed along with other processes. Also as it holds a
230file (socket actually) open in
9fdcb471
N
231.B /dev
232(by default) it will not be possible to unmount
233.B /dev
234if it is a separate filesystem.
cd9a8b5c 235
b5c727dc 236.SH EXAMPLES
5d4d1b26 237
eb49460b 238.B " mdmon \-\-all-active-arrays \-\-takeover"
5d4d1b26
N
239.br
240Any
241.I mdmon
242which is currently running is killed and a new instance is started.
9fdcb471
N
243This should be run during in the boot sequence if an initramfs was
244used, so that any mdmon running from the initramfs will not hold
245the initramfs active.
e0fe762a
N
246.SH SEE ALSO
247.IR mdadm (8),
248.IR md (4).