View | Details | Raw Unified | Return to bug 832501
Collapse All | Expand All

(-)mkinitrd.orig/scripts/boot-md.sh (+11 lines)
Lines 15-20 Link Here
15
## need_mdadm=1		use MD raid
15
## need_mdadm=1		use MD raid
16
## 
16
## 
17
17
18
debug() {
19
    if [ "$DEBUG" = 1 ]; then
20
        echo "DEBUG: $@"
21
    fi
22
}
23
18
# load the necessary module before we initialize the raid system
24
# load the necessary module before we initialize the raid system
19
load_modules
25
load_modules
20
26
Lines 67-74 Link Here
67
md_assemble()
73
md_assemble()
68
{
74
{
69
	local dev=$1 uuid mdconf container container_name
75
	local dev=$1 uuid mdconf container container_name
76
	debug "md_assemble $dev"
70
77
71
	if test -e "$dev"; then
78
	if test -e "$dev"; then
79
		debug "$dev exists; returning"
72
		return
80
		return
73
	fi
81
	fi
74
	case "$dev" in
82
	case "$dev" in
Lines 83-88 Link Here
83
		dev=
91
		dev=
84
		;;
92
		;;
85
	*)
93
	*)
94
		debug "unhandled device $dev; returning"
86
		return
95
		return
87
	esac
96
	esac
88
	if test -f /etc/mdadm.conf; then
97
	if test -f /etc/mdadm.conf; then
Lines 98-103 Link Here
98
	else
107
	else
99
		mdconf="-c partitions"
108
		mdconf="-c partitions"
100
	fi
109
	fi
110
# 2013-07-30 pm: added --run to 2 lines here:
101
	case "$container" in
111
	case "$container" in
102
	"")
112
	"")
103
		;;
113
		;;
Lines 114-119 Link Here
114
	*)
124
	*)
115
		echo "unrecognized container for $dev: $container"
125
		echo "unrecognized container for $dev: $container"
116
	esac
126
	esac
127
# 2013-07-30 pm: added --run to 3 lines here:
117
	if test -n "$dev"; then
128
	if test -n "$dev"; then
118
		$mdadm -A $mdconf "$dev" --offroot
129
		$mdadm -A $mdconf "$dev" --offroot
119
	else
130
	else
(-)mkinitrd.orig/scripts/setup-md.sh (-1 / +20 lines)
Lines 11-40 Link Here
11
cont_list=
11
cont_list=
12
md_devs=
12
md_devs=
13
13
14
# peter added this so /boot will start degraded
15
# this removes duplicates
16
# if root is mdadm+lvm, then there would be 2 roots here, one from setup-storage checking mdadm.conf, and one from another script that finds the md device that an LV root is on)
17
blockdev=$(echo "$blockdev" | tr ' ' '\n' | sort | uniq | tr '\n' ' ')
18
19
verbose "[MD]\t start setup-md.sh blockdev = $blockdev"
20
14
declare -A md_conf
21
declare -A md_conf
15
# blockdev contains real devices (/dev/X) for root, resume, journal, dumb
22
# blockdev contains real devices (/dev/X) for root, resume, journal, dumb
16
for bd in $blockdev ; do
23
for bd in $blockdev ; do
17
    is_part_dev=false
24
    is_part_dev=false
18
    case $bd in
25
    case $bd in
19
	/dev/md[0-9]*p[0-9]*)
26
	/dev/md[0-9]*p[0-9]*)
27
	    verbose "[MD]\t $bd is partitionable"
20
	    # Partitionable MD RAID. This is partition on RAID. Get the RAID
28
	    # Partitionable MD RAID. This is partition on RAID. Get the RAID
21
	    bd=${bd%%p[0-9]*}
29
	    bd=${bd%%p[0-9]*}
22
	    is_part_dev=true
30
	    is_part_dev=true
23
	    ;;
31
	    ;;
24
	/dev/md[0-9]*)
32
	/dev/md[0-9]*)
33
	    verbose "[MD]\t $bd is normal"
34
	    ;;
35
	/dev/md/[0-9]*)
36
	    verbose "[MD]\t $bd has slash"
25
	    ;;
37
	    ;;
26
	*)
38
	*)
39
	    verbose "[MD]\t $bd is other type"
27
	    mdblockdev="$mdblockdev $bd"
40
	    mdblockdev="$mdblockdev $bd"
28
	    continue
41
	    continue
29
	    ;;
42
	    ;;
30
    esac
43
    esac
31
    # Check if this device is already added (possible for partitionable).
44
    # Check if this device is already added (possible for partitionable).
32
    md_dev=`mdadm -D --export $bd | sed -n -e 's/^MD_DEVNAME=//p'`
