diff options
author | Harald Hoyer <harald@redhat.com> | 2009-09-15 09:00:13 +0200 |
---|---|---|
committer | Harald Hoyer <harald@redhat.com> | 2009-09-15 15:00:18 +0200 |
commit | 2f02ae9d45b263eecf4348986a8e67057dbad126 (patch) | |
tree | 0a71665cd7a5e416b436694036742d8b40e561c4 | |
parent | 11fcc8c8f941edb438ad48ef7deb6cbf8d87d530 (diff) | |
download | dracut-2f02ae9d45b263eecf4348986a8e67057dbad126.tar.gz dracut-2f02ae9d45b263eecf4348986a8e67057dbad126.tar.bz2 dracut-2f02ae9d45b263eecf4348986a8e67057dbad126.zip |
mdraid: add rd_NO_MDADMCONF --mdadmconf --nomdadmconf
Copy /etc/mdadm.conf to initramfs (even for non-hostonly) if
mdadmconf="yes" is set in dracut.conf or --mdadmconf is specified on the
dracut command line.
This was done, because there seems _no_ sane way to autoassemble md raid
arrays.
also moved rd_NO_MD to an udev ENV
-rwxr-xr-x | dracut | 7 | ||||
-rw-r--r-- | dracut.8 | 9 | ||||
-rw-r--r-- | dracut.conf | 4 | ||||
-rw-r--r-- | modules.d/90mdraid/65-md-incremental-imsm.rules | 7 | ||||
-rwxr-xr-x | modules.d/90mdraid/install | 3 | ||||
-rwxr-xr-x | modules.d/90mdraid/mdadm_auto.sh | 7 | ||||
-rw-r--r-- | modules.d/90mdraid/parse-md.sh | 8 | ||||
-rwxr-xr-x | test/TEST-10-RAID/test.sh | 1 | ||||
-rwxr-xr-x | test/TEST-12-RAID-DEG/create-root.sh | 2 | ||||
-rwxr-xr-x | test/TEST-12-RAID-DEG/test.sh | 13 | ||||
-rwxr-xr-x | test/TEST-14-IMSM/test.sh | 9 |
11 files changed, 58 insertions, 12 deletions
@@ -45,6 +45,8 @@ Creates initial ramdisk images for preloading modules --no-kernel Do not install kernel drivers and firmware files --strip Strip binaries in the initramfs (default) --nostrip Do not strip binaries in the initramfs + --mdadmconf Include local /etc/mdadm.conf + --nomdadmconf Do not include local /etc/mdadm.conf -h, --help This message --debug Output debug information of the build process -v, --verbose Verbose output during the build process @@ -78,6 +80,8 @@ while (($# > 0)); do --no-kernel) kernel_only="no"; no_kernel="yes";; --strip) do_strip_l="yes";; --nostrip) do_strip_l="no";; + --mdadmconf) mdadmconf_l="yes";; + --nomdadmconf) mdadmconf_l="no";; -h|--help) usage; exit 1 ;; --debug) debug="yes";; -v|--verbose) beverbose="yes";; @@ -115,6 +119,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH [[ $fw_dir_l ]] && fw_dir=$fw_dir_l [[ $do_strip_l ]] && do_strip=$do_strip_l [[ $hostonly_l ]] && hostonly=$hostonly_l +[[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l [[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut [[ $fw_dir ]] || fw_dir=/lib/firmware [[ $do_strip ]] || do_strip=yes @@ -163,7 +168,7 @@ chmod 755 "$initdir" export initdir hookdirs dsrc dracutmodules drivers \ fw_dir drivers_dir debug beverbose no_kernel kernel_only \ - add_drivers + add_drivers mdadmconf if [[ $kernel_only != yes ]]; then # Create some directory structure first @@ -44,6 +44,12 @@ only install kernel drivers and firmware files .BR \-\-no-kernel do not install kernel drivers and firmware files .TP +.BR \-\-mdadmconf +include local /etc/mdadm.conf +.TP +.BR \-\-nomdadmconf +do not include local /etc/mdadm.conf +.TP .BR \-\-strip strip binaries in the initramfs (default) .TP @@ -146,6 +152,9 @@ disable MD RAID detection .B rd_NO_MDIMSM no MD RAID for imsm/isw raids, use dmraid instead .TP +.B rd_NO_MDADMCONF +ignore mdadm.conf included in initramfs +.TP .B rd_MD_UUID=<md uuid> only activate the raid sets with the given UUID diff --git a/dracut.conf b/dracut.conf index 73d064fe..ded37767 100644 --- a/dracut.conf +++ b/dracut.conf @@ -11,3 +11,7 @@ # build initrd only to boot current hardware #hostonly="-h" +# + +# install local /etc/mdadm.conf +mdadmconf="yes" diff --git a/modules.d/90mdraid/65-md-incremental-imsm.rules b/modules.d/90mdraid/65-md-incremental-imsm.rules index 883f80c8..ca0ac70d 100644 --- a/modules.d/90mdraid/65-md-incremental-imsm.rules +++ b/modules.d/90mdraid/65-md-incremental-imsm.rules @@ -11,11 +11,14 @@ ENV{DEVTYPE}!="partition", \ ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}=="?*", GOTO="md_inc_end" +ENV{rd_NO_MD}=="?*", GOTO="md_inc_end" + TEST=="/tmp/.mdraid_start-%k", GOTO="md_inc_end" TEST=="/tmp/.mdraid_container-%k", GOTO="md_inc_end" KERNEL!="md*", IMPORT{program}="/sbin/mdadm --examine --export $tempnode" + # UUID CHECK LABEL="do_md_inc" @@ -41,6 +44,8 @@ ACTION=="add|change", \ KERNEL=="md[0-9]*|md/*", \ ENV{MD_LEVEL}!="container", \ ENV{MD_CONTAINER}!="?*", \ + ENV{rd_MDADMCONF}!="?*", \ + ENV{rd_NO_MD}!="?*", \ GOTO="do_raidstart" GOTO="end_raidstart" @@ -63,6 +68,8 @@ ACTION=="add|change", \ KERNEL=="md[0-9]*|md/*", \ ENV{DEVTYPE}!="partition", \ ENV{MD_LEVEL}=="container", \ + ENV{rd_MDADMCONF}!="?*", \ + ENV{rd_NO_MD}!="?*", \ GOTO="do_container" GOTO="end_container" diff --git a/modules.d/90mdraid/install b/modules.d/90mdraid/install index c2de3bba..84ab240e 100755 --- a/modules.d/90mdraid/install +++ b/modules.d/90mdraid/install @@ -21,7 +21,7 @@ if ! mdadm -Q -e imsm /dev/null &> /dev/null; then inst_hook pre-trigger 30 "$moddir/md-noimsm.sh" fi -if [[ $hostonly ]]; then +if [[ $hostonly ]] || [[ $mdadmconf = "yes" ]]; then [ -f /etc/mdadm/mdadm.conf ] && inst /etc/mdadm/mdadm.conf /etc/mdadm.conf [ -f /etc/mdadm.conf ] && inst /etc/mdadm.conf fi @@ -33,6 +33,7 @@ fi inst "$moddir/mdraid_start.sh" /sbin/mdraid_start inst "$moddir/mdcontainer_start.sh" /sbin/mdcontainer_start +inst "$moddir/mdadm_auto.sh" /sbin/mdadm_auto inst_hook pre-trigger 30 "$moddir/parse-md.sh" inst_hook pre-pivot 30 "$moddir/mdraid-cleanup.sh" inst_hook pre-pivot 31 "$moddir/mdraid-cleanup.sh" diff --git a/modules.d/90mdraid/mdadm_auto.sh b/modules.d/90mdraid/mdadm_auto.sh new file mode 100755 index 00000000..9e96b003 --- /dev/null +++ b/modules.d/90mdraid/mdadm_auto.sh @@ -0,0 +1,7 @@ +#!/bin/sh +. /lib/dracut-lib.sh + +info "Autoassembling MD Raid" +udevadm control --stop-exec-queue +/sbin/mdadm -As --auto=yes --run 2>&1 | vinfo +udevadm control --start-exec-queue diff --git a/modules.d/90mdraid/parse-md.sh b/modules.d/90mdraid/parse-md.sh index 1032963b..a2cf599e 100644 --- a/modules.d/90mdraid/parse-md.sh +++ b/modules.d/90mdraid/parse-md.sh @@ -1,6 +1,6 @@ if getarg rd_NO_MD; then info "rd_NO_MD: removing MD RAID activation" - rm /etc/udev/rules.d/65-md-incremental*.rules + udevadm control --property=rd_NO_MD=1 else MD_UUID=$(getargs rd_MD_UUID=) @@ -24,6 +24,12 @@ else fi fi + +if [ -e /etc/mdadm.conf ] && ! getarg rd_NO_MDADMCONF; then + udevadm control --property=rd_MDADMCONF=1 + rm -f /pre-pivot/*mdraid-cleanup.sh +fi + if getarg rd_NO_MDIMSM; then info "rd_NO_MDIMSM: no MD RAID for imsm/isw raids" udevadm control --property=rd_NO_MDIMSM=1 diff --git a/test/TEST-10-RAID/test.sh b/test/TEST-10-RAID/test.sh index 1b9e931d..7d793d3c 100755 --- a/test/TEST-10-RAID/test.sh +++ b/test/TEST-10-RAID/test.sh @@ -47,6 +47,7 @@ test_setup() { $basedir/dracut -l -i overlay / \ -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \ -d "ata_piix ext2 sd_mod" \ + --nomdadmconf \ -f initramfs.makeroot $KVERSION || return 1 rm -rf overlay # Invoke KVM and/or QEMU to actually create the target filesystem. diff --git a/test/TEST-12-RAID-DEG/create-root.sh b/test/TEST-12-RAID-DEG/create-root.sh index bf944187..b21a0602 100755 --- a/test/TEST-12-RAID-DEG/create-root.sh +++ b/test/TEST-12-RAID-DEG/create-root.sh @@ -30,7 +30,9 @@ cp -a -t /sysroot /source/* && \ umount /sysroot && \ lvm lvchange -a n /dev/dracut/root && \ cryptsetup luksClose /dev/mapper/dracut_crypt_test && \ +{ mdadm -W /dev/md0 || : ;} && \ mdadm /dev/md0 --fail /dev/sda2 --remove /dev/sda2 && \ +{ mdadm -W /dev/md0 || : ;} && \ { /sbin/mdadm --detail --export /dev/md0 > /tmp/mduuid ; . /tmp/mduuid; diff --git a/test/TEST-12-RAID-DEG/test.sh b/test/TEST-12-RAID-DEG/test.sh index 94ef50b5..25c96341 100755 --- a/test/TEST-12-RAID-DEG/test.sh +++ b/test/TEST-12-RAID-DEG/test.sh @@ -27,6 +27,8 @@ test_run() { echo "MD_UUID=$MD_UUID" client_run || return 1 + + client_run rd_NO_MDADMCONF || return 1 client_run rd_NO_LVM && return 1 @@ -36,13 +38,13 @@ test_run() { client_run rd_LVM_VG=dummy1 rd_LVM_VG=dracut rd_LVM_VG=dummy2 || return 1 - client_run rd_MD_UUID=failme && return 1 + client_run rd_MD_UUID=failme rd_NO_MDADMCONF && return 1 client_run rd_NO_MD && return 1 - client_run rd_MD_UUID=$MD_UUID || return 1 + client_run rd_MD_UUID=$MD_UUID rd_NO_MDADMCONF || return 1 - client_run rd_MD_UUID=dummy1 rd_MD_UUID=$MD_UUID rd_MD_UUID=dummy2 || return 1 + client_run rd_MD_UUID=dummy1 rd_MD_UUID=$MD_UUID rd_MD_UUID=dummy2 rd_NO_MDADMCONF|| return 1 return 0 } @@ -50,7 +52,7 @@ test_run() { test_setup() { # Create the blank file to use as a root filesystem dd if=/dev/zero of=root.ext2 bs=1M count=20 - + kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay ( @@ -88,12 +90,15 @@ test_setup() { -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81" \ -initrd initramfs.makeroot || return 1 grep -m 1 -q dracut-root-block-created root.ext2 || return 1 + eval $(grep --binary-files=text -m 1 MD_UUID root.ext2) ( initdir=overlay . $basedir/dracut-functions dracut_install poweroff shutdown inst_simple ./hard-off.sh /emergency/01hard-off.sh inst ./cryptroot-ask /sbin/cryptroot-ask + mkdir -p overlay/etc + echo "ARRAY /dev/md0 level=raid5 num-devices=3 UUID=$MD_UUID" > overlay/etc/mdadm.conf ) sudo $basedir/dracut -l -i overlay / \ -o "plymouth" \ diff --git a/test/TEST-14-IMSM/test.sh b/test/TEST-14-IMSM/test.sh index 73aaca34..00593c91 100755 --- a/test/TEST-14-IMSM/test.sh +++ b/test/TEST-14-IMSM/test.sh @@ -26,11 +26,10 @@ test_run() { client_run || return 1 client_run rd_NO_MDIMSM || return 1 client_run rd_NO_DM || return 1 - client_run rd_NO_MD rd_NO_MDIMSM && return 1 -# FIXME: -# client_run rd_NO_DM rd_NO_MDIMSM && return 1 -# client_run rd_NO_MD && return 1 - return 0 + client_run rd_NO_DM rd_NO_MDIMSM rd_NO_MDADMCONF || return 1 + client_run rd_NO_MD rd_NO_MDIMSM && return 1 + client_run rd_NO_MD && return 1 + return 0 } test_setup() { |