summaryrefslogtreecommitdiff
path: root/src/core/libs/lib-blockdevices-filesystems.sh
diff options
context:
space:
mode:
authorGerhard Brauer <gerbra@archlinux.de>2009-07-27 21:23:01 +0200
committerDieter Plaetinck <dieter@plaetinck.be>2009-07-27 21:23:01 +0200
commit4754e1f0f956e0227ad0c9c280e303e6d314fac8 (patch)
tree75df2c8262ecb93f0969324eec1636b3e6ccee4f /src/core/libs/lib-blockdevices-filesystems.sh
parenta96f1b9ac7f505865ffaf9ee9ac1a375c9b959be (diff)
grub refactoring
I have tested it: - With raid1 and seperate /boot on an raid array - With raid1 and no seperate /boot on an raid array - Without raid and with/without seperate /boot On all installs grub installs successfully and i could boot the system. On the raid systems i could also boot from each HD in the array.
Diffstat (limited to 'src/core/libs/lib-blockdevices-filesystems.sh')
-rw-r--r--src/core/libs/lib-blockdevices-filesystems.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 577fd81..3511557 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -773,3 +773,46 @@ get_blockdevice_size ()
[ $unit = GiB ] && BLOCKDEVICE_SIZE=$((bytes/2**30))
[ $unit = GB ] && BLOCKDEVICE_SIZE=$((bytes/10**9))
}
+
+
+# $1 blockdevice (ex: /dev/md0 or /dev/sda1)
+# return true when blockdevice is an md raid, otherwise return a unset value
+mdraid_is-raid ()
+{
+ local israid
+ if [ -z $1 ]; then
+ # Don't call mdadm on empty blockdevice parameter!
+ israid=""
+ elif [ "$(mdadm --query $1 | cut -d':' -f2)" == " is not an md array" ]; then
+ israid=""
+ else
+ israid=true
+ fi
+ echo $israid
+}
+
+# $1 md raid blockdevice (ex: /dev/md0)
+# return the array member device which is slave 0 in the given array
+# ex: /dev/md0 is an array with /dev/sda1, /dev/sdb1,
+# so we would return /dev/sda1 as slave 0
+#
+# This procedure is used to determine the grub value for root, ex: (hd0,0)
+mdraid_slave0 ()
+{
+ echo "/dev/"$(ls -ldgGQ /sys/class/block/$(basename $1)/md/rd0 | cut -d'"' -f4 | cut -d'-' -f2)
+}
+
+# $1 md raid blockdevice (ex: /dev/md0)
+# return a list of array members from given md array
+# ex: /dev/md0 has slaves: "/dev/sda1 /dev/sdb2 /dev/sdc2"
+mdraid_all-slaves ()
+{
+ local slave=
+ local slaves=
+ for slave in $(ls /sys/class/block/$(basename $1)/slaves/); do
+ slaves=$slaves"/dev/"$slave" "
+ done
+ echo $slaves
+}
+
+