After upgrading to mdadm-3.3.1 my RAID array(s) wouldn't assemble automatically on boot any more (using systemd). Traced down the issue potentially to the udev rule file being busted. See: # cat /lib/udev/rules.d/64-md-raid-assembly.rules # This file is part of mdadm. # # mdadm is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. [Unit] Description=MD Metadata Monitor on /dev/%I DefaultDependencies=no Before=initrd-switch-root.target [Service] # mdmon should never complain due to lack of a platform, # that is mdadm's job if at all. Environment=IMSM_NO_PLATFORM=1 # The mdmon starting in the initramfs (with dracut at least) # cannot see sysfs after root is mounted, so we will have to # 'takeover'. As the '--offroot --takeover' don't hurt when # not necessary, are are useful with root-on-md in dracut, # have them always present. ExecStart=/sbin/mdmon --offroot --takeover %I Type=forking # Don't set the PIDFile. It isn't necessary (systemd can work # it out) and systemd will remove it when transitioning from # initramfs to rootfs. #PIDFile=/run/mdadm/%I.pid KillMode=none offroot ${DEVLINKS}" ACTION=="add|change", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer" ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}" ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name" LABEL="md_inc_end" This looks more like a systemd service file rather than an udev rule file. Downgrading to 3.3-r4 fixes the array auto assembly at boot. The udev rule file also looks saner now: # cat /lib/udev/rules.d/64-md-raid-assembly.rules # do not edit this file, it will be overwritten on update # assemble md arrays SUBSYSTEM!="block", GOTO="md_inc_end" # handle potential components of arrays (the ones supported by md) ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_inc" GOTO="md_inc_end" LABEL="md_inc" # remember you can limit what gets auto/incrementally assembled by # mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY' ACTION=="add", RUN+="/sbin/mdadm --incremental $devnode --offroot" ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}" ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name" LABEL="md_inc_end"
Looks fine here, ssuominen@null ~/gentoo-x86/sys-fs/mdadm $ qfile -v /lib/udev/rules.d/64-md-raid-assembly.rules sys-fs/mdadm-3.3.1 (/lib/udev/rules.d/64-md-raid-assembly.rules) ssuominen@null ~/gentoo-x86/sys-fs/mdadm $ cat /lib/udev/rules.d/64-md-raid-assembly.rules # do not edit this file, it will be overwritten on update # Don't process any events if anaconda is running as anaconda brings up # raid devices manually ENV{ANACONDA}=="?*", GOTO="md_inc_end" # assemble md arrays SUBSYSTEM!="block", GOTO="md_inc_end" # handle potential components of arrays (the ones supported by md) ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="md_inc" # "noiswmd" on kernel command line stops mdadm from handling # "isw" (aka IMSM - Intel RAID). # "nodmraid" on kernel command line stops mdadm from handling # "isw" or "ddf". IMPORT{cmdline}="noiswmd" IMPORT{cmdline}="nodmraid" ENV{nodmraid}=="?*", GOTO="md_inc_end" ENV{ID_FS_TYPE}=="ddf_raid_member", GOTO="md_inc" ENV{noiswmd}=="?*", GOTO="md_inc_end" ENV{ID_FS_TYPE}=="isw_raid_member", GOTO="md_inc" GOTO="md_inc_end" LABEL="md_inc" # remember you can limit what gets auto/incrementally assembled by # mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY' ACTION=="add|change", IMPORT{program}="/sbin/mdadm --incremental --export $devnode --offroot ${DEVLINKS}" ACTION=="add|change", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer" ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}" ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name" LABEL="md_inc_end"
Do you have sys-apps/systemd installed? Just wondering howto reproduce.
Yes, I do use systemd: [ebuild R ] sys-apps/systemd-215-r1:0/2 USE="acl filecaps firmware-loader gudev introspection kmod pam policykit python seccomp ssl -audit -cryptsetup -doc -elfutils -gcrypt -http (-kdbus) -lzma -qrcode (-selinux) {-test} -vanilla" ABI_X86="(64) -32 (-x32)" PYTHON_SINGLE_TARGET="python2_7 -python3_2 -python3_3" PYTHON_TARGETS="python2_7 python3_3 -python3_2" 0 kB [ebuild R ] sys-fs/mdadm-3.3.1 [3.3-r4] USE="-static" 0 kB
I just built it for fun and lib/udev/rules.d/63-md-raid-arrays.rules definitely is what it should be.
Created attachment 380840 [details] mdadm-3.3.1 build log
The issue is with /lib/udev/rules.d/64-md-raid-assembly.rules not /lib/udev/rules.d/63-md-raid-arrays.rules. Could you check to see if that one looks OK too? I just tried to emerge mdadm-3.3.1 again and still see the same issue - attaching full build log.
Yes, both .rules look OK (but I don't have sys-apps/systemd installed) Have you tried compiling with MAKEOPTS="-j1"? CCing systemd@ if they can reproduce
In Makefile, I see "file" and "$$file" and .install.tmp used in for -loops over and over again, but I just fail to see how it can have this outcome :/
Can you try editing the ebuild and see if... Changing this line... mdadm_emake DESTDIR="${D}" install install-systemd to split lines... mdadm_emake DESTDIR="${D}" install mdadm_emake DESTDIR="${D}" install-systemd solves the problem?
Great suggestions. Both MAKEOPTS="-j1" AND splitting the mdadm_emake line into two lines fixes the issue. I'm typically running with MAKEOPTS="-j9" in /etc/portage/make.conf, I guess I should add sys-fs/mdadm to package.env for MAKEOPTS="-j1". Thanks for your help!
I guess as a general solution though it might be nice to split the mdadm_emake line on portage since it works fine with MAKEOPTS="-jN" and I'd imagine a decent number of folks would hit this bug.
Created attachment 380866 [details, diff] mdadm-3.3.1.ebuid.patch ebuild patch to apply -parallel-make.patch
Created attachment 380868 [details, diff] mdadm-3.3.1-parallel-make.patch patch for the previous ebuild, goes to files/ directory
I'll split the lines for mdadm-3.3.1-r1.ebuild, but before you emerge/sync, could you do a quick test and see if the attach patches fix the problem as well? so that I can then send them to upstream mailing list, so this will be fixed for everyone, not just for gentoo
+*mdadm-3.3.1-r1 (17 Jul 2014) + + 17 Jul 2014; Samuli Suominen <ssuominen@gentoo.org> +mdadm-3.3.1-r1.ebuild: + Fix corruption of udev rules and/or systemd service files because of parallel + make wrt #517218 by splitting installation of targets "install" and "install- + systemd" to separate lines. Thanks to Mark R. Pariente for reporting. (but please still test the attached patches...)
Reported to upstream here, http://marc.info/?l=linux-raid&m=140558222313576&w=2
Created attachment 380878 [details, diff] mdadm-3.3.1-parallel-make.patch Upstream said this should be enough to fix the problem (change only filename, not the variable) But since I can't reproduce the bug, not even with -j9 on my machine (parallel make is like that, it's tricky...), I can't verify it
Samuli, thanks for the patches. I can confirm that mdadm-3.3.1-parallel-make.patch (attachment 380878 [details, diff]) fixes the problem, udev rule file is as expected with MAKEOPTS="-j9".