All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: [PATCH] boot from LVM / RAID
Date: Fri, 6 Jun 2008 18:09:46 +0200	[thread overview]
Message-ID: <20080606160946.GA13716@thorin> (raw)

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

             reply	other threads:[~2008-06-06 16:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-06 16:09 Robert Millan [this message]
2008-06-15 18:22 ` [PATCH] boot from LVM / RAID 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080606160946.GA13716@thorin \
    --to=rmh@aybabtu.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.