Skip to contentSkip to conversation

patch for partmap probing on RAID/LVM

DISCUSSION Sam Morris 3 participants 5 messages May 28, 2007 – Jun 17, 2007

lore
Share & tools
lore

Sam Morris

author
#0 lore raw

Here's the beginning of a patch for grub-probe itself to make it handle RAID/LVM more intelligently. This will work for the most common use-cases; the comments describe an idea to make the probing process recursive to handle more interesting situations such as LVM-on-RAID.

diff --git a/util/grub-probe.c b/util/grub-probe.c index 29d0d0a..8e10986 100644
--- a/util/grub-probe.c
+++ b/util/grub-probe.c
@@ -118,8 +118,36 @@ probe (const char *path)

if (print == PRINT_PARTMAP)
{
- if (dev->disk->partition == NULL)
- grub_util_error ("Cannot detect partition map for %s", drive_name);
+ if (dev->disk->partition == NULL) {
+ /* If the device does not have a partition map, it may still be a
+ RAID or LVM device. */
+ /* What happens for LVM-on-RAID, or RAID-on-LVM, or nested LVM?
+ Maybe this should be recursive, e.g.:
+
+ Where (md0) consists of two devices: a whole disk and a pc partition:
+ probe_partmap (md0)
+ probe_partmap (hd0) -> raid
+ probe_partmap (hd1,1) -> raid
+ probe_partmap (hd1) -> pc
+
+ Where (foo-bar) is an LVM Logical Volume on a RAID array on disks using
+ gpt partitions:
+ probe_partmap (foo-bar)
+ probe_partmap (md0) -> lvm
+ probe_partmap (hd0,1)
+ probe_partmap (hd0) -> gpt
+ probe_partmap (hd1,1)
+ probe_partmap (hd1) -> gpt
+ */
+ if (drive_name[0] == 'm' && drive_name[1] == 'd')
+ printf ("pc gpt raid\n");
+ else if (strchr (drive_name, '-') != NULL)
+ printf ("pc gpt lvm\n");
+ else
+ grub_util_error ("Cannot detect partition map for %s", drive_name);
+
+ goto end;
+ }

if (strcmp (dev->disk->partition->partmap->name, "amiga_partition_map") == 0)
printf ("amiga\n");

Signature · 5 lines
Sam Morris
http://robots.org.uk/

PGP key id 1024D/5EA01078
3412 EA18 1277 354B 991B  C869 B219 7FDB 5EA0 1078
#1 lore raw
Quoted 4 lines · Sam Morris

Here's the beginning of a patch for grub-probe itself to make it handle RAID/LVM more intelligently. This will work for the most common use-cases; the comments describe an idea to make the probing process recursive to handle more interesting situations such as LVM-on-RAID.

I assume this isn't complete or working yet.

By the way I don't think that LVM on LVM is actually supported by LVM itself,
and raid on LVM is an unlikely scenario.

Quoted 49 lines

diff --git a/util/grub-probe.c b/util/grub-probe.c index 29d0d0a..8e10986 100644
--- a/util/grub-probe.c
+++ b/util/grub-probe.c
@@ -118,8 +118,36 @@ probe (const char *path)

if (print == PRINT_PARTMAP)
{
- if (dev->disk->partition == NULL)
- grub_util_error ("Cannot detect partition map for %s", drive_name);
+ if (dev->disk->partition == NULL) {
+ /* If the device does not have a partition map, it may still be a
+ RAID or LVM device. */
+ /* What happens for LVM-on-RAID, or RAID-on-LVM, or nested LVM?
+ Maybe this should be recursive, e.g.:
+
+ Where (md0) consists of two devices: a whole disk and a pc partition:
+ probe_partmap (md0)
+ probe_partmap (hd0) -> raid
+ probe_partmap (hd1,1) -> raid
+ probe_partmap (hd1) -> pc
+
+ Where (foo-bar) is an LVM Logical Volume on a RAID array on disks using
+ gpt partitions:
+ probe_partmap (foo-bar)
+ probe_partmap (md0) -> lvm
+ probe_partmap (hd0,1)
+ probe_partmap (hd0) -> gpt
+ probe_partmap (hd1,1)
+ probe_partmap (hd1) -> gpt
+ */
+ if (drive_name[0] == 'm' && drive_name[1] == 'd')
+ printf ("pc gpt raid\n");
+ else if (strchr (drive_name, '-') != NULL)
+ printf ("pc gpt lvm\n");
+ else
+ grub_util_error ("Cannot detect partition map for %s", drive_name);
+
+ goto end;
+ }

if (strcmp (dev->disk->partition->partmap->name, "amiga_partition_map") == 0)
printf ("amiga\n");

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Daniel Reurich

Centurion Computer Technology (2005) Limited.
Ph: 021 797 722
author
#2 lore raw
Quoted 7 lines · On Tue, 29 May 2007 14:37:02 +1200, Centurion Computer Technology (2005) Ltd…
Quoted 4 lines · Sam Morris

Here's the beginning of a patch for grub-probe itself to make it handle RAID/LVM more intelligently. This will work for the most common use-cases; the comments describe an idea to make the probing process recursive to handle more interesting situations such as LVM-on-RAID.

I assume this isn't complete or working yet.

Well, it works well enough for me at the moment, but it's not complete. _How_ complete it will get depends on how thoroughly you want grub to search for possible partition maps, lvm and raid layouts, etc...

Quoted 2 lines

By the way I don't think that LVM on LVM is actually supported by LVM itself, and raid on LVM is an unlikely scenario.

Fair enough--LVM on raid is pretty common though, well I have a few systems that use it at least. Of course, they all have a separate filesystem for /boot that is on RAID-1, so that grub-legacy can boot them. :)

Signature · 5 lines
Sam Morris
http://robots.org.uk/

PGP key id 1024D/5EA01078
3412 EA18 1277 354B 991B  C869 B219 7FDB 5EA0 1078
#3 lore raw
Quoted 9 lines · Sam Morris
Quoted 6 lines · On Tue, 29 May 2007 14:37:02 +1200, Centurion Computer Technology (2005) Ltd…
Quoted 4 lines · Sam Morris

Here's the beginning of a patch for grub-probe itself to make it handle RAID/LVM more intelligently. This will work for the most common use-cases; the comments describe an idea to make the probing process recursive to handle more interesting situations such as LVM-on-RAID.

Quoted 5 lines
Quoted 1 line

I assume this isn't complete or working yet.

Well, it works well enough for me at the moment, but it's not complete. _How_ complete it will get depends on how thoroughly you want grub to search for possible partition maps, lvm and raid layouts, etc...

I patched built and installed the debian package however I still couldn't get it to detect the raided disks. Are there other files that need to be patched as well??

Signature · 4 lines
Daniel Reurich

Centurion Computer Technology (2005) Limited.
Ph: 021 797 722
#4 lore raw
In reply to Sam Morris

Sorry for the late reply ;-). Let's see if we can revive this issue..

