wok 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 ae53586561c8
children 84fc1b67b40b
files dmraid/receipt dmraid/stuff/grub-dmraid
line diff
     1.1 --- a/dmraid/receipt	Fri Sep 04 13:38:12 2009 +0200
     1.2 +++ b/dmraid/receipt	Fri Sep 04 22:07:47 2009 +0200
     1.3 @@ -28,5 +28,6 @@
     1.4  {
     1.5  	mkdir -p $fs/usr/sbin
     1.6  	cp -a $src/tools/dmraid $fs/usr/sbin
     1.7 +	cp -a stuff/grub-dmraid $fs/usr/sbin
     1.8  }
     1.9  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/dmraid/stuff/grub-dmraid	Fri Sep 04 22:07:47 2009 +0200
     2.3 @@ -0,0 +1,36 @@
     2.4 +#!/bin/sh
     2.5 +
     2.6 +grub_part=0
     2.7 +[ -n "$1" ] && case "$1" in
     2.8 +[0-9]*) grub_part=$1;;
     2.9 +*) cat 1>&2 <<EOT
    2.10 +Usage: $0 [partition]
    2.11 +Install grub on dmraid device. Default partition is 0.
    2.12 +EOT
    2.13 +  exit 2;;
    2.14 +esac
    2.15 +
    2.16 +# Get raid parameters
    2.17 +dev=/dev/mapper/$(dmraid -s 2> /dev/null | grep ^name | awk '{ print $3 }')
    2.18 +if [ "$dev" == "/dev/mapper/" ]; then
    2.19 +	echo "No dmraid device found." 1>&2
    2.20 +	exit 1
    2.21 +fi
    2.22 +
    2.23 +geometry="$(fdisk -l $dev | grep heads | sed \
    2.24 +'s|\(.*\) heads, \(.*\) sectors/track, \(.*\) cylinders|\3 \1 \2|')"
    2.25 +
    2.26 +# Grub bug workaround
    2.27 +for i in ${dev}p* ; do
    2.28 +  n=${i#${dev}p}
    2.29 +  [ -e $i -a ! -e ${dev}$n ] && ln -s $(basename $dev)p$n ${dev}$n 
    2.30 +done
    2.31 +
    2.32 +# Let's go
    2.33 +grub --device-map=/dev/null --batch <<EOT
    2.34 +device (hd0) $dev
    2.35 +geometry (hd0) $geometry
    2.36 +root (hd0,$grub_part)
    2.37 +setup (hd0)
    2.38 +quit
    2.39 +EOT