use mdadm instead of bundled stripped down mdassemble (v2)
authorMatthias Dahl <ua_bugz_gentoo@mortal-soul.de>
Fri, 27 Aug 2010 15:26:52 +0000 (17:26 +0200)
committerSebastian Pipping <sebastian@pipping.org>
Mon, 17 Jan 2011 14:42:07 +0000 (15:42 +0100)
mdassemble can't handle newer metadata formats and fails for partitioned
arrays, among other things.

This...

- replaces the bundled mdassemble with proper support for mdadm
- fixes raid autodetection/assemble when no mdadm.conf is available
- fixes a compilation failure for newer mdadm versions

Tested w/ genkernel 3.4.10.907 and mdadm 3.1.3.

defaults/initrd.scripts
gen_compile.sh
gen_determineargs.sh
gen_initramfs.sh
genkernel.conf

index ce05f4c27babe01bc0c81edc1b7214132e7e7b81..1c7ebf32764dde5df709e12767b26e544bd92113 100755 (executable)
@@ -615,9 +615,10 @@ startVolumes() {
        then
                if [ ! -e '/etc/mdadm.conf' ]
                then
-                       /sbin/mdadm --examine > /etc/mdadm.conf
+                       echo "DEVICE /dev/sd[a-z]* /dev/hd[a-z]*" >/etc/mdadm.conf
+                       /sbin/mdadm --examine --scan >>/etc/mdadm.conf
                fi
-               /sbin/mdadm --assemble
+               /sbin/mdadm -A --scan
        fi
 
        if [ "${USE_DMRAID_NORMAL}" = '1' ]
index 7438f34d3c7c206bc86189091119c83d21346be1..1c3bf976e7ecf53363f2c5af5bafc89d36c43a03 100755 (executable)
@@ -457,6 +457,41 @@ compile_lvm() {
        fi
 }
 
+compile_mdadm() {
+       if [ ! -f "${MDADM_BINCACHE}" ]
+       then
+               [ -f "${MDADM_SRCTAR}" ] ||
+                       gen_die "Could not find MDADM source tarball: ${MDADM_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
+               cd "${TEMP}"
+               rm -rf "${MDADM_DIR}" > /dev/null
+               /bin/tar -jxpf "${MDADM_SRCTAR}" ||
+                       gen_die 'Could not extract MDADM source tarball!'
+               [ -d "${MDADM_DIR}" ] ||
+                       gen_die 'MDADM directory ${MDADM_DIR} is invalid!'
+               
+               cd "${MDADM_DIR}"
+               sed -i "/^CFLAGS = /s:^CFLAGS = \(.*\)$:CFLAGS = -Os:" Makefile
+               sed -i "/^CXFLAGS = /s:^CXFLAGS = \(.*\)$:CXFLAGS = -Os:" Makefile
+               sed -i "/^CWFLAGS = /s:^CWFLAGS = \(.*\)$:CWFLAGS = -Wall:" Makefile
+               sed -i "s/^# LDFLAGS = -static/LDFLAGS = -static/" Makefile
+
+               print_info 1 'mdadm: >> Compiling...'
+                       compile_generic 'mdadm' utils
+
+               mkdir -p "${TEMP}/mdadm/sbin"
+               install -m 0755 -s mdadm "${TEMP}/mdadm/sbin/mdadm"
+               print_info 1 '      >> Copying to bincache...'
+               cd "${TEMP}/mdadm"
+               strip "sbin/mdadm" ||
+                       gen_die 'Could not strip mdadm!'
+               /bin/tar -cjf "${MDADM_BINCACHE}" sbin/mdadm ||
+                       gen_die 'Could not create binary cache'
+
+               cd "${TEMP}"
+               rm -rf "${MDADM_DIR}" mdadm
+       fi
+}
+
 compile_dmraid() {
        compile_device_mapper
        if [ ! -f "${DMRAID_BINCACHE}" ]
index f830c48c307cd6a815c0c4ca9f1985129ddea14c..548f55b6616bbe2720fa46d09458ce6d3d18a0aa 100755 (executable)
@@ -135,6 +135,7 @@ determine_real_args() {
        BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"`
        DEVICE_MAPPER_BINCACHE=`cache_replace "${DEVICE_MAPPER_BINCACHE}"`
        LVM_BINCACHE=`cache_replace "${LVM_BINCACHE}"`
+       MDADM_BINCACHE=`cache_replace "${MDADM_BINCACHE}"`
        DMRAID_BINCACHE=`cache_replace "${DMRAID_BINCACHE}"`
        ISCSI_BINCACHE=`cache_replace "${ISCSI_BINCACHE}"`
        BLKID_BINCACHE=`cache_replace "${BLKID_BINCACHE}"`
@@ -147,6 +148,7 @@ determine_real_args() {
        BUSYBOX_BINCACHE=`arch_replace "${BUSYBOX_BINCACHE}"`
        DEVICE_MAPPER_BINCACHE=`arch_replace "${DEVICE_MAPPER_BINCACHE}"`
        LVM_BINCACHE=`arch_replace "${LVM_BINCACHE}"`
+       MDADM_BINCACHE=`arch_replace "${MDADM_BINCACHE}"`
        DMRAID_BINCACHE=`arch_replace "${DMRAID_BINCACHE}"`
        ISCSI_BINCACHE=`arch_replace "${ISCSI_BINCACHE}"`
        BLKID_BINCACHE=`arch_replace "${BLKID_BINCACHE}"`
index ac32516ea8c72cc44299a710e0e68ffa436920fe..e7d4a107abaee83ad857ad4b8d998f898bc39e9c 100755 (executable)
@@ -339,10 +339,22 @@ append_mdadm(){
        fi
        cd ${TEMP}
        mkdir -p "${TEMP}/initramfs-mdadm-temp/etc/"
+       mkdir -p "${TEMP}/initramfs-mdadm-temp/sbin/"
        if [ "${MDADM}" = '1' ]
        then
                cp -a /etc/mdadm.conf "${TEMP}/initramfs-mdadm-temp/etc" \
                        || gen_die "Could not copy mdadm.conf!"
+               if [ -e '/sbin/mdadm' ] && LC_ALL="C" ldd /sbin/mdadm|grep -q 'not a dynamic executable'
+               then
+                       print_info 1 '          MDADM: Adding support (using local static binaries)...'
+                       cp /sbin/mdadm "${TEMP}/initramfs-mdadm-temp/sbin/mdadm" ||
+                               gen_die 'Could not copy over mdadm!'
+               else
+                       print_info 1 '          MDADM: Adding support (compiling binaries)...'
+                       compile_mdadm
+                       /bin/tar -jxpf "${MDADM_BINCACHE}" -C "${TEMP}/initramfs-mdadm-temp" ||
+                               gen_die "Could not extract mdadm binary cache!";
+               fi
        fi
        cd "${TEMP}/initramfs-mdadm-temp/"
        find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
index 2bc8183819741b29e35d0b6ef258d6c6a891b4f2..e0c12743d03c19406278a524748ab290b3d816f7 100644 (file)
@@ -169,6 +169,11 @@ LVM_DIR="LVM2.${LVM_VER}"
 LVM_SRCTAR="${DISTDIR}/LVM2.${LVM_VER}.tgz"
 LVM_BINCACHE="%%CACHE%%/LVM2.${LVM_VER}-%%ARCH%%.tar.bz2"
 
+MDADM_VER="VERSION_MDADM"
+MDADM_DIR="mdadm-${MDADM_VER}"
+MDADM_SRCTAR="${DISTDIR}/mdadm-${MDADM_VER}.tar.bz2"
+MDADM_BINCACHE="%%CACHE%%/mdadm-${MDADM_VER}-%%ARCH%%.tar.bz2"
+
 DMRAID_VER="VERSION_DMRAID"
 DMRAID_DIR="dmraid/${DMRAID_VER}"
 DMRAID_SRCTAR="${DISTDIR}/dmraid-${DMRAID_VER}.tar.bz2"