This patch makes it possible to boot directly from LVM or RAID.

It is archieved by permitting that grub_prefix include a drive component as
part of its path.  The kernel already knows how to extract root from there,
as long as `grub_install_dos_part == -2'.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What good is a phone call… if you are unable to speak?
(as seen on /.)
2008-06-06  Robert Millan  <[EMAIL PROTECTED]>

	Make boot directly from LVM or RAID possible.

	* kern/i386/pc/init.c (make_install_device): Remove memdisk check.
	It is assumed that if we have a memdisk, grub-mkimage has set
	grub_prefix to include the "(memdisk)" drive in it.

	* util/i386/pc/grub-install.in (prefix_drive): New variable.  If
	we need to include a drive in the prefix (because we're installing
	on LVM or RAID), it is set in this variable.
	Include ${grub_prefix} in `--prefix' parameter of ${grub_mkimage}
	invokation.

	* util/i386/pc/grub-mkimage.c (main): If a memdisk was requested,
	add "(memdisk)" drive explicitly to the beginning of the prefix.

	* util/i386/pc/grub-setup.c (setup): Don't write to `install_prefix',
	since it has been set by grub-mkimage based on request from
	grub-install, which knows better than anyone else which prefix we
	need.

diff -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/kern/i386/pc/init.c ./kern/i386/pc/init.c
--- ../grub2/kern/i386/pc/init.c	2008-04-07 16:34:46.000000000 +0200
+++ ./kern/i386/pc/init.c	2008-06-06 16:14:37.000000000 +0200
@@ -64,12 +64,7 @@ make_install_device (void)
   /* XXX: This should be enough.  */
   char dev[100];
 
-  if (grub_memdisk_image_size)
-    {
-      grub_sprintf (dev, "(memdisk)%s", grub_prefix);
-      grub_strcpy (grub_prefix, dev);
-    }
-  else if (grub_install_dos_part != -2)
+  if (grub_install_dos_part != -2)
     {
       /* If the root drive is not set explicitly, assume that it is identical
          to the boot drive.  */
diff -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/i386/pc/grub-install.in ./util/i386/pc/grub-install.in
--- ../grub2/util/i386/pc/grub-install.in	2008-06-06 17:49:43.000000000 +0200
+++ ./util/i386/pc/grub-install.in	2008-06-06 17:50:39.000000000 +0200
@@ -231,10 +231,18 @@ partmap_module=`$grub_probe --target=par
 # Device abstraction module, if any (lvm, raid).
 devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}`
 
+if [ "x${devabstraction_module}" = "x" ] ; then
+    prefix_drive=
+else
+    prefix_drive=`$grub_probe --target=drive --device ${grub_device}`
+fi
+
 # _chain is often useful
 modules="$modules $fs_module $partmap_module biosdisk $devabstraction_module _chain"
 
-$grub_mkimage --output=${grubdir}/core.img --prefix=`make_system_path_relative_to_its_root ${grubdir}`/ $modules || exit 1
+$grub_mkimage --output=${grubdir}/core.img \
+    --prefix=${prefix_drive}`make_system_path_relative_to_its_root ${grubdir}`/ \
+    $modules || exit 1
 
 # Now perform the installation.
 $grub_setup --directory=${grubdir} --device-map=${device_map} \
diff -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/i386/pc/grub-mkimage.c ./util/i386/pc/grub-mkimage.c
--- ../grub2/util/i386/pc/grub-mkimage.c	2008-01-21 16:48:27.000000000 +0100
+++ ./util/i386/pc/grub-mkimage.c	2008-06-06 12:36:57.000000000 +0200
@@ -278,6 +278,11 @@ main (int argc, char *argv[])
 	      free (memdisk);
 
 	    memdisk = xstrdup (optarg);
+	
+	    if (prefix)
+	      free (prefix);
+
+	    prefix = xstrdup ("(memdisk)/boot/grub");
 	    break;
 
 	  case 'h':
diff -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/i386/pc/grub-setup.c ./util/i386/pc/grub-setup.c
--- ../grub2/util/i386/pc/grub-setup.c	2008-05-06 15:34:29.000000000 +0200
+++ ./util/i386/pc/grub-setup.c	2008-06-06 17:52:00.000000000 +0200
@@ -330,7 +330,6 @@ setup (const char *prefix, const char *d
 		  grub_le_to_cpu32 (*install_dos_part),
 		  grub_le_to_cpu32 (*install_bsd_part),
 		  prefix);
-	  strcpy (install_prefix, prefix);
 	  
 	  /* Write the core image onto the disk.  */
 	  if (grub_disk_write (dest_dev->disk, embed_region.start, 0, core_size, core_img))
@@ -518,7 +517,6 @@ setup (const char *prefix, const char *d
 		  grub_le_to_cpu32 (*install_dos_part),
 		  grub_le_to_cpu32 (*install_bsd_part),
 		  prefix);
-  strcpy (install_prefix, prefix);
   
   /* Write the first two sectors of the core image onto the disk.  */
   core_path = grub_util_get_path (dir, core_file);
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to