From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Yvcey-0000S0-16 for mharc-grub-devel@gnu.org; Thu, 21 May 2015 22:26:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yvcev-0000Rn-1O for grub-devel@gnu.org; Thu, 21 May 2015 22:26:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yvcer-0007Ia-SL for grub-devel@gnu.org; Thu, 21 May 2015 22:26:00 -0400 Received: from mail-la0-x22e.google.com ([2a00:1450:4010:c03::22e]:36059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yvcer-0007IW-Fg for grub-devel@gnu.org; Thu, 21 May 2015 22:25:57 -0400 Received: by lagv1 with SMTP id v1so3304945lag.3 for ; Thu, 21 May 2015 19:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=dDA2spWKVVYtjzo23IRC3d+hJ7jxdZ1Qh7sH0fSgfm4=; b=yvUMXka/ie5qV0TTF3ukp5USf8HK8/JEox/+7VvxRHwry09gIm/Q/kAsAEruoLmnZU ii/zlm5EvMuZDg9QyJkfZSpzVy65qxtMrtQQSeH/rXSRDsJvZtV8oULvjjt1QxR+x4QF 5c/FUFd/svxRQ+uXqguQJbWWloQmgcSnCJ5OsvQ5619Sgox0jG+HxkeTPIEPauX302xl fWLrOTme3DkJOeIJ2cUKbVgpj8+/KFStTRtuEvSspRLaHVyyrTjskF63Z1EUwtIVeaAm Rr0/wFc7Y0ECZSOSYxWqEiqMnoW5cfpWYisL7GUG/5J/e3Xw2UR/qEhAd6P4HYtBA5RJ qbpw== X-Received: by 10.112.138.195 with SMTP id qs3mr4389648lbb.47.1432261556589; Thu, 21 May 2015 19:25:56 -0700 (PDT) Received: from opensuse.site (ppp91-76-14-38.pppoe.mtu-net.ru. [91.76.14.38]) by mx.google.com with ESMTPSA id f4sm149056lbd.49.2015.05.21.19.25.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 May 2015 19:25:55 -0700 (PDT) Date: Fri, 22 May 2015 05:25:52 +0300 From: Andrei Borzenkov To: The development of GRUB 2 Subject: Re: Future of installing GRUB to LVM volumes (and loop devices) Message-ID: <20150522052552.4cd25056@opensuse.site> In-Reply-To: References: <5548F5AB.4080305@pipping.org> <20150505203836.30e66cbc@opensuse.site> <554A0948.9050301@pipping.org> <20150506201645.492f1743@opensuse.site> <5551D8CF.8080905@pipping.org> <20150512144143.6f4713d0@opensuse.site> <5555BC53.9030308@pipping.org> <5555CD85.4050804@pipping.org> <20150517111440.3d550ffd@opensuse.site> <555E511C.6020202@pipping.org> <555E5295.7010504@pipping.org> X-Mailer: Claws Mail 3.11.0 (GTK+ 2.24.27; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22e X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2015 02:26:02 -0000 =D0=92 Fri, 22 May 2015 00:17:50 +0200 "Vladimir 'phcoder' Serbinenko" =D0=BF=D0=B8=D1=88=D0= =B5=D1=82: > Le 21 mai 2015 23:48, "Sebastian Pipping" a =C3= =A9crit : > > > > 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 happen= ed > 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 =D0=92=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D1=8F=D0=B5=D1=82=D1=81=D1=8F =D1=83= =D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B0 =D0=B4=D0=BB=D1=8F =D0=BF= =D0=BB=D0=B0=D1=82=D1=84=D0=BE=D1=80=D0=BC=D1=8B i386-pc. grub2-install: =D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0: =D0=B4=D0=B8=D1=81=D0= =BA =C2=ABlvmid/AxK0hm-Xmee-kRPP-dqU3-ycoo-EfcX-Vs3mk2/aot5OT-H8ZH-FXKe-Kz8= e-gw6r-PI6v-9IdcGb=C2=BB =D0=BD=D0=B5 =D0=BD=D0=B0=D0=B9=D0=B4=D0=B5=D0=BD. opensuse:/home/bor # grub2-install --boot-directory /tmp/x/boot '(hd0)' =D0=92=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D1=8F=D0=B5=D1=82=D1=81=D1=8F =D1=83= =D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B0 =D0=B4=D0=BB=D1=8F =D0=BF= =D0=BB=D0=B0=D1=82=D1=84=D0=BE=D1=80=D0=BC=D1=8B i386-pc. grub2-install: =D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0: =D0=B4=D0=B8=D1=81=D0= =BA =C2=ABhd0=C2=BB =D0=BD=D0=B5 =D0=BD=D0=B0=D0=B9=D0=B4=D0=B5=D0=BD. opensuse:/home/bor # cat /tmp/x/boot/grub/device.map=20 (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 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/devmappe= r/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 =3D get_dm_uuid (os_dev); if (!uuid) return NULL; - =20 - if (strncmp (uuid, "LVM-", sizeof ("LVM-") - 1) =3D=3D 0) + + switch (grub_util_get_dev_abstraction (os_dev)) { + case GRUB_DEV_ABSTRACTION_LVM: + { unsigned i; int dashes[] =3D { 0, 6, 10, 14, 18, 22, 26, 32, 38, 42, 46, 50, 54, 58}; + grub_dev =3D xmalloc (grub_strlen (uuid) + 40); optr =3D grub_stpcpy (grub_dev, "lvmid/"); for (i =3D 0; i < ARRAY_SIZE (dashes) - 1; i++) @@ -246,19 +249,23 @@ grub_util_get_devmapper_grub_dev (const char *os_dev) return grub_dev; } =20 - if (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) =3D=3D 0) - { - char *dash; - dash =3D grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-'); - if (dash) - *dash =3D 0; - grub_dev =3D grub_xasprintf ("cryptouuid/%s", - uuid + sizeof ("CRYPT-LUKS1-") - 1); + case GRUB_DEV_ABSTRACTION_LUKS: + { + char *dash; + + dash =3D grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-'); + if (dash) + *dash =3D 0; + grub_dev =3D 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; } =20 char * diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroo= t.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 hand= led - 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: { --=20 tg: (f4e62af..) u/devmapper-check-abstraction (depends on: master)