{"id":3307,"date":"2022-12-20T17:02:18","date_gmt":"2022-12-20T20:02:18","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/mdmon-man8\/"},"modified":"2022-12-20T17:02:18","modified_gmt":"2022-12-20T20:02:18","slug":"mdmon-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/mdmon-man8\/","title":{"rendered":"MDMON (man8)"},"content":{"rendered":"<h1 align=\"center\">MDMON<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#OVERVIEW\">OVERVIEW<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#OPTIONS\">OPTIONS<\/a><br \/> <a href=\"#START UP AND SHUTDOWN\">START UP AND SHUTDOWN<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">mdmon \u2212 monitor MD external metadata arrays<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mdmon<\/b> <i>[&#8211;all] [&#8211;takeover] [&#8211;foreground] CONTAINER<\/i><\/p>\n<h2>OVERVIEW <a name=\"OVERVIEW\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The 2.6.27 kernel brings the ability to support external metadata arrays. External metadata implies that user space handles all updates to the metadata. The kernel\u2019s responsibility is to notify user space when a &#8220;metadata event&#8221; occurs, like disk failures and clean-to-dirty transitions. The kernel, in important cases, waits for user space to take action on these notifications.<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Metadata updates:<\/b> <br \/> To service metadata update requests a daemon, <i>mdmon<\/i>, is introduced. <i>Mdmon<\/i> is tasked with polling the sysfs namespace looking for changes in <b>array_state<\/b>, <b>sync_action<\/b>, and per disk <b>state<\/b> attributes. When a change is detected it calls a per metadata type handler to make modifications to the metadata. The following actions are taken:<\/p>\n<p style=\"margin-left:22%;\"><b>array_state \u2212 inactive<\/b><\/p>\n<p style=\"margin-left:32%;\">Clear the dirty bit for the volume and let the array be stopped<\/p>\n<p style=\"margin-left:22%;\"><b>array_state \u2212 write pending<\/b><\/p>\n<p style=\"margin-left:32%;\">Set the dirty bit for the array and then set <b>array_state<\/b> to <b>active<\/b>. Writes are blocked until userspace writes <b>active.<\/b><\/p>\n<p style=\"margin-left:22%;\"><b>array_state \u2212 active-idle<\/b><\/p>\n<p style=\"margin-left:32%;\">The safe mode timer has expired so set array state to clean to block writes to the array<\/p>\n<p style=\"margin-left:22%;\"><b>array_state \u2212 clean<\/b><\/p>\n<p style=\"margin-left:32%;\">Clear the dirty bit for the volume<\/p>\n<p style=\"margin-left:22%;\"><b>array_state \u2212 read-only<\/b><\/p>\n<p style=\"margin-left:32%;\">This is the initial state that all arrays start at. <i>mdmon<\/i> takes one of the three actions:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"32%\"><\/td>\n<td width=\"3%\">\n<p>1\/<\/p>\n<\/td>\n<td width=\"8%\"><\/td>\n<td width=\"57%\">\n<p>Transition the array to read-auto keeping the dirty bit clear if the metadata handler determines that the array does not need resyncing or other modification<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"32%\"><\/td>\n<td width=\"3%\">\n<p>2\/<\/p>\n<\/td>\n<td width=\"8%\"><\/td>\n<td width=\"57%\">\n<p>Transition the array to active if the metadata handler determines a resync or some other manipulation is necessary<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"32%\"><\/td>\n<td width=\"3%\">\n<p>3\/<\/p>\n<\/td>\n<td width=\"8%\"><\/td>\n<td width=\"57%\">\n<p>Leave the array read\u2212only if the volume is marked to not be monitored; for example, the metadata version has been set to &#8220;external:\u2212dev\/md127&#8221; instead of &#8220;external:\/dev\/md127&#8221;<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%;\"><b>sync_action \u2212 resync\u2212to\u2212idle<\/b><\/p>\n<p style=\"margin-left:32%;\">Notify the metadata handler that a resync may have completed. If a resync process is idled before it completes this event allows the metadata handler to checkpoint resync.<\/p>\n<p style=\"margin-left:22%;\"><b>sync_action \u2212 recover\u2212to\u2212idle<\/b><\/p>\n<p style=\"margin-left:32%;\">A spare may have completed rebuilding so tell the metadata handler about the state of each disk. This is the metadata handler\u2019s opportunity to clear any &#8220;out-of-sync&#8221; bits and clear the volume\u2019s degraded status. If a recovery process is idled before it completes this event allows the metadata handler to checkpoint recovery.<\/p>\n<p style=\"margin-left:22%;\"><b><disk>\/state \u2212 faulty<\/b><\/p>\n<p style=\"margin-left:32%;\">A disk failure kicks off a series of events. First, notify the metadata handler that a disk has failed, and then notify the kernel that it can unblock writes that were dependent on this disk. After unblocking the kernel this disk is set to be removed+ from the member array. Finally the disk is marked failed in all other member arrays in the container.<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\">+ Note This behavior differs slightly from native MD arrays where removal is reserved for a <b>mdadm &#8211;remove<\/b> event. In the external metadata case the container holds the final reference on a block device and a <b>mdadm &#8211;remove <container> <victim><\/b> call is still required.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Containers:<\/b> <br \/> External metadata formats, like DDF, differ from the native MD metadata formats in that they define a set of disks and a series of sub-arrays within those disks. MD metadata in comparison defines a 1:1 relationship between a set of block devices and a RAID array. For example to create 2 arrays at different RAID levels on a single set of disks, MD metadata requires the disks be partitioned and then each array can be created with a subset of those partitions. The supported external formats perform this disk carving internally.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Container devices simply hold references to all member disks and allow tools like <i>mdmon<\/i> to determine which active arrays belong to which container. Some array management commands like disk removal and disk add are now only valid at the container level. Attempts to perform these actions on member arrays are blocked with error messages like:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">&#8220;mdadm: Cannot remove disks from a \u00b4member\u00b4 array, perform this operation on the parent container&#8221;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Containers are identified in \/proc\/mdstat with a metadata version string &#8220;external:<metadata name>&#8220;. Member devices are identified by &#8220;external:\/<container device>\/<member index>&#8220;, or &#8220;external:-<container device>\/<member index>&#8221; if the array is to remain readonly.<\/p>\n<h2>OPTIONS <a name=\"OPTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">CONTAINER<\/p>\n<p style=\"margin-left:22%;\">The <b>container<\/b> device to monitor. It can be a full path like \/dev\/md\/container, or a simple md device name like md127.<\/p>\n<p style=\"margin-left:11%;\"><b>\u2212\u2212foreground<\/b><\/p>\n<p style=\"margin-left:22%;\">Normally, <i>mdmon<\/i> will fork and continue in the background. Adding this option will skip that step and run <i>mdmon<\/i> in the foreground.<\/p>\n<p style=\"margin-left:11%;\"><b>\u2212\u2212takeover<\/b><\/p>\n<p style=\"margin-left:22%;\">This instructs <i>mdmon<\/i> to replace any active <i>mdmon<\/i> which is currently monitoring the array. This is primarily used late in the boot process to replace any <i>mdmon<\/i> which was started from an <b>initramfs<\/b> before the root filesystem was mounted. This avoids holding a reference on that <b>initramfs<\/b> indefinitely and ensures that the <i>pid<\/i> and <i>sock<\/i> files used to communicate with <i>mdmon<\/i> are in a standard place.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p><b>\u2212\u2212all<\/b><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"78%\">\n<p>This tells mdmon to find any active containers and start monitoring each of them if appropriate. This is normally used with <b>\u2212\u2212takeover<\/b> late in the boot sequence. A separate <i>mdmon<\/i> process is started for each container as the <b>\u2212\u2212all<\/b> argument is over-written with the name of the container. To allow for containers with names longer than 5 characters, this argument can be arbitrarily extended, e.g. to <b>\u2212\u2212all-active-arrays<\/b>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%; margin-top: 1em\">Note that <i><br \/> mdmon<\/i> is automatically started by <i>mdadm<\/i> when needed and so does not need to be considered when working with RAID arrays. The only times it is run other than by <i>mdadm<\/i> is when the boot scripts need to restart it after mounting the new root filesystem.<\/p>\n<h2>START UP AND SHUTDOWN <a name=\"START UP AND SHUTDOWN\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">As <i>mdmon<\/i> needs to be running whenever any filesystem on the monitored device is mounted there are special considerations when the root filesystem is mounted from an <i>mdmon<\/i> monitored device. Note that in general <i>mdmon<\/i> is needed even if the filesystem is mounted read-only as some filesystems can still write to the device in those circumstances, for example to replay a journal after an unclean shutdown.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When the array is assembled by the <b>initramfs<\/b> code, mdadm will automatically start <i>mdmon<\/i> as required. This means that <i>mdmon<\/i> must be installed on the <b>initramfs<\/b> and there must be a writable filesystem (typically tmpfs) in which <b>mdmon<\/b> can create a <b>.pid<\/b> and <b>.sock<\/b> file. The particular filesystem to use is given to mdmon at compile time and defaults to <b>\/run\/mdadm<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This filesystem must persist through to shutdown time.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">After the final root filesystem has be instantiated (usually with <b>pivot_root<\/b>) <i>mdmon<\/i> should be run with <i>\u2212\u2212all \u2212\u2212takeover<\/i> so that the <i>mdmon<\/i> running from the <b>initramfs<\/b> can be replaced with one running in the main root, and so the memory used by the initramfs can be released.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">At shutdown time, <i>mdmon<\/i> should not be killed along with other processes. Also as it holds a file (socket actually) open in <b>\/dev<\/b> (by default) it will not be possible to unmount <b>\/dev<\/b> if it is a separate filesystem.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mdmon \u2212\u2212all-active-arrays \u2212\u2212takeover<\/b> <br \/> Any <i>mdmon<\/i> which is currently running is killed and a new instance is started. This should be run during in the boot sequence if an initramfs was used, so that any mdmon running from the initramfs will not hold the initramfs active.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>mdadm<\/i>(8), <i>md<\/i>(4).<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  mdmon \u2212 monitor MD external metadata arrays <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,4,438],"class_list":["post-3307","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-mdmon"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=3307"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3307\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=3307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=3307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=3307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}