wok-4.x view dmraid/stuff/grub-dmraid @ rev 4025
dmraid: add grub-dmraid
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Sep 04 22:07:47 2009 +0200 (2009-09-04) |
parents | |
children | 8db9118bfcb7 |
line source
1 #!/bin/sh
3 grub_part=0
4 [ -n "$1" ] && case "$1" in
5 [0-9]*) grub_part=$1;;
6 *) cat 1>&2 <<EOT
7 Usage: $0 [partition]
8 Install grub on dmraid device. Default partition is 0.
9 EOT
10 exit 2;;
11 esac
13 # Get raid parameters
14 dev=/dev/mapper/$(dmraid -s 2> /dev/null | grep ^name | awk '{ print $3 }')
15 if [ "$dev" == "/dev/mapper/" ]; then
16 echo "No dmraid device found." 1>&2
17 exit 1
18 fi
20 geometry="$(fdisk -l $dev | grep heads | sed \
21 's|\(.*\) heads, \(.*\) sectors/track, \(.*\) cylinders|\3 \1 \2|')"
23 # Grub bug workaround
24 for i in ${dev}p* ; do
25 n=${i#${dev}p}
26 [ -e $i -a ! -e ${dev}$n ] && ln -s $(basename $dev)p$n ${dev}$n
27 done
29 # Let's go
30 grub --device-map=/dev/null --batch <<EOT
31 device (hd0) $dev
32 geometry (hd0) $geometry
33 root (hd0,$grub_part)
34 setup (hd0)
35 quit
36 EOT