Bug#685161: mdadm initramfs script panics with modern mdadm being unable to load any modules

Michael Tokarev mjt at tls.msk.ru
Fri Aug 17 14:52:25 UTC 2012


Package: mdadm
Version: 3.2.5-1
Severity: grave
Tags: patch wheezy
Justification: makes system unbootable

The mdadm initramfs hook in /share/initramfs-tools/hooks/mdadm
tries to create a list of array:level pairs for arrays found
on the system in question.  From this list, it extracts a list
of levels in use.  It uses this list to record a list of modules
to load for the initramfs script.

Modern mdadm does not include raid levels in the generated mdadm.conf
anymore.  So the list of raid levels to use will be empty.

However, the initramfs mdadm script contains the following code:

  MD_DEVS=all
  MD_MODULES='linear multipath raid0 raid1 raid456 raid5 raid6 raid10'
  [ -s /conf/conf.d/md ] && . /conf/conf.d/md

  verbose && log_begin_msg Loading MD modules
  for module in ${MD_MODULES:-}; do
    if modprobe -q "$module"; then
      verbose && log_success_msg "loaded module ${module}."
    else
      log_failure_msg "failed to load module ${module}."
    fi
  done
  log_end_msg

  if [ ! -f /proc/mdstat ]; then
    verbose && panic "cannot initialise MD subsystem (/proc/mdstat missing)"
    exit 1
  fi

When the hook runs and "discovers" empty list of levels,
it adds

  MD_MODULES=''

to /conf/conf.d/md.  So the above fragment will not load any raid
modules.

But the last piece of code above checks whenever /proc/mdstat exists
and panics if it doesn't.  But since we didn't load any module,
md_mod hasn't been loaded either, so /proc/mdstat will not exist.

So the code will panic, and initramfs will display its emergency
prompt waiting for actions.  And no raid arrays will ever be assembled,
because the code assembling arrays is below this panic/exit place.

This happens with user-created arrays mostly, d-i somehow manages
to create mdadm.conf which contains the necessary level= options
for each array, but the issue is still severe enough.

The solution appears to be to just remove this module loading and
/proc/mdstat check, since mdadm is perfectly capable of on-demand
loading of all support modules - by accessing a temp node and
relying on module autoloading using block-major-9* alias for the
main md_mod module, and raid level modules are autoloaded by
md_mod.

So this whole check and module loading needs to be removed now.
But we should remember we have to set md_mod parameter (start_ro=1)
which is set in /sys/module/md_mod before invoking mdadm for the
first time.

Thanks,

/mjt



More information about the pkg-mdadm-devel mailing list