45
    md_dev=`mdadm -D --export $bd | sed -n -e 's/^MD_DEVNAME=//p'`
46
    verbose "[MD]\t bd = $bd md_dev = $md_dev"
33
    if [ -z "$md_dev" ]; then
47
    if [ -z "$md_dev" ]; then
34
        md_dev=${bd##/dev/}
48
        md_dev=${bd##/dev/}
35
    else
49
    else
36
	bd="/dev/md/$md_dev"
50
# peter changed this from bd="/dev/..." to md_dev="...", because otherwise the md_devs="..." line later won't use the bd set here, only md_dev which was wrong (0 instead of md0 or md/0), ending up with /dev/0
51
#	bd="/dev/md/$md_dev"
52
	md_dev="md/$md_dev"
37
    fi
53
    fi
54
    verbose "[MD]\t bd = $bd md_dev = $md_dev"
38
    dup_found=false
55
    dup_found=false
39
    for dup in $md_devs; do
56
    for dup in $md_devs; do
40
	if [ x"$dup" = x"$md_dev" ]; then
57
	if [ x"$dup" = x"$md_dev" ]; then
Lines 55-60 Link Here
55
    fi
72
    fi
56
    md_tmpblockdev=$(mdadm -Dbv $bd | sed -n "1D;s/,/ /g;s/^ *devices=//p")
73
    md_tmpblockdev=$(mdadm -Dbv $bd | sed -n "1D;s/,/ /g;s/^ *devices=//p")
57
    mdblockdev="$mdblockdev $md_tmpblockdev"
74
    mdblockdev="$mdblockdev $md_tmpblockdev"
75
    verbose "[MD]\t final bd = $bd md_dev = $md_dev"
58
    md_devs="$md_devs $md_dev"
76
    md_devs="$md_devs $md_dev"
59
    container=$(echo "$mdconf" | sed -rn 's/.* container=([^ ]*) .*/\1/p')
77
    container=$(echo "$mdconf" | sed -rn 's/.* container=([^ ]*) .*/\1/p')
60
    for cnt in $cont_list; do
78
    for cnt in $cont_list; do
Lines 102-106 Link Here
102
    md_devs=$(printf '/dev/%s ' $md_devs)
120
    md_devs=$(printf '/dev/%s ' $md_devs)
103
fi
121
fi
104
122
123
echo "md devices:     $md_devs"
105
save_var need_mdadm
124
save_var need_mdadm
106
save_var md_devs
125
save_var md_devs
(-)mkinitrd.orig/scripts/setup-storage.sh (+21 lines)
Lines 4-9 Link Here
4
#%param_j: "Journal device" device journaldev
4
#%param_j: "Journal device" device journaldev
5
#
5
#
6
# usage: update_list <id> <list>
6
# usage: update_list <id> <list>
7
8
set &> /root/setfrommkinitrd
9
7
update_list() {
10
update_list() {
8
    local elem=$1
11
    local elem=$1
9
12
Lines 414-416 Link Here
414
save_var dumpdev
417
save_var dumpdev
415
blockdev="$(resolve_device Root $rootdev) $(resolve_device /usr $usrdev) $(resolve_device Resume $resumedev) $(resolve_device Journal $journaldev) $(resolve_device Dump $dumpdev)"
418
blockdev="$(resolve_device Root $rootdev) $(resolve_device /usr $usrdev) $(resolve_device Resume $resumedev) $(resolve_device Journal $journaldev) $(resolve_device Dump $dumpdev)"
416
419
420
# peter added this so /boot will start degraded (this adds all devices in /etc/mdadm.conf):
421
if [ -e /etc/sysconfig/mdadm ]; then
422
    . <(grep MDADM_CONFIG /etc/sysconfig/mdadm)
423
fi
424
if [ -z "$MDADM_CONFIG" ]; then
425
    MDADM_CONFIG=/etc/mdadm.conf
426
fi
427
if [ ! -e "$MDADM_CONFIG" ]; then
428
    # only print the warning and run mdadm -D --scan if there are any md devices found
429
    if find /sys/devices/virtual/block/ -name "md" &>/dev/null; then
430
        echo "WARNING: mdadm config file \"$MDADM_CONFIG\" was not found; auto-generating it for you"
431
        blockdev="$blockdev $(mdadm -D --scan | grep ARRAY | cut -d' ' -f2)"
432
    fi
433
else
434
    blockdev="$blockdev $(grep ARRAY "$MDADM_CONFIG" | cut -d' ' -f2)"
435
fi
436
437
verbose "[STORAGE]\t blockdev = $blockdev"

Return to bug 832501