All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] boot from LVM / RAID
@ 2008-06-06 16:09 Robert Millan
  2008-06-15 18:22 ` Robert Millan
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Millan @ 2008-06-06 16:09 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]


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 /.)

[-- Attachment #2: root_on_lvm.diff --]
[-- Type: text/x-diff, Size: 4178 bytes --]

2008-06-06  Robert Millan  <rmh@aybabtu.com>

	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);

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-06-22 17:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-06 16:09 [PATCH] boot from LVM / RAID Robert Millan
2008-06-15 18:22 ` Robert Millan
2008-06-15 21:33   ` new patch (boot from LVM / RAID) Robert Millan
2008-06-15 21:34     ` Robert Millan
2008-06-17 20:42       ` Robert Millan
2008-06-18 17:35         ` Robert Millan
2008-06-22 17:56         ` Guntsche Michael

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.