All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: Future of installing GRUB to LVM volumes (and loop devices)
Date: Fri, 22 May 2015 05:25:52 +0300	[thread overview]
Message-ID: <20150522052552.4cd25056@opensuse.site> (raw)
In-Reply-To: <CAEaD8JN+wvk+a823CpLfxWpW2OAfyjPLP5wqXh=kT=6Wr4Osdw@mail.gmail.com>

В Fri, 22 May 2015 00:17:50 +0200
"Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com> пишет:

> Le 21 mai 2015 23:48, "Sebastian Pipping" <sebastian@pipping.org> a écrit :
> >
> > There is not device map and there was no need for one previously.
> > I'm happy to add that to the ticket, give me a second.
> >
> It worked only by lack of support for devmapper, not because it was
> designed so or because it's reasonable to. It was just a bug which happened
> to do what you wanted

The actual bug is that device.map does not work anymore for
device-mapper devices that LVM happens to be:

opensuse:/home/bor # grub2-install --boot-directory /tmp/x/boot /dev/mapper/vg-lv
Выполняется установка для платформы i386-pc.
grub2-install: ошибка: диск «lvmid/AxK0hm-Xmee-kRPP-dqU3-ycoo-EfcX-Vs3mk2/aot5OT-H8ZH-FXKe-Kz8e-gw6r-PI6v-9IdcGb» не найден.
opensuse:/home/bor # grub2-install --boot-directory /tmp/x/boot '(hd0)'
Выполняется установка для платформы i386-pc.
grub2-install: ошибка: диск «hd0» не найден.
opensuse:/home/bor # cat /tmp/x/boot/grub/device.map 
(hd0) /dev/mapper/vg-lv


This is fixed with patch below. And yes, with this patch it does not
require device.map which itself is a bug and should be fixed but it is
much more intrusive.

From: Andrei Borzenkov <arvidjaar@gmail.com>
Subject: [PATCH] check for abstraction in grub_util_get_devmapper_grub_dev

If user added device to device.map we should respect it.

---
 grub-core/osdep/devmapper/getroot.c | 33 ++++++++++++++++++++-------------
 grub-core/osdep/linux/getroot.c     |  2 +-
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c
index 0a77a04..f830f9c 100644
--- a/grub-core/osdep/devmapper/getroot.c
+++ b/grub-core/osdep/devmapper/getroot.c
@@ -224,11 +224,14 @@ grub_util_get_devmapper_grub_dev (const char *os_dev)
   uuid = get_dm_uuid (os_dev);
   if (!uuid)
     return NULL;
-  
-  if (strncmp (uuid, "LVM-", sizeof ("LVM-") - 1) == 0)
+
+  switch (grub_util_get_dev_abstraction (os_dev))
     {
+    case GRUB_DEV_ABSTRACTION_LVM:
+      {
 	unsigned i;
 	int dashes[] = { 0, 6, 10, 14, 18, 22, 26, 32, 38, 42, 46, 50, 54, 58};
+
 	grub_dev = xmalloc (grub_strlen (uuid) + 40);
 	optr = grub_stpcpy (grub_dev, "lvmid/");
 	for (i = 0; i < ARRAY_SIZE (dashes) - 1; i++)
@@ -246,19 +249,23 @@ grub_util_get_devmapper_grub_dev (const char *os_dev)
 	return grub_dev;
       }
 
-  if (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0)
-    {
-      char *dash;
-      dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-');
-      if (dash)
-	*dash = 0;
-      grub_dev = grub_xasprintf ("cryptouuid/%s",
-				 uuid + sizeof ("CRYPT-LUKS1-") - 1);
+    case GRUB_DEV_ABSTRACTION_LUKS:
+      {
+	char *dash;
+
+	dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-');
+	if (dash)
+	  *dash = 0;
+	grub_dev = grub_xasprintf ("cryptouuid/%s",
+				   uuid + sizeof ("CRYPT-LUKS1-") - 1);
+	grub_free (uuid);
+	return grub_dev;
+      }
+
+    default:
       grub_free (uuid);
-      return grub_dev;
+      return NULL;
     }
-  grub_free (uuid);
-  return NULL;
 }
 
 char *
diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
index a2e360f..bc79eaa 100644
--- a/grub-core/osdep/linux/getroot.c
+++ b/grub-core/osdep/linux/getroot.c
@@ -1075,7 +1075,7 @@ grub_util_get_grub_dev_os (const char *os_dev)
   switch (grub_util_get_dev_abstraction (os_dev))
     {
       /* Fallback for non-devmapper build. In devmapper-builds LVM is handled
-	 in rub_util_get_devmapper_grub_dev and this point isn't reached.
+	 in grub_util_get_devmapper_grub_dev and this point isn't reached.
        */
     case GRUB_DEV_ABSTRACTION_LVM:
       {
-- 
tg: (f4e62af..) u/devmapper-check-abstraction (depends on: master)


  parent reply	other threads:[~2015-05-22  2:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-05 16:54 Future of installing GRUB to LVM volumes (and loop devices) Sebastian Pipping
2015-05-05 17:38 ` Andrei Borzenkov
2015-05-06 12:30   ` Sebastian Pipping
2015-05-06 17:16     ` Andrei Borzenkov
2015-05-12 10:41       ` Sebastian Pipping
2015-05-12 11:41         ` Andrei Borzenkov
2015-05-15  9:28           ` Sebastian Pipping
2015-05-15  9:34             ` Andrei Borzenkov
2015-05-15 10:42               ` Sebastian Pipping
2015-05-16  3:47                 ` Jordan Uggla
2015-05-16 14:10                   ` Sebastian Pipping
2015-05-16 23:33                     ` Jordan Uggla
2015-05-17  8:14                 ` Andrei Borzenkov
2015-05-21 21:41                   ` Sebastian Pipping
2015-05-21 21:44                     ` Vladimir 'phcoder' Serbinenko
2015-05-21 21:48                       ` Sebastian Pipping
2015-05-21 22:17                         ` Vladimir 'phcoder' Serbinenko
2015-05-21 22:20                           ` Sebastian Pipping
2015-05-22  2:25                           ` Andrei Borzenkov [this message]
2015-05-07  9:35     ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-05-12  9:16       ` Sebastian Pipping

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=20150522052552.4cd25056@opensuse.site \
    --to=arvidjaar@gmail.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.