diff --git a/64-md-raid.rules b/64-md-raid.rules new file mode 100644 index 0000000..a2fe2d0 --- /dev/null +++ b/64-md-raid.rules @@ -0,0 +1,35 @@ +# do not edit this file, it will be overwritten on update + +SUBSYSTEM!="block", GOTO="md_end" +ACTION!="add|change", GOTO="md_end" + +# import data from a raid member and activate it +ENV{ID_FS_TYPE}=="linux_raid_member", PROGRAM="/bin/grep -qs '^AUTO -all' /etc/mdadm.conf", IMPORT{program}="/sbin/mdadm --examine --export $tempnode", RUN+="/sbin/mdadm --incremental $env{DEVNAME}" +# import data from a raid set +KERNEL!="md*", GOTO="md_end" + +# container devices have a metadata version of e.g. 'external:ddf' and +# never leave state 'inactive' +ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state" +ATTR{md/array_state}=="|clear|inactive", GOTO="md_end" +LABEL="md_ignore_state" + +IMPORT{program}="/sbin/mdadm --detail --export $tempnode" +ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace" +ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}" +ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}" + +ENV{DEVTYPE}!="partition", GOTO="md_vol_id" +IMPORT{program}="/sbin/mdadm --detail --export %r/$parent" +ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace" +ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n" +ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n" +ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n" + +LABEL="md_vol_id" +IMPORT{program}="/sbin/blkid -o udev -p $tempnode" +OPTIONS+="link_priority=100" +ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" +ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" + +LABEL="md_end" diff --git a/mdadm.changes b/mdadm.changes index 322d019..8922746 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,4 +1,38 @@ ------------------------------------------------------------------- +Wed Mar 24 17:37:27 CET 2010 - mmarek@suse.cz + +- 64-md-raid.rules: Use absolute path to grep, otherwise udev will + only search in /lib/udev (bnc#590832). + +------------------------------------------------------------------- +Tue Mar 23 14:49:38 CET 2010 - mmarek@suse.cz + +- mkinitrd-*.sh: Assemble md arrays even if the root= or resume= + option doesn't directly refer to md (bnc#589676, bnc#586837, + bnc#583424). + +------------------------------------------------------------------- +Thu Mar 11 10:18:18 CET 2010 - mmarek@suse.cz + +- 64-md-raid.rules: Use blkid instead of vol_id. + +------------------------------------------------------------------- +Thu Mar 11 09:58:21 CET 2010 - mmarek@suse.cz + +- 64-md-raid.rules: Allow --incremental assembly if "AUTO -all" is + given in mdadm.conf (fate#307478). + +------------------------------------------------------------------- +Tue Mar 9 16:15:41 CET 2010 - mmarek@suse.cz + +- Install udev rules in /lib/udev/rules.d (fate#307478). + +------------------------------------------------------------------- +Mon Feb 22 15:14:03 CET 2010 - mmarek@suse.cz + +- mkinitrd-setup.sh: call mdadm --scan only if necessary + (bnc#581769). + Fri Jan 15 17:37:26 CET 2010 - mmarek@suse.cz - fix modprobe invocation in boot.md (bnc#565293). diff --git a/mdadm.spec b/mdadm.spec index 2b84225..c1d8186 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -20,7 +20,7 @@ Name: mdadm Version: 3.0.3 -Release: 4 +Release: 5 BuildRequires: sgmltool PreReq: %fillup_prereq %insserv_prereq Obsoletes: raidtools @@ -37,6 +37,7 @@ Source3: mdadmd Source4: boot.md Source5: mkinitrd-setup.sh Source6: mkinitrd-boot.sh +Source7: 64-md-raid.rules %description Mdadm is a program that can be used to control Linux md devices. It is @@ -73,8 +74,8 @@ ln -sf ../../etc/init.d/mdadmd $RPM_BUILD_ROOT/%{_sbindir}/rcmdadmd rm -rf $RPM_BUILD_ROOT/var/run/mdadm mkdir -p $RPM_BUILD_ROOT/var/run ln -s mdadm $RPM_BUILD_ROOT/var/run/mdadm -# remove here, using the one in the udev package -rm -f $RPM_BUILD_ROOT/lib/udev/rules.d/64-md-raid.rules +install -d $RPM_BUILD_ROOT/lib/udev/rules.d +install -m 644 %_sourcedir/64-md-raid.rules $RPM_BUILD_ROOT/lib/udev/rules.d %post [ -x /sbin/mkinitrd_setup ] && mkinitrd_setup @@ -117,5 +118,8 @@ rm -rf $RPM_BUILD_ROOT %dir /lib/mkinitrd/scripts /lib/mkinitrd/scripts/setup-md.sh /lib/mkinitrd/scripts/boot-md.sh +%dir /lib/udev +%dir /lib/udev/rules.d +/lib/udev/rules.d/64-md-raid.rules %changelog diff --git a/mkinitrd-boot.sh b/mkinitrd-boot.sh index a5c7019..5bfe0c5 100644 --- a/mkinitrd-boot.sh +++ b/mkinitrd-boot.sh @@ -42,6 +42,9 @@ md_assemble() { local dev=$1 mdconf container + if test -e "$dev"; then + return + fi case "$dev" in /dev/md[0-9]*p[0-9]*) dev=${dev%p[0-9]*} @@ -84,5 +87,8 @@ if [ -n "$need_mdadm" ]; then if [ -n "$md_dev" ] ; then md_assemble "$md_dev" fi + for dev in $md_devs; do + md_assemble "$dev" + done wait_for_events fi diff --git a/mkinitrd-setup.sh b/mkinitrd-setup.sh index 750508c..e46c257 100644 --- a/mkinitrd-setup.sh +++ b/mkinitrd-setup.sh @@ -6,7 +6,7 @@ mdblockdev= # Full mdadm.conf generated by mdadm. # Contains all created MD RAIDs -mdadm_conf=$(mdadm --examine --brief --scan) +mdadm_conf= cont_list= md_devs= @@ -64,7 +64,10 @@ for bd in $blockdev ; do mdconf="$(mdadm -Db "$container")\\n$mdconf" ;; [0-9a-f]*[0-9a-f]) - mdconf="$(mdadm -Ebs | grep "UUID=$container")\\n$mdconf" + if test -z "$mdadm_conf"; then + mdadm_conf=$(mdadm --examine --brief --scan) + fi + mdconf="$(echo "$mdadm_conf" | grep "UUID=$container")\\n$mdconf" ;; *) echo "unrecognized container for $md_dev: $container" @@ -84,6 +87,10 @@ if [ -n "$root_md" ] ; then eval echo -e \"\$md_conf_$md\" >> $tmp_mnt/etc/mdadm.conf done fi +# Remember which arrays are needed for the root or swap device and assemble +# them all during boot. The root= or resume= option might not directly refer to +# the array. +md_devs=$(printf '/dev/%s ' $md_devs) save_var need_mdadm -save_var root_md +save_var md_devs