Bug#468832: multipath support
On Sat, Mar 01, 2008 at 07:57:15PM +0100, Guido Günther wrote:
> attached is a first version of multipath support for grub-install to get
> some comments. It basically uses the sataraid code. The current code
...as Frans pointed out I forgot the attachment.
-- Guido
>From b36dac79b414d9a9b472f32eecdaa975d829481c Mon Sep 17 00:00:00 2001
From: Guido Guenther <agx@sigxcpu.org>
Date: Sat, 1 Mar 2008 19:41:17 +0100
Subject: [PATCH] multipath support modeled after dmraid
---
.../grub-installer/debian/grub-installer.templates | 21 ++++++++
.../arch/i386/grub-installer/debian/isinstallable | 13 +++++-
packages/arch/i386/grub-installer/grub-installer | 50 +++++++++++++++-----
3 files changed, 71 insertions(+), 13 deletions(-)
mode change 100755 => 100644 packages/arch/i386/grub-installer/grub-installer
diff --git a/packages/arch/i386/grub-installer/debian/grub-installer.templates b/packages/arch/i386/grub-installer/debian/grub-installer.templates
index 183d9cd..7a8441a 100644
--- a/packages/arch/i386/grub-installer/debian/grub-installer.templates
+++ b/packages/arch/i386/grub-installer/debian/grub-installer.templates
@@ -47,6 +47,27 @@ _Description: Unable to configure GRUB
.
The GRUB installation has been aborted.
+Template: grub-installer/multipath
+Type: boolean
+Default: true
+# :sl3:
+_Description: Install the GRUB boot loader to the multipath device?
+ Installation of GRUB on multipath is experimental.
+ .
+ GRUB is always installed to the master boot record (MBR) of the multipath
+ device. It is also assumed that that this device is listed as the first hard
+ device in the boot order defined in the system's BIOS setup.
+ .
+ The GRUB root device is: ${GRUBROOT}.
+
+Template: grub-installer/multipath-error
+Type: error
+# :sl2:
+_Description: Unable to configure GRUB
+ An error occurred while setting up GRUB for the multipathed device.
+ .
+ The GRUB installation has been aborted.
+
Template: grub-installer/install_to_xfs
Type: boolean
Default: false
diff --git a/packages/arch/i386/grub-installer/debian/isinstallable b/packages/arch/i386/grub-installer/debian/isinstallable
index 73ddfcf..6e2eb41 100755
--- a/packages/arch/i386/grub-installer/debian/isinstallable
+++ b/packages/arch/i386/grub-installer/debian/isinstallable
@@ -24,6 +24,17 @@ is_sataraid () {
return 1
}
+is_multipath () {
+ if type multipath >/dev/null 2>&1; then
+ for frdisk in $(multipath -l 2>/dev/null | grep '^mpath[0-9]\+ ' | cut -d ' ' -f 1); do
+ if echo "$1" | grep -q "^/dev/mapper/${frdisk}-part[0-9]\+"; then
+ return 0
+ fi
+ done
+ fi
+ return 1
+}
+
ARCH="$(archdetect)"
case $ARCH in
@@ -53,7 +64,7 @@ fi
# Check for the control file to work around lvdisplay refusal to work with
# certian lvm device names.
if lvdisplay "$bootfs" | grep -q 'LV Name' 2>/dev/null || [ -e "$(dirname $bootfs)/control" ]; then
- if ! is_sataraid $bootfs; then
+ if ! is_sataraid $bootfs && ! is_multipath $bootfs; then
log "/boot is a lvm volume ($bootfs), cannot install grub"
exit 1
fi
diff --git a/packages/arch/i386/grub-installer/grub-installer b/packages/arch/i386/grub-installer/grub-installer
old mode 100755
new mode 100644
index 1dc80bc..2c25b0c
--- a/packages/arch/i386/grub-installer/grub-installer
+++ b/packages/arch/i386/grub-installer/grub-installer
@@ -99,12 +99,14 @@ convert () {
tmp_disk=$(echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
-e 's%\(fd[0-9]*\)$%\1%' \
-e 's%/part[0-9]*$%/disc%' \
- -e 's%\(c[0-7]d[0-9]*\).*$%\1%')
+ -e 's%\(c[0-7]d[0-9]*\).*$%\1%' \
+ -e 's%\(/mapper/mpath[0-9]\+\)-part[0-9]\+$%\1%')
tmp_part=$(echo "$1" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \
-e 's%.*/fd[0-9]*$%%' \
-e 's%.*/floppy/[0-9]*$%%' \
-e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \
- -e 's%.*c[0-7]d[0-9]*p*%%')
+ -e 's%.*c[0-7]d[0-9]*p*%%' \
+ -e 's%.*/mapper/mpath[0-9]\+-part\([0-9]\+\)%\1%')
;;
gnu*)
tmp_disk=$(echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%')
@@ -276,9 +278,29 @@ if type dmraid >/dev/null 2>&1; then
frdev=/dev/mapper/$frdisk
frbootpart=${disc_offered#$frdev}
frgrubroot=$(($frbootpart - 1))
+ frtype=sataraid
break
fi
done
+# Check if the boot file system is on multipath
+elif type multipath >/dev/null 2>&1; then
+ for frdisk in $(multipath -l 2>/dev/null | \
+ grep '^mpath[0-9]\+ ' | cut -d ' ' -f 1); do
+ if echo "$disc_offered" | \
+ grep -q "^/dev/mapper/${frdisk}-part[0-9]\+"; then
+ frdev=/dev/mapper/$frdisk
+ frbootpart=${disc_offered#$frdev}
+ frgrubroot=$((${frbootpart#-part} - 1))
+ frtype=multipath
+ break
+ fi
+ done
+ if [ "$frdisk" ]; then
+ # Create the device nodes for grub:
+ apt-install dmsetup
+ $chroot $ROOT mount /proc
+ $chroot $ROOT dmsetup mknodes
+ fi
fi
info "Identified partition label for $bootfs: $bootfslabel"
@@ -380,6 +402,10 @@ if ! apt-install $grub_package ; then
exit 1
fi
+if [ "$frtype" = multipath ]; then
+ $chroot $ROOT umount /proc
+fi
+
db_progress STEP 1
db_progress INFO grub-installer/progress/step_os-probe
os-prober > /tmp/os-probed || true
@@ -449,11 +475,11 @@ fi
if [ "$frdev" ]; then
if [ -e $ROOT$frdev ] && \
- [ $frgrubroot -gt 0 ] && [ -e $ROOT$frdev$frbootpart ]; then
- db_subst grub-installer/sataraid GRUBROOT $ROOT$frdev$frbootpart
- q=grub-installer/sataraid
+ [ $frgrubroot -ge 0 ] && [ -e $ROOT$frdev$frbootpart ]; then
+ db_subst grub-installer/$frtype GRUBROOT $ROOT$frdev$frbootpart
+ q=grub-installer/$frtype
else
- db_input critical grub-installer/sataraid-error
+ db_input critical grub-installer/${frtype}-error
db_go || true
exit 1
fi
@@ -475,8 +501,8 @@ while : ; do
bootdev="(hd0)"
break
else
- # Exit to menu if /boot is on SATA RAID; we don't
- # support device selection in that case
+ # Exit to menu if /boot is on SATA RAID/multipath; we
+ # don't support device selection in that case
if [ "$frdev" ]; then
db_progress STOP
exit 10
@@ -554,8 +580,8 @@ if [ -z "$frdisk" ]; then
else
- # Semi-manual grub setup for Serial ATA RAID
- info "Boot partition is on a Serial ATA RAID disk"
+ # Semi-manual grub setup for Serial ATA RAID/multipath
+ info "Boot partition is on a Serial ATA RAID disk or multipath device"
info "Installing GRUB to $frdev; grub root is $disc_offered"
case $(archdetect) in
i386/*)
@@ -563,7 +589,7 @@ else
amd64/*)
stagedir=x86_64-pc ;;
*)
- error "Unsupported architecture for SATA RAID installation"
+ error "Unsupported architecture for SATA RAID/multipath installation"
exit 1
;;
esac
@@ -593,7 +619,7 @@ db_progress INFO grub-installer/progress/step_config_loader
rm -f $ROOT/boot/grub/$menu_file
update_grub
-# For SATA RAID we may need to update the grub root
+# For SATA RAID/multipath we may need to update the grub root
# TODO: This should really be supported in update-grub
if [ "$frdev" ] && [ $frgrubroot -gt 0 ]; then
sed -i "/^root/s/(hd0,0)/(hd0,$frgrubroot)/
--
1.5.4.1
Reply to: