.\" See file COPYING in distribution for details.
-.TH MDMON 8 "" v3.0-rc1
+.TH MDMON 8 "" v3.1.1
.SH NAME
mdmon \- monitor MD external metadata arrays
.SH SYNOPSIS
-.BI mdmon " CONTAINER [NEWROOT]"
+.BI mdmon " CONTAINER [NEWROOT | PID]"
.SH OVERVIEW
The 2.6.27 kernel brings the ability to support external metadata arrays.
The
.B container
device to monitor. It can be a full path like /dev/md/container, a simple md
-device name like md127, or /proc/mdstat which tells
+device name like md127, or
+.I \-\-all
+ which tells
.I mdmon
to scan for containers and launch an
.I mdmon
instances that are running in the current namespace,
.IR chroot (2)
to NEWROOT, and continue monitoring the container.
+
+Alternately the new
+.I mdmon
+can be started after the new root has been installed with
+.I pivotroot
+by passing
+.B /
+as the NEWROOT. For
+.I mdmon
+to be able to find and kill the old
+.I mdmon
+there must be some part of the filesystem that persists from before
+the
+.I pivotroot
+to afterwards. This can be
+.B /var/run/mdadm
+or some other directory. The default other directory is
+.B /lib/init/rw/mdadm
+but this can easily be changed when
+.I mdmon
+is compiled.
+If
+.I mdmon
+cannot store the pid file in
+.B /var/run/mdadm
+it will store it in the other directory until
+.B /var/run/mdadm
+becomes available, or until it is killed.
+.TP
+[PID]
+If the second argument to
+.I mdmon
+does not start with a slash it is assumed to be the pid of a previous
+instance of
+.I mdmon
+to kill. This is used internally by
+.I mdmon
+to pass the pid across a chroot/exec and should not be used otherwise.
+
.PP
Note that
.I mdmon
is when the boot scripts need to restart it after mounting the new
root filesystem.
+.SH EXMAPLES
+
+.B " mdmon --all /"
+.br
+Any
+.I mdmon
+which is currently running is killed and a new instance is started.
+This should be run early in the boot sequence after a
+.I pivotroot
+to the final root filesystem, but before that filesystem is remounted
+read-write.
.SH SEE ALSO
.IR mdadm (8),
.IR md (4).