[arch-commits] Commit in mdadm/trunk (mdadm.install mdadm_hook mdadm_install)

Tobias Powalowski tpowa at archlinux.org
Sun Mar 8 18:17:21 UTC 2009


    Date: Sunday, March 8, 2009 @ 14:17:20
  Author: tpowa
Revision: 29450

upgpkg: mdadm 2.6.8-2

Added:
  mdadm/trunk/mdadm.install
  mdadm/trunk/mdadm_hook
  mdadm/trunk/mdadm_install

---------------+
 mdadm.install |   14 ++++++++++++++
 mdadm_hook    |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 mdadm_install |   44 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 108 insertions(+)

Added: mdadm.install
===================================================================
--- mdadm.install	                        (rev 0)
+++ mdadm.install	2009-03-08 18:17:20 UTC (rev 29450)
@@ -0,0 +1,14 @@
+# arg 1:  the new package version
+# arg 2:  the old package version
+
+post_upgrade() {
+  if [ "$(vercmp $2 2.6.8-2)" -lt 0 -a "$(grep raid_partitions /etc/mkinitcpio.conf)" ]; then
+    echo "Attention mdadm update:"
+    echo "raid_partitions hook has been replaced by the more powerfull mdadm hook."
+    echo "Please update your /etc/mkinitcpio.conf accordingly."
+  fi
+}
+
+op=$1
+shift
+$op $*

Added: mdadm_hook
===================================================================
--- mdadm_hook	                        (rev 0)
+++ mdadm_hook	2009-03-08 18:17:20 UTC (rev 29450)
@@ -0,0 +1,50 @@
+# vim: set ft=sh:
+run_hook ()
+{
+    input="$(cat /proc/cmdline)"
+    mdconfig="/etc/mdadm.conf"
+    # if no config file is present create one from command line parameters
+    if ! [ -e $mdconfig ]; then
+        #Create initial mdadm.conf
+        # scan all devices in /proc/partitions
+        echo DEVICE partitions > $mdconfig
+        for i in $input; do 
+        case $i in
+                # raid 
+                md=[0-9]*,/*)
+                    device="$(/bin/replace -s,/ "$i" "=" "")"
+                    array="$(/bin/replace -s/ "$device" "," " devices=")"
+                    echo "ARRAY /dev/$array" >> $mdconfig
+                    RAID_FOUND=1
+                    ;;
+                # partitionable raid
+                md=d[0-9]*,/*)
+                    device="$(/bin/replace -s=d "$i" "md=" "md_")"
+                    array="$(/bin/replace -s/ "$device" "," " devices=")"
+                    echo "ARRAY /dev/$array" >> $mdconfig
+                    RAID_FOUND=1
+                    ;;
+                # raid UUID 
+                md=[0-9]*,[0-9,a-z]*)
+                    device="$(/bin/replace -s,/ "$i" "=" "")"
+                    array="$(/bin/replace -s/ "$device" "," " uuid=")"
+                    echo "ARRAY /dev/$array" >> $mdconfig
+                    RAID_FOUND=1
+                    ;;
+                # partitionable raid UUID
+                md=d[0-9]*,[0-9,a-z]*)
+                    device="$(/bin/replace -s=d "$i" "md=" "md_")"
+                    array="$(/bin/replace -s/ "$device" "," " uuid=")"
+                    echo "ARRAY /dev/$array" >> $mdconfig
+                    RAID_FOUND=1
+                    ;;
+            esac 
+        done
+    else
+        RAID_FOUND=1
+    fi
+    if [ "$RAID_FOUND" = 1 ]; then
+        # assemble everything
+        /sbin/mdassemble.static
+    fi
+}
\ No newline at end of file


Property changes on: mdadm/trunk/mdadm_hook
___________________________________________________________________
Added: svn:executable
   + *

Added: mdadm_install
===================================================================
--- mdadm_install	                        (rev 0)
+++ mdadm_install	2009-03-08 18:17:20 UTC (rev 29450)
@@ -0,0 +1,44 @@
+# vim: set ft=sh:
+
+install ()
+{
+    MODULES=" $(checked_modules "drivers/md/*" | grep -v "dm-") "
+    BINARIES="mdassemble.static"
+    FILES=""
+    SCRIPT="mdadm"
+    # check if a custom mdadm.conf exists
+    if grep -q ^ARRAY /etc/mdadm.conf; then
+        echo "Custom /etc/mdadm.conf file will be used in initramfs for assembling arrays."
+        add_file "/etc/mdadm.conf"
+    fi
+}
+
+help ()
+{
+cat<<HELPEOF
+  This hook loads the necessary modules for any raid root device,
+  and assembles the raid device when run.
+
+  If arrays are defined in /etc/mdadm.conf, the file will be used instead
+  of command line assembling.
+  
+  Command Line Setup:
+  - for raid arrays with persistent superblocks:
+    md=<md device no.>,dev0,dev1,...,devn
+    md=<md device no.>,uuid
+  - for partitionable raid arrays with persistent superblocks:
+    md=d<md device no.>,dev0,dev1,...,devn
+    md=d<md device no.>,uuid
+
+  Parameters:
+  - <md device no.> = the number of the md device: 
+    0 means md0, 1 means md1, ...
+  - <dev0-devn>: e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1
+                   or 0900878d:f95f6057:c39a36e9:55efa60a
+  Examples:
+  - md=d0,/dev/sda3,/dev/sda4 md=d1,/dev/hda1,/dev/hdb1
+    This will setup 2 md partitionable arrays.
+  - md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1
+    This will setup 2 md arrays with persistent superblocks.
+HELPEOF
+}




More information about the arch-commits mailing list