Browse Source

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
master
Harald Hoyer 15 years ago
parent
commit
2f02ae9d45
  1. 7
      dracut
  2. 9
      dracut.8
  3. 4
      dracut.conf
  4. 7
      modules.d/90mdraid/65-md-incremental-imsm.rules
  5. 3
      modules.d/90mdraid/install
  6. 7
      modules.d/90mdraid/mdadm_auto.sh
  7. 8
      modules.d/90mdraid/parse-md.sh
  8. 1
      test/TEST-10-RAID/test.sh
  9. 2
      test/TEST-12-RAID-DEG/create-root.sh
  10. 13
      test/TEST-12-RAID-DEG/test.sh
  11. 9
      test/TEST-14-IMSM/test.sh

7
dracut

@ -45,6 +45,8 @@ Creates initial ramdisk images for preloading modules @@ -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 @@ -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 @@ -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" @@ -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

9
dracut.8

@ -44,6 +44,12 @@ only install kernel drivers and firmware files @@ -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 @@ -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


4
dracut.conf

@ -11,3 +11,7 @@ @@ -11,3 +11,7 @@

# build initrd only to boot current hardware
#hostonly="-h"
#

# install local /etc/mdadm.conf
mdadmconf="yes"

7
modules.d/90mdraid/65-md-incremental-imsm.rules

@ -11,11 +11,14 @@ ENV{DEVTYPE}!="partition", \ @@ -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", \ @@ -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", \ @@ -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"

3
modules.d/90mdraid/install

@ -21,7 +21,7 @@ if ! mdadm -Q -e imsm /dev/null &> /dev/null; then @@ -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 @@ -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"

7
modules.d/90mdraid/mdadm_auto.sh

@ -0,0 +1,7 @@ @@ -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

8
modules.d/90mdraid/parse-md.sh

@ -1,6 +1,6 @@ @@ -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 @@ -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

1
test/TEST-10-RAID/test.sh

@ -47,6 +47,7 @@ test_setup() { @@ -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.

2
test/TEST-12-RAID-DEG/create-root.sh

@ -30,7 +30,9 @@ cp -a -t /sysroot /source/* && \ @@ -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;

13
test/TEST-12-RAID-DEG/test.sh

@ -27,6 +27,8 @@ test_run() { @@ -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() { @@ -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() { @@ -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() { @@ -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" \

9
test/TEST-14-IMSM/test.sh

@ -26,11 +26,10 @@ test_run() { @@ -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() {

Loading…
Cancel
Save