wok-current annotate dmraid/stuff/grub-dmraid @ rev 13734
Add xscavenger
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Dec 25 16:55:52 2012 +0100 (2012-12-25) |
parents | 1a703730ac71 |
children | 02c70d036ea0 |
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@4027 | 20 # Ensure raid is active |
pascal@4027 | 21 [ ! -e $dev ] && dmraid-start |
pascal@4027 | 22 |
pascal@4025 | 23 geometry="$(fdisk -l $dev | grep heads | sed \ |
pascal@4025 | 24 's|\(.*\) heads, \(.*\) sectors/track, \(.*\) cylinders|\3 \1 \2|')" |
pascal@4025 | 25 |
pascal@4025 | 26 # Grub bug workaround |
pascal@4025 | 27 for i in ${dev}p* ; do |
pascal@4025 | 28 n=${i#${dev}p} |
pascal@4025 | 29 [ -e $i -a ! -e ${dev}$n ] && ln -s $(basename $dev)p$n ${dev}$n |
pascal@4025 | 30 done |
pascal@4025 | 31 |
pascal@4025 | 32 # Let's go |
pascal@4025 | 33 grub --device-map=/dev/null --batch <<EOT |
pascal@4025 | 34 device (hd0) $dev |
pascal@4025 | 35 geometry (hd0) $geometry |
pascal@4025 | 36 root (hd0,$grub_part) |
pascal@4025 | 37 setup (hd0) |
pascal@4025 | 38 quit |
pascal@4025 | 39 EOT |