Quoted 4 lines · Sam Morris

+ if (drive_name[0] == 'm' && drive_name[1] == 'd')
+ printf ("pc gpt raid\n");
+ else if (strchr (drive_name, '-') != NULL)
+ printf ("pc gpt lvm\n");

The point of probing for the partition table is to determine which module we need to access it. This "pc gpt" is just a guess, and doesn't give you any garantee that you will be able to access your partitions. Besides, even if it does we're needlessly loading an additional module that we probably don't need (either pc or gpt).

Don't get me wrong, I don't think it's completely unreasonable to fallback to "pc gpt" (at least, not for debian), but if we do this grub-probe doesn't seem like the right place to do it. If it can't detect something, IMHO it should exit with error. Then grub-install can be tollerant to this and have that "pc gpt" fallback (untill the problem is fixed properly).

OTOH, your check that we need raid or lvm modules seems useful, it just happens to be unrelated to the partmap stuff. Can you isolate it? (for example, we could have "grub-probe -t <some_generic_word_matching_raid_and_lvm>").

Then maybe grub-install could do something like:

partmap=grub-probe -t partmap || echo pc gpt
something=grub-probe -t something || true

modules="..... $partmap $something ...."

Ah, and this strchr (drive_name, '-') seems too generic. Maybe it could catch some other unwanted paths? Can it be narrowed?

Signature · 4 lines
Robert Millan

My spam trap is [email protected].  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.