Bug#415336: mdadm: doWhatINeed argument to init script

Eduard Bloch edi at gmx.de
Tue Apr 3 14:04:38 UTC 2007


reopen 415336
thanks

You have pretty short timeouts...

See attachments for an extended version of your script, allowing to
force the update of the array data. Because currently it sucks, it does
not start the arrays on Knoppix because there is a dummy config file
already, and it does not tell you what is going wrong :-(

A manpage is also there.

Eduard.
-------------- next part --------------
#!/bin/sh
#
# startall -- starts all existing arrays after creating mdadm.conf
#             overrides the AUTOSTART variable in /etc/default/mdadm
#
# Copyright ? martin f. krafft <madduck at madduck.net>
# distributed under the terms of the Artistic Licence 2.0
#
# Partial rewrite by Eduard Bloch <blade at debian.org>, 2007
#
# $Id: startall 272 2006-11-11 19:54:38Z madduck $
#

set -eu

CONFIG=/etc/mdadm/mdadm.conf
ALTCONFIG=/etc/mdadm.conf

modprobe -kq md 2>/dev/null || :

if [ "$1" = "-r" ] ; then
	PREPENDCMD="(cat $CONFIG || cat $ALTCONFIG) | grep -v '^ARRAY'"
fi

if [ ! -f $CONFIG ] && [ ! -f $ALTCONFIG ] ; then
   PREPENDCMD=:
fi

if [ -n "$PREPENDCMD" ]; then
  mkdir --parents ${CONFIG%/*}
  $PREPENDCMD > $CONFIG.new
  /sbin/mdadm --examine --scan --config=partitions >> $CONFIG.new || ret=$?
  mv -f $CONFIG.new $CONFIG
  case ${ret:-0} in
    0) :;;
    255) echo W: mdadm: using existing mdadm.conf file... >&2;;
    *)
      echo E: mdadm: mdadm.conf creation failed, aborting. >&2
      exit $ret
      ;;
  esac
  if ! grep -q '^ARRAY' $CONFIG ; then
     echo "No array configuration could be retrieved. Consider using -r."
     exit 1
  fi
fi

MDADM_FORCE_AUTOSTART__=1 exec /etc/init.d/mdadm-raid start
-------------- next part --------------
.\" This manpage has been automatically generated by docbook2man 
.\" from a DocBook document.  This tool can be found at:
.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/> 
.\" Please send any bug reports, improvements, comments, patches, 
.\" etc. to Steve Cheng <steve at ggi-project.org>.
.TH "MDADM-STARTALL" "8" "03 April 2007" "" ""

.SH NAME
mdadm-startall \- helper script to start all inactive arrays
.SH SYNOPSIS

\fBmdadm\fR [ \fB-r\fR ]

.SH "DESCRIPTION"
.PP
The \fBmdadm-startall\fR script starts all raids that are inactive yet and examines their configuration when needed.
.SH "OPTIONS"
.TP
\fB-r \fR
Force the examination of MD array configuration.
.SH "SEE ALSO"
.PP
mdadm (8), mdadm.conf(5)
.SH "AUTHOR"
.PP
This manual page was written by Eduard Bloch <blade at debian.org> for
the Debian system (but may be used by others).  Permission is
granted to copy, distribute and/or modify this document under
the terms of the GNU General Public License, Version 2 any 
later version published by the Free Software Foundation.
.PP
On Debian systems, the complete text of the GNU General Public
License can be found in /usr/share/common-licenses/GPL.
-------------- next part --------------
<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [

<!-- Process this file with docbook-to-man to generate an nroff manual
     page: `docbook-to-man manpage.sgml > manpage.1'.  You may view
     the manual page with: `docbook-to-man manpage.sgml | nroff -man |
     less'.  A typical entry in a Makefile or Makefile.am is:

manpage.1: manpage.sgml
	docbook-to-man $< > $@

    
	The docbook-to-man binary is found in the docbook-to-man package.
	Please remember that if you create the nroff version in one of the
	debian/rules file targets (such as build), you will need to include
	docbook-to-man in your Build-Depends control field.

  -->

  <!-- Fill in your name for FIRSTNAME and SURNAME. -->
  <!ENTITY dhfirstname "<firstname>Eduard</firstname>">
  <!ENTITY dhsurname   "<surname>Bloch</surname>">
  <!-- Please adjust the date whenever revising the manpage. -->
  <!ENTITY dhdate      "<date>April  3, 2007</date>">
  <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
       allowed: see man(7), man(1). -->
  <!ENTITY dhsection   "<manvolnum>8</manvolnum>">
  <!ENTITY dhemail     "<email>blade at debian.org</email>">
  <!ENTITY dhusername  "Eduard Bloch">
  <!ENTITY dhucpackage "<refentrytitle>mdadm-startall</refentrytitle>">
  <!ENTITY dhpackage   "mdadm">

  <!ENTITY debian      "<productname>Debian</productname>">
  <!ENTITY gnu         "<acronym>GNU</acronym>">
  <!ENTITY gpl         "&gnu; <acronym>GPL</acronym>">
]>

<refentry>
  <refentryinfo>
    <address>
      &dhemail;
    </address>
    <author>
      &dhfirstname;
      &dhsurname;
    </author>
    <copyright>
      <year>2007</year>
      <holder>&dhusername;</holder>
    </copyright>
    &dhdate;
  </refentryinfo>
  <refmeta>
    &dhucpackage;

    &dhsection;
  </refmeta>
  <refnamediv>
    <refname>mdadm-startall</refname>

    <refpurpose>helper script to start all inactive arrays</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <cmdsynopsis>
      <command>&dhpackage;</command>

      <arg><option>-r</option></arg>
    </cmdsynopsis>
  </refsynopsisdiv>
  <refsect1>
    <title>DESCRIPTION</title>

    <para>The <command>mdadm-startall</command> script starts all raids that are inactive yet and examines their configuration when needed.
    </para>

  </refsect1>
  <refsect1>
    <title>OPTIONS</title>

    <variablelist>
      <varlistentry>
        <term><option>-r</option>
        </term>
        <listitem>
          <para>Force the examination of MD array configuration.</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  <refsect1>
    <title>SEE ALSO</title>

    <para>mdadm (8), mdadm.conf(5)</para>
  </refsect1>
  <refsect1>
    <title>AUTHOR</title>

    <para>This manual page was written by &dhusername; &dhemail; for
      the &debian; system (but may be used by others).  Permission is
      granted to copy, distribute and/or modify this document under
      the terms of the &gnu; General Public License, Version 2 any 
	  later version published by the Free Software Foundation.
    </para>
	<para>
	  On Debian systems, the complete text of the GNU General Public
	  License can be found in /usr/share/common-licenses/GPL.
	</para>

  </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->




More information about the pkg-mdadm-devel mailing list