diff -ur grub-0.97/util/grub-install.in grub-0.97.raid/util/grub-install.in
--- grub-0.97/util/grub-install.in	2008-04-30 22:42:03.000000000 +0200
+++ grub-0.97.raid/util/grub-install.in	2008-04-30 22:46:45.000000000 +0200
@@ -137,106 +137,12 @@
 	exit 1
     fi
 
-    # Break the device name into the disk part and the partition part.
-    case "$host_os" in
-    linux*)
 	# Find an actual physical device if we're passed a RAID device
 	case $1 in
-		/dev/md*)  set -- `getraid_mdadm $1`
+		/dev/md* | /dev/md/*)  set -- `getraid_mdadm $1`
 	esac
-	tmp_disk=`echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
-				  -e 's%\(d[0-9]*\)p[0-9]*$%\1%' \
-				  -e 's%\(fd[0-9]*\)$%\1%' \
-				  -e 's%/part[0-9]*$%/disc%' \
-				  -e 's%\(c[0-7]d[0-9]*\).*$%\1%' \
-				  -e 's%\(e[0-9]\.[0-9]*\).*$%\1%'`
-	tmp_part=`echo "$1" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \
-				  -e 's%.*d[0-9]*p%%' \
-				  -e 's%.*/fd[0-9]*$%%' \
-				  -e 's%.*/floppy/[0-9]*$%%' \
-				  -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \
-				  -e 's%.*c[0-7]d[0-9]*p*%%' \
-				  -e 's%.*e[0-9]\.[0-9]*p%%' \
-				  -e 's%.*e[0-9]\.[0-9]*\$%%'`
-	;;
-    gnu*)
-	tmp_disk=`echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%'`
-	tmp_part=`echo "$1" | sed "s%$tmp_disk%%"` ;;
-    freebsd* | kfreebsd*-gnu)
-	tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%\1%' \
-			    | sed 's%r\{0,1\}\(da[0-9]*\).*$%\1%'`
-	tmp_part=`echo "$1" \
-	    | sed "s%.*/r\{0,1\}[saw]d[0-9]\(s[0-9]*[a-h]\)%\1%" \
-       	    | sed "s%.*/r\{0,1\}da[0-9]\(s[0-9]*[a-h]\)%\1%"`
-	;;
-    netbsd* | knetbsd*-gnu)
-	tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([sw]d[0-9]*\).*$%r\1d%' \
-	    | sed 's%r\{0,1\}\(fd[0-9]*\).*$%r\1a%'`
-	tmp_part=`echo "$1" \
-	    | sed "s%.*/r\{0,1\}[sw]d[0-9]\([abe-p]\)%\1%"`
-	;;
-    *)
-	echo "grub-install does not support your OS yet." 1>&2
-	exit 1 ;;
-    esac
 
-    # Get the drive name.
-    tmp_drive=`grep -v '^#' $device_map | grep "$tmp_disk *$" \
-	| sed 's%.*\(([hf]d[0-9][a-z0-9,]*)\).*%\1%'`
-
-    # If not found, print an error message and exit.
-    if test "x$tmp_drive" = x; then
-	echo "$1 does not have any corresponding BIOS drive." 1>&2
-	exit 1
-    fi
-
-    if test "x$tmp_part" != x; then
-	# If a partition is specified, we need to translate it into the
-	# GRUB's syntax.
-	case "$host_os" in
-	linux*)
-	    echo "$tmp_drive" | sed "s%)$%,`expr $tmp_part - 1`)%" ;;
-	gnu*)
-	    if echo $tmp_part | grep "^s" >/dev/null; then
-		tmp_pc_slice=`echo $tmp_part \
-		    | sed "s%s\([0-9]*\)[a-z]*$%\1%"`
-		tmp_drive=`echo "$tmp_drive" \
-		    | sed "s%)%,\`expr "$tmp_pc_slice" - 1\`)%"`
-	    fi
-	    if echo $tmp_part | grep "[a-z]$" >/dev/null; then
-		tmp_bsd_partition=`echo "$tmp_part" \
-		    | sed "s%[^a-z]*\([a-z]\)$%\1%"`
-		tmp_drive=`echo "$tmp_drive" \
-		    | sed "s%)%,$tmp_bsd_partition)%"`
-	    fi
-	    echo "$tmp_drive" ;;
-	freebsd* | kfreebsd*-gnu)
-	    if echo $tmp_part | grep "^s" >/dev/null; then
-		tmp_pc_slice=`echo $tmp_part \
-		    | sed "s%s\([0-9]*\)[a-h]*$%\1%"`
-		tmp_drive=`echo "$tmp_drive" \
-		    | sed "s%)%,\`expr "$tmp_pc_slice" - 1\`)%"`
-	    fi
-	    if echo $tmp_part | grep "[a-h]$" >/dev/null; then
-		tmp_bsd_partition=`echo "$tmp_part" \
-		    | sed "s%s\{0,1\}[0-9]*\([a-h]\)$%\1%"`
-		tmp_drive=`echo "$tmp_drive" \
-		    | sed "s%)%,$tmp_bsd_partition)%"`
-	    fi
-	    echo "$tmp_drive" ;;
-	netbsd* | knetbsd*-gnu)
-	    if echo $tmp_part | grep "^[abe-p]$" >/dev/null; then
-		tmp_bsd_partition=`echo "$tmp_part" \
-		    | sed "s%\([a-p]\)$%\1%"`
-		tmp_drive=`echo "$tmp_drive" \
-		    | sed "s%)%,$tmp_bsd_partition)%"`
-	    fi
-	    echo "$tmp_drive" ;;
-	esac
-    else
-	# If no partition is specified, just print the drive name.
-	echo "$tmp_drive"
-    fi
+	GRUB_LEGACY_0_BASED_PARTITIONS=1 grub-probe --device-map=${device_map} -t drive -d "$1"
 }
 
 # Usage: resolve_symlink file
@@ -265,9 +171,7 @@
 # Usage: find_device file
 # Find block device on which the file resides.
 find_device () {
-    # For now, this uses the program `df' to get the device name, but is
-    # this really portable?
-    tmp_fname=`df $1/ | sed -n 's%.*\(/dev/[^ 	]*\).*%\1%p'`
+    tmp_fname=`grub-probe --device-map=${device_map} -t device $1/`
 
     if test -z "$tmp_fname"; then
 	echo "Could not find device for $1" 2>&1
diff -ur grub-0.97/util/grub-install.in grub-0.97.new/util/grub-install.in
--- grub-0.97/util/grub-install.in	2008-07-23 01:14:29.000000000 +0200
+++ grub-0.97.new/util/grub-install.in	2008-07-23 01:16:46.000000000 +0200
@@ -288,22 +288,7 @@
 if test -f "$device_map"; then
     :
 else
-    # Create a safe temporary file.
-    test -n "$mklog" && log_file=`$mklog`
-
-    # Before all invocations of the grub shell, call sync to make sure
-    # the raw device is in sync with any bufferring in filesystems.
-    sync
- 
-    $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
-quit
-EOF
-    if grep "Error [0-9]*: " $log_file >/dev/null; then
-	cat $log_file 1>&2
-	exit 1
-    fi
-
-    rm -f $log_file
+    grub-mkdevicemap $no_floppy --device-map=$device_map
 fi
 
 # Make sure that there is no duplicated entry.

