]>
Commit | Line | Data |
---|---|---|
82705b6e MT |
1 | --- grub-0.95/util/grub-install.in.support_md 2004-12-17 17:50:45.000000000 -0500 |
2 | +++ grub-0.95/util/grub-install.in 2004-12-19 19:19:20.509409160 -0500 | |
3 | @@ -207,6 +207,43 @@ | |
4 | echo "$tmp_fname" | |
5 | } | |
6 | ||
7 | +# Usage: is_raid1_device devicename | |
8 | +# Returns 0 if devicename is a raid1 md device, 1 if it is not. | |
9 | +is_raid1_device () { | |
10 | + case "$host_os" in | |
11 | + linux*) | |
12 | + level=`mdadm --query --detail $1 2>/dev/null | \ | |
13 | + awk '/Raid Level :/ {print $4}'` | |
14 | + if [ "$level" = "raid1" ]; then | |
15 | + return 0 | |
16 | + fi | |
17 | + ;; | |
18 | + esac | |
19 | + return 1 | |
20 | +} | |
21 | + | |
22 | +# Usage: find_real_devs device | |
23 | +# Returns space separated list of devices for linux if device is | |
24 | +# a raid1 device. In all other cases, the provided value is returned. | |
25 | +find_real_devs () { | |
26 | + source_device=$1 | |
27 | + case "$host_os" in | |
28 | + linux*) | |
29 | + if is_raid1_device $source_device ; then | |
30 | + list="" | |
31 | + for device in `mdadm --query --detail "${source_device}" | \ | |
32 | + awk '/\/dev\/[^(md)]/ {print $7}'` ; do | |
33 | + list="$list $device" | |
34 | + done | |
35 | + echo $list | |
36 | + return 0 | |
37 | + fi | |
38 | + ;; | |
39 | + esac | |
40 | + echo $source_device | |
41 | + return 0 | |
42 | +} | |
43 | + | |
44 | # Usage: find_device file | |
45 | # Find block device on which the file resides. | |
46 | find_device () { | |
47 | @@ -219,7 +256,7 @@ | |
48 | exit 1 | |
49 | fi | |
50 | ||
51 | - tmp_fname=`resolve_symlink $tmp_fname` | |
52 | + tmp_fname=`resolve_symlink $tmp_fname` | |
53 | ||
54 | echo "$tmp_fname" | |
55 | } | |
56 | @@ -379,7 +416,11 @@ | |
57 | # Check for INSTALL_DEVICE. | |
58 | case "$install_device" in | |
59 | /dev/*) | |
60 | + # If we are running md on a Linux box, just use the first physical device | |
61 | + # at this point. | |
62 | install_device=`resolve_symlink "$install_device"` | |
63 | + install_device=`find_real_devs $install_device | awk '{print $1}'` | |
64 | + | |
65 | install_drive=`convert "$install_device"` | |
66 | # I don't know why, but some shells wouldn't die if exit is | |
67 | # called in a function. | |
68 | @@ -408,14 +449,7 @@ | |
69 | grub_prefix="/grub" | |
70 | fi | |
71 | ||
72 | -# Convert the root device to a GRUB drive. | |
73 | -root_drive=`convert "$root_device"` | |
74 | -if test "x$root_drive" = x; then | |
75 | - exit 1 | |
76 | -fi | |
77 | - | |
78 | -# Check if the root directory exists in the same device as the grub | |
79 | -# directory. | |
80 | +# Check if the root directory exists in the same device as the grub directory. | |
81 | grubdir_device=`find_device ${grubdir}` | |
82 | ||
83 | if test "x$grubdir_device" != "x$root_device"; then | |
84 | @@ -431,30 +465,40 @@ | |
85 | test -n "$mkimg" && img_file=`$mkimg` | |
86 | test -n "$mklog" && log_file=`$mklog` | |
87 | ||
88 | -for file in ${grubdir}/stage1 ${grubdir}/stage2 ${grubdir}/*stage1_5; do | |
89 | - count=5 | |
90 | - tmp=`echo $file | sed "s|^${grubdir}|${grub_prefix}|"` | |
91 | - while test $count -gt 0; do | |
92 | - $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file | |
93 | +for real_device in `find_real_devs $root_device`; do | |
94 | + # Convert the root deviceto a GRUB drive. | |
95 | + root_drive=`convert "$real_device"` | |
96 | + if [ "x$root_drive" = x ]; then | |
97 | + exit 1 | |
98 | + fi | |
99 | + | |
100 | + for file in ${grubdir}/stage1 ${grubdir}/stage2 ${grubdir}/*stage1_5; do | |
101 | + count=5 | |
102 | + tmp=`echo $file | sed "s|^${grubdir}|${grub_prefix}|"` | |
103 | + while test $count -gt 0; do | |
104 | + sync | |
105 | + $grub_shell --batch $no_floppy --device-map=$device_map \ | |
106 | + <<EOF >$log_file | |
107 | dump ${root_drive}${tmp} ${img_file} | |
108 | quit | |
109 | EOF | |
110 | - if grep "Error [0-9]*: " $log_file >/dev/null; then | |
111 | - : | |
112 | - elif cmp $file $img_file >/dev/null; then | |
113 | - break | |
114 | + if grep "Error [0-9]*: " $log_file >/dev/null; then | |
115 | + : | |
116 | + elif cmp $file $img_file >/dev/null; then | |
117 | + break | |
118 | + fi | |
119 | + sleep 1 | |
120 | + count=`expr $count - 1` | |
121 | + done | |
122 | + if test $count -eq 0; then | |
123 | + echo "The file $file not read correctly." 1>&2 | |
124 | + exit 1 | |
125 | fi | |
126 | - sleep 1 | |
127 | - count=`expr $count - 1` | |
128 | done | |
129 | - if test $count -eq 0; then | |
130 | - echo "The file $file not read correctly." 1>&2 | |
131 | - exit 1 | |
132 | - fi | |
133 | -done | |
134 | ||
135 | -rm -f $img_file | |
136 | -rm -f $log_file | |
137 | + rm -f $img_file | |
138 | + rm -f $log_file | |
139 | +done | |
140 | ||
141 | if ! test -e ${grubdir}/grub.conf ; then | |
142 | test -e ${grubdir}/menu.lst && ln -s ./menu.lst ${grubdir}/grub.conf | |
143 | @@ -463,21 +507,33 @@ | |
144 | # Create a safe temporary file. | |
145 | test -n "$mklog" && log_file=`$mklog` | |
146 | ||
147 | -# Before all invocations of the grub shell, call sync to make sure | |
148 | -# the raw device is in sync with any bufferring in filesystems. | |
149 | -sync | |
150 | +for real_device in `find_real_devs $root_device`; do | |
151 | + # Convert the root deviceto a GRUB drive. | |
152 | + root_drive=`convert "$real_device"` | |
153 | + if [ "x$root_drive" = x ]; then | |
154 | + exit 1 | |
155 | + fi | |
156 | + | |
157 | + # Before all invocations of the grub shell, call sync to make sure | |
158 | + # the raw device is in sync with any bufferring in filesystems. | |
159 | + sync | |
160 | ||
161 | -# Now perform the installation. | |
162 | -$grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file | |
163 | + # Now perform the installation. | |
164 | + $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >>$log_file | |
165 | root $root_drive | |
166 | -setup $force_lba --stage2=$grubdir/stage2 --prefix=$grub_prefix $install_drive | |
167 | +setup $force_lba --stage2=$grubdir/stage2 --prefix=$grub_prefix $root_drive | |
168 | quit | |
169 | EOF | |
170 | ||
171 | -if grep "Error [0-9]*: " $log_file >/dev/null || test $debug = yes; then | |
172 | +done | |
173 | + | |
174 | +if grep "Error [0-9]*: " $log_file >/dev/null ; then | |
175 | cat $log_file 1>&2 | |
176 | exit 1 | |
177 | fi | |
178 | +if test $debug = yes; then | |
179 | + cat $log_file 1>&2 | |
180 | +fi | |
181 | ||
182 | rm -f $log_file | |
183 |