]> git.pld-linux.org Git - projects/geninitrd.git/blame - mod-dmraid.sh
no need to mess with magic values, let the "magic" be value
[projects/geninitrd.git] / mod-dmraid.sh
CommitLineData
36523626 1#!/bin/sh
c34c6a69 2DMRAID_RCSID='$Revision$ $Date:: $'
05c474b5 3
36523626 4# geninitrd mod: dmraid
6e49b0b1 5USE_DMRAID=${USE_DMRAID:-yes}
36523626
ER
6
7# if we should init dmraid at boot
8have_dmraid=no
9
c124d0cf
ER
10# setup geninitrd module
11# @access public
12setup_mod_dmraid() {
13 dmraid=$(find_tool $initrd_dir/dmraid /sbin/dmraid-initrd)
6e49b0b1 14 if [ ! -x /sbin/dmraid ] || [ ! -x "$dmraid" ]; then
c124d0cf
ER
15 USE_DMRAID=no
16 fi
36523626 17
c124d0cf
ER
18 if [ "$kernel_version" -lt "002006" ]; then
19 USE_DMRAID=no
20 fi
21}
fb0e4a4c 22
36523626
ER
23# return true if dmraid is set on $devpath
24# @param string $devpath device node to be examined
25# @access public
26is_dmraid() {
27 local devpath="$1"
28
29 # dmraid disabled
30 if ! is_yes "$USE_DMRAID"; then
31 return 1
32 fi
33
34 if ! is_yes "$(echo "$devpath" | awk '/^\/dev\/mapper\/(sil|hpt37x|hpt45x|isw|lsi|nvidia|pdc|sil|via|dos)_/ { print "yes"; }')"; then
35 return
36 fi
37}
38
39# find dmraid modules for $devpath
40# @param $devpath device to be examined
41# @return false if $devpath is not on dmraid
42# @access public
43find_modules_dmraid() {
44 local devpath="$1"
45
46 # get blockdev itself (without partition)
47 # /dev/mapper/sil_ahbgadcbchfc3 -> /dev/mapper/sil_ahbgadcbchfc
48 local blockdev=${devpath%%[0-9]*}
49 local raidname=${blockdev#/dev/mapper/}
50 local found=0
51
52 local dev phydevs=$(dmraid -r -cdevpath,raidname | awk -F, -vv="$raidname" '{if ($2 == v) print $1}')
53 for dev in $phydevs; do
54 find_modules_for_devpath $dev
55 lvm_ignore_devices="$lvm_ignore_devices $dev"
56 found=1
57 done
58
59 if [ $found = 0 ]; then
60 return 1
61 fi
62
b02a6b13 63 find_module "dm-mirror"
36523626
ER
64 have_dmraid=yes
65 return 0
66}
67
68# generate initrd fragment for dmraid
69# @access public
70initrd_gen_dmraid() {
1b481849
ER
71 if ! is_yes "$have_dmraid"; then
72 return
73 fi
74
36523626 75 inst_d /sbin
684d5d2a 76 inst_exec $dmraid /sbin/dmraid
36523626
ER
77
78 mount_dev
79 mount_sys
80 initrd_gen_devices
81 add_linuxrc <<-EOF
82 # 2 secs was enough for my system to initialize.
83 # XXX: shouldn't just call 'udevadm settle' ?
84 usleep 2000000
85 : 'Activating Device-Mapper RAID(s)'
86 /sbin/dmraid -ay -i
87
88 debugshell
89 EOF
90}
This page took 0.07443 seconds and 4 git commands to generate.