wok-6.x diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dmraid/stuff/grub-dmraid	Fri Sep 04 22:07:47 2009 +0200
     1.3 @@ -0,0 +1,36 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +grub_part=0
     1.7 +[ -n "$1" ] && case "$1" in
     1.8 +[0-9]*) grub_part=$1;;
     1.9 +*) cat 1>&2 <<EOT
    1.10 +Usage: $0 [partition]
    1.11 +Install grub on dmraid device. Default partition is 0.
    1.12 +EOT
    1.13 +  exit 2;;
    1.14 +esac
    1.15 +
    1.16 +# Get raid parameters
    1.17 +dev=/dev/mapper/$(dmraid -s 2> /dev/null | grep ^name | awk '{ print $3 }')
    1.18 +if [ "$dev" == "/dev/mapper/" ]; then
    1.19 +	echo "No dmraid device found." 1>&2
    1.20 +	exit 1
    1.21 +fi
    1.22 +
    1.23 +geometry="$(fdisk -l $dev | grep heads | sed \
    1.24 +'s|\(.*\) heads, \(.*\) sectors/track, \(.*\) cylinders|\3 \1 \2|')"
    1.25 +
    1.26 +# Grub bug workaround
    1.27 +for i in ${dev}p* ; do
    1.28 +  n=${i#${dev}p}
    1.29 +  [ -e $i -a ! -e ${dev}$n ] && ln -s $(basename $dev)p$n ${dev}$n 
    1.30 +done
    1.31 +
    1.32 +# Let's go
    1.33 +grub --device-map=/dev/null --batch <<EOT
    1.34 +device (hd0) $dev
    1.35 +geometry (hd0) $geometry
    1.36 +root (hd0,$grub_part)
    1.37 +setup (hd0)
    1.38 +quit
    1.39 +EOT