[patch] update-grub: Add support for software raid1
reassign 292274 grub
tags 292274 + d-i patch
retitle 292274 update-grub: Add support for software raid1
thanks
I have traced the root of these installation problems to update-grub.
If the device in /etc/fstab is /dev/md?, update-grub will default to
(hd0,0) as it does not know how to deal with software raid devices in
functions convert_default and convert.
The attached patch add support for raid1.
The /dev/md? will be converted to the first physical device in the array.
Note: I have chosen to use only the first physical device and not all (as
suggested in #264262 because there seemed to be some dispute over the
question if this is useful.
Please consider applying this patch before the release of Sarge, as
because d-i now supports raid installation, a lot of people will benefit
from this. Because of this I have left severity at important instead of
setting it to wishlist.
I have tested the patch on a similar setup as described in this report.
I've also tested the patch on a box without raid.
Cheers,
Frans Pop
(Debian Installer team)
--- /sbin/update-grub 2005-01-16 23:20:51.000000000 +0100
+++ update-grub 2005-01-29 16:11:59.000000000 +0100
@@ -96,6 +96,34 @@
echo $device
}
+# Usage: convert_raid1 os_device
+# Checks if os_device is a software raid1.
+# If so, converts to first physical device in array.
+convert_raid1 ()
+{
+ case $1 in
+ /dev/md[0-9])
+ : ;; # Continue
+ *)
+ return 1 ;;
+ esac
+
+ [ -x /sbin/mdadm ] || return 1
+
+ # Check that the raid device is raid1
+ raidlevel=$(mdadm -D -b $1 | grep "^ARRAY" | \
+ sed "s/^.*level=//" | cut -d" " -f1)
+ [ "$raidlevel" = "raid1" ] || return 1
+
+ # Take only the first device that makes up the raid
+ raiddev=$(mdadm -D -b $1 | grep "^ devices=" | \
+ sed "s/^ devices=//" | cut -d"," -f1)
+ [ -n "$raiddev" ] || return 1
+
+ echo $raiddev
+ return 0
+}
+
# Usage: convert os_device
# Convert an OS device to the corresponding GRUB drive.
# This part is OS-specific.
@@ -208,7 +236,14 @@
# Calls OS-specific convert, and returns a default of
# (hd0,0) if anything goes wrong
convert_default () {
- if tmp=$(convert $1 2>/dev/null) ; then
+ # Check if device is software raid1 array
+ if tmp_dev=$(convert_raid1 $1 2>/dev/null) ; then
+ : # Use device returned by convert_raid1
+ else
+ tmp_dev=$1
+ fi
+
+ if tmp=$(convert $tmp_dev 2>/dev/null) ; then
echo $tmp
else
echo "(hd0,0)"
Reply to: