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