Mdadm auto-assemble

Bonjour à tous,

Sur une installation toute fraîche de raspbian, je viens d’installer mdadm. Mes arrays ont bien été détectés lors de la configuration et voici les fichiers /etc/mdadm/mdadm.conf /etc/default/mdadm résultant.

# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers

# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# definitions of existing MD arrays
ARRAY /dev/md/6 metadata=1.2 UUID=0771082a:ce97b231:67689da5:6b8ef4b4 name=server:6
ARRAY /dev/md/5 metadata=1.2 UUID=574a7889:3a742cf8:c1097a83:7a719a64 name=server:5

# This file was auto-generated on Sat, 14 Mar 2015 14:48:11 +0100
# by mkconf 3.2.5-5
# mdadm Debian configuration
#
# You can run 'dpkg-reconfigure mdadm' to modify the values in this file, if
# you want. You can also change the values here and changes will be preserved.
# Do note that only the values are preserved; the rest of the file is
# rewritten.
#

# INITRDSTART:
#   list of arrays (or 'all') to start automatically when the initial ramdisk
#   loads. This list *must* include the array holding your root filesystem. Use
#   'none' to prevent any array from being started from the initial ramdisk.
INITRDSTART='all'

# AUTOSTART:
#   should mdadm start arrays listed in /etc/mdadm/mdadm.conf automatically
#   during boot?
AUTOSTART=true

# AUTOCHECK:
#   should mdadm run periodic redundancy checks over your arrays? See
#   /etc/cron.d/mdadm.
AUTOCHECK=true

# START_DAEMON:
#   should mdadm start the MD monitoring daemon during boot?
START_DAEMON=true

# DAEMON_OPTIONS:
#   additional options to pass to the daemon.
DAEMON_OPTIONS="--syslog"

# VERBOSE:
#   if this variable is set to true, mdadm will be a little more verbose e.g.
#   when creating the initramfs.
VERBOSE=false

# MAIL_TO:
#   this variable is now managed in /etc/mdadm/mdadm.conf (MAILADDR).
#   Please see mdadm.conf(5).

Suite à cette installation, un simple “mount /dev/md6 /mnt/raid1; mount /dev/md5 /mnt/raid0;” m’a permis d’accéder au contenu des deux volumes. Par sécurité, je fais un petit “update-initramfs -k all -u” puis reboot…

Suite à ce reboot, les disques n’apparaissaient plus dans /dev/md/ ! Impossible donc de faire un auto-montage avec fstab ! Pourtant, la commande “mdadm --examine --scan” fournit toujours le bon résultat. Avez-vous une idée pour résoudre ce problème ? Mes moultes recherches n’ont menées à rien :frowning:

Remarque :

  • disque externe USB avec alimentation externe pour le pi,
  • se pourrait-il que les disques USB ne soient pas bien prêts lorsque le script mdadm-raid se lance ? Les disques USB sont-il “ajoutés” dans /dev au même moment que les disques durs internes ?
  • est-ce que le “server:” après name peut avoir un impact ?
  • la commande “mdadm --assemble --scan” permet bien de faire réapparaître /dev/md5 et /dev/md6 :wink:

Merci d’avance !

Le problème venait effectivement du fait que les disques USB n’étaient pas prêts lorsque le script /etc/init.d/mdadm-raid (responsable d’assembler les volumes RAID) s’exécutait…

Une solution “winning-ugly” consiste à :

  1. Ajouter une dépendance “mdadm-raid” de type “Required-Start” dans “checkroot.sh”.
  2. Modifier la dépendance à “udev” dans “mdadm-raid” du type “Should-Start” à “Required-Start”.
  3. Ajouter un moche “sleep 15” avant la ligne “for line in $($MDADM --assemble --scan --auto=yes --symlink=no 2>&1); do” du script “mdadm-raid” !

Remarques : Le point 2 est optionnel. Le point 3 me fait penser que renseigner les ARRAY dans le fichier mdadm.conf est en fait complètement inutile…

En espérant en aider d’autres…
Tulkas