From 8174f145f2eb86b9d51716a32db9db86aa58e454 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Sat, 28 Mar 2009 14:07:42 +0100 Subject: [PATCH] 'added new mdadm hook' --- lib/initcpio/hooks/arch_mdadm | 50 +++++++++++++++++++++++++++++++++ lib/initcpio/hooks/arch_raid | 22 --------------- lib/initcpio/install/arch_mdadm | 44 +++++++++++++++++++++++++++++ lib/initcpio/install/arch_raid | 41 --------------------------- 4 files changed, 94 insertions(+), 63 deletions(-) create mode 100644 lib/initcpio/hooks/arch_mdadm delete mode 100644 lib/initcpio/hooks/arch_raid create mode 100644 lib/initcpio/install/arch_mdadm delete mode 100644 lib/initcpio/install/arch_raid diff --git a/lib/initcpio/hooks/arch_mdadm b/lib/initcpio/hooks/arch_mdadm new file mode 100644 index 000000000..842aae9c9 --- /dev/null +++ b/lib/initcpio/hooks/arch_mdadm @@ -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 diff --git a/lib/initcpio/hooks/arch_raid b/lib/initcpio/hooks/arch_raid deleted file mode 100644 index 198e78b76..000000000 --- a/lib/initcpio/hooks/arch_raid +++ /dev/null @@ -1,22 +0,0 @@ -run_hook () -{ - #TODO scan for these somehow... - /sbin/modprobe -aq linear multipath raid0 raid1 raid456 raid10>/dev/null 2>&1 - # md= can be specified multiple times. The simplistic commandline - # parsing does not handle this, so we will let mdassemble parse it - # create md devices for installation - for i in $(seq 0 15); do - /sbin/mdadm --create /dev/md$i > /dev/null 2>&1 - /sbin/mdadm --create -a mdp /dev/md_d$i > /dev/null 2>&1 - done - for i in $(replace $(echo $md) ',' ' '); do - case $i in d[0-9]) - mdadm --assemble --auto=mdp /dev/md_$(replace $(echo $md) ',' ' ') - export USE_RAID_ARRAY=1 - ;; - esac - done - if ! [ "$USE_RAID_ARRAY" = "1" ] ; then - /bin/mdassemble ${CMDLINE} - fi -} diff --git a/lib/initcpio/install/arch_mdadm b/lib/initcpio/install/arch_mdadm new file mode 100644 index 000000000..10ab63864 --- /dev/null +++ b/lib/initcpio/install/arch_mdadm @@ -0,0 +1,44 @@ +# vim: set ft=sh: + +install () +{ + MODULES=" $(checked_modules "drivers/md/*" | grep -v "dm-") " + BINARIES="mdassemble.static mdadm" + FILES="" + SCRIPT="arch_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<,dev0,dev1,...,devn + md=,uuid + - for partitionable raid arrays with persistent superblocks: + md=d,dev0,dev1,...,devn + md=d,uuid + + Parameters: + - = the number of the md device: + 0 means md0, 1 means md1, ... + - : 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 +} diff --git a/lib/initcpio/install/arch_raid b/lib/initcpio/install/arch_raid deleted file mode 100644 index d2606c702..000000000 --- a/lib/initcpio/install/arch_raid +++ /dev/null @@ -1,41 +0,0 @@ -# Created by Tobias Powalowski - -install () -{ - MODULES=" $(checked_modules "drivers/md/*" | grep -v "dm-") " - BINARIES="mdadm" - FILES="" - SCRIPT="arch_raid" - add_file "/usr/lib/klibc/bin/mdassemble" "/bin/mdassemble" -} - -help () -{ -cat<,,,,dev0,dev1 - - for raid arrays with persistent superblocks: - md=,dev0,dev1,...,devn - - for, to assemble a partitionable array: - md=d,dev0,dev1,...,devn - - Parameters: - - = the number of the md device: - 0 means md0, 1 means md1, ... - - = -1 linear mode, 0 striped mode - other modes are only supported with persistent super block - - = (raid-0 and raid-1 only): - Set the chunk size as 4k << n. - - = totally ignored - - : e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1 -HELPEOF -}