mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-19 19:40:37 +02:00
'added new mdadm hook'
This commit is contained in:
parent
154c4d674c
commit
8174f145f2
4 changed files with 94 additions and 63 deletions
50
lib/initcpio/hooks/arch_mdadm
Normal file
50
lib/initcpio/hooks/arch_mdadm
Normal file
|
@ -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
|
||||||
|
}
|
|
@ -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
|
|
||||||
}
|
|
44
lib/initcpio/install/arch_mdadm
Normal file
44
lib/initcpio/install/arch_mdadm
Normal file
|
@ -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<<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
|
||||||
|
}
|
|
@ -1,41 +0,0 @@
|
||||||
# Created by Tobias Powalowski <tpowa@archlinux.org>
|
|
||||||
|
|
||||||
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<<HELPEOF
|
|
||||||
This hook loads the necessary modules for an raid root device,
|
|
||||||
and assemble the raid device when run, on an arch boot image.
|
|
||||||
|
|
||||||
Kernel Parameters:
|
|
||||||
Specify all your md arrays with md= parameter:
|
|
||||||
::: Example ::: md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1
|
|
||||||
This will setup 2 md arrays with persistent superblocks
|
|
||||||
|
|
||||||
Setup:
|
|
||||||
- for old raid arrays without persistent superblocks:
|
|
||||||
md=<md device no.>,<raid level>,<chunk size factor>,<fault level>,dev0,dev1
|
|
||||||
- for raid arrays with persistent superblocks:
|
|
||||||
md=<md device no.>,dev0,dev1,...,devn
|
|
||||||
- for, to assemble a partitionable array:
|
|
||||||
md=d<md device no.>,dev0,dev1,...,devn
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
- <md device no.> = the number of the md device:
|
|
||||||
0 means md0, 1 means md1, ...
|
|
||||||
- <raid level> = -1 linear mode, 0 striped mode
|
|
||||||
other modes are only supported with persistent super block
|
|
||||||
- <chunk size factor> = (raid-0 and raid-1 only):
|
|
||||||
Set the chunk size as 4k << n.
|
|
||||||
- <fault level> = totally ignored
|
|
||||||
- <dev0-devn>: e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1
|
|
||||||
HELPEOF
|
|
||||||
}
|
|
Loading…
Reference in a new issue