--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
--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";;
[[ $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
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
.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
.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
# build initrd only to boot current hardware
#hostonly="-h"
+#
+
+# install local /etc/mdadm.conf
+mdadmconf="yes"
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"
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"
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"
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
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"
--- /dev/null
+#!/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
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=)
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
$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.
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;
echo "MD_UUID=$MD_UUID"
client_run || return 1
+
+ client_run rd_NO_MDADMCONF || return 1
client_run rd_NO_LVM && return 1
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
}
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
(
-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" \
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() {