From: Felix Zielcke <fzielcke@z-51.de>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: grub2 (1.97.1) on RAID0
Date: Thu, 12 Nov 2009 15:32:49 +0100 [thread overview]
Message-ID: <1258036369.4591.2.camel@fz.local> (raw)
In-Reply-To: <4AFBF433.9@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 858 bytes --]
Am Donnerstag, den 12.11.2009, 12:40 +0100 schrieb André Fettouhi:
> That sucks big time! <Sad>
>
> info@dupondje.be skrev:
> > To bad :)
> > Its not possible to use dmraid with Grub2 yet.
> >
> > I had to switch bad to grub1 because its not possible to get it working.
> > Hopefully some developper wants to implement this :)
> >
> > Sincerely,
> > Jean-Louis
> >
If you have some /dev/mapper/nvida_ pdc_ or isw_ device you can try
attached patch.
But it's a dirty way to implement it and not really tested.
I haven't checked it with recent releases but at the time I wrote it it
worked with my nvidia dmraid device.
isw_ devices seems to have different formats only one of them is
supported.
And pdc_ worked for Pavel but for someone else on IRC it didn't.
--
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer
[-- Attachment #2: dmraid.patch.5 --]
[-- Type: text/x-patch, Size: 5756 bytes --]
diff --git a/util/getroot.c b/util/getroot.c
index 120ab13..f1bfd4c 100644
--- a/util/getroot.c
+++ b/util/getroot.c
@@ -396,13 +396,38 @@ grub_guess_root_device (const char *dir)
return os_dev;
}
+int
+grub_util_is_dmraid (const char *os_dev)
+{
+ if (! strncmp (os_dev, "/dev/mapper/nvidia_", 19))
+ return 1;
+ else if (! strncmp (os_dev, "/dev/mapper/isw_", 16))
+ return 1;
+ else if (! strncmp (os_dev, "/dev/mapper/hpt37x_", 19))
+ return 1;
+ else if (! strncmp (os_dev, "/dev/mapper/hpt45x_", 19))
+ return 1;
+ else if (! strncmp (os_dev, "/dev/mapper/via_", 16))
+ return 1;
+ else if (! strncmp (os_dev, "/dev/mapper/lsi_", 16))
+ return 1;
+ else if (! strncmp (os_dev, "/dev/mapper/pdc_", 16))
+ return 1;
+ else if (! strncmp (os_dev, "/dev/mapper/jmicron_", 20))
+ return 1;
+ else if (! strncmp (os_dev, "/dev/mapper/asr_", 16))
+ return 1;
+ else if (! strncmp (os_dev, "/dev/mapper/sil_", 16))
+ return 1;
+ return 0;
+}
int
grub_util_get_dev_abstraction (const char *os_dev UNUSED)
{
#ifdef __linux__
/* Check for LVM. */
- if (!strncmp (os_dev, "/dev/mapper/", 12))
+ if (!strncmp (os_dev, "/dev/mapper/", 12) && ! grub_util_is_dmraid (os_dev))
return GRUB_DEV_ABSTRACTION_LVM;
/* Check for RAID. */
diff --git a/util/hostdisk.c b/util/hostdisk.c
index a06ecca..0d94ccd 100644
--- a/util/hostdisk.c
+++ b/util/hostdisk.c
@@ -25,6 +25,7 @@
#include <grub/util/misc.h>
#include <grub/util/hostdisk.h>
#include <grub/misc.h>
+#include <grub/file.h>
#include <stdio.h>
#include <stdlib.h>
@@ -819,6 +820,27 @@ convert_system_partition_to_system_disk (const char *os_dev)
p[4] = '\0';
return path;
}
+ /* If this is a Nvidia fake raid. */
+ if (strncmp ("mapper/nvidia_", p, 14) == 0 && p[22] >= '0' && p[22] <= '9')
+ {
+ p[sizeof ("mapper/nvidia_abcdefgh") - 1] = '\0';
+ return path;
+ }
+ if (strncmp ("mapper/pdc_", p, 11) == 0 && p[20] >= '0' && p[20] <= '9')
+ {
+ p[sizeof ("mapper/pdc_abcdefghi") - 1] = '\0';
+ return path;
+ }
+ if (strncmp ("mapper/isw_", p, 11) == 0 && p[29] >= '0' && p[29] <= '9')
+ {
+ p[sizeof ("mapper/isw_abcdefghij_Volume0") - 1] = '\0';
+ return path;
+ }
+ if (strncmp ("mapper/isw_", p, 11) == 0 && p[27] >= '0' && p[27] <= '9')
+ {
+ p[sizeof ("mapper/isw_abcdefghij_ARRAY") - 1] = '\0';
+ return path;
+ }
}
return path;
@@ -869,6 +891,10 @@ device_is_wholedisk (const char *os_dev)
if (os_dev[len - 1] < '0' || os_dev[len - 1] > '9')
return 1;
+ if (strncmp ("/dev/mapper/isw_", os_dev, 16) == 0 && os_dev[34] == '\0')
+ return 1;
+ if (strncmp ("/dev/mapper/isw_", os_dev, 16) == 0 && os_dev[32] == '\0')
+ return 1;
return 0;
}
#endif
@@ -935,7 +961,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
does not count the extended partition and missing primary
partitions. Use same method as on Linux here. */
{
- char *name;
+ char *name, *os_dev_uuid;
grub_disk_t disk;
int fd;
struct hd_geometry hdg;
@@ -985,7 +1011,44 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
return 0;
}
+ auto int find_partition_by_uuid (const char *name);
+ int find_partition_by_uuid (const char *name)
+ {
+ grub_device_t dev;
+
+ if (name[0] == 'f' && name[1] == 'd'
+ && name[2] >= '0' && name[2] <= '9')
+ return 0;
+
+ dev = grub_device_open (name);
+ if (dev)
+ {
+ grub_fs_t fs;
+
+ fs = grub_fs_probe (dev);
+
+ if (fs && fs->uuid)
+ {
+ char *uuid, *p;
+
+ (fs->uuid) (dev, &uuid);
+ if (grub_errno == GRUB_ERR_NONE && uuid)
+ {
+ if (grub_strcasecmp (uuid, os_dev_uuid) == 0)
+ {
+ p = strchr (name, ',');
+ dos_part = atoi (p);
+ free (uuid);
+ return 1;
+ }
+ free (uuid);
+ }
+ }
+ grub_device_close (dev);
+ }
+ return 0;
+ }
name = make_device_name (drive, -1, -1);
if (MAJOR (st.st_rdev) == FLOPPY_MAJOR)
@@ -1015,28 +1078,60 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
if (hdg.start == 0 && device_is_wholedisk (os_dev))
return name;
- grub_util_info ("opening the device %s", name);
- disk = grub_disk_open (name);
- free (name);
-
- if (! disk)
- return 0;
- grub_partition_iterate (disk, find_partition);
- if (grub_errno != GRUB_ERR_NONE)
+ if (hdg.sectors == 0)
{
- grub_disk_close (disk);
- return 0;
+ FILE *fp;
+ char *free_ptr, *p, *q;
+ int len = 512;
+
+ p = xmalloc (strlen (os_dev) + strlen ("blkid ") + 1);
+ strcpy (p, "blkid ");
+ strcat (p, os_dev);
+ fp = popen (p, "r");
+ free (p);
+ do {
+ p = xmalloc (len);
+ p = fgets (p, len, fp);
+ if (! p)
+ return 0;
+ len *= 2;
+ } while (! strchr (p, '\n'));
+ free_ptr = p;
+ p = strstr (p , "UUID=");
+ if (! p)
+ return 0;
+ p += strlen ("UUID=\"");
+ q = strchr (p, '\"');
+ if (q)
+ *q = '\0';
+ os_dev_uuid = p;
+ pclose (fp);
+ grub_device_iterate (find_partition_by_uuid);
+ free (free_ptr);
}
-
- if (dos_part < 0)
+ else
{
- grub_disk_close (disk);
- grub_error (GRUB_ERR_BAD_DEVICE,
- "cannot find the partition of `%s'", os_dev);
- return 0;
- }
+ grub_util_info ("opening the device %s", name);
+ disk = grub_disk_open (name);
+ free (name);
+ if (! disk)
+ return 0;
+ grub_partition_iterate (disk, find_partition);
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_disk_close (disk);
+ return 0;
+ }
+ if (dos_part < 0)
+ {
+ grub_disk_close (disk);
+ grub_error (GRUB_ERR_BAD_DEVICE,
+ "cannot find the partition of `%s'", os_dev);
+ return 0;
+ }
+ }
return make_device_name (drive, dos_part, bsd_part);
}
prev parent reply other threads:[~2009-11-12 14:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-12 10:19 grub2 (1.97.1) on RAID0 André Fettouhi
2009-11-12 10:59 ` info
2009-11-12 11:40 ` André Fettouhi
2009-11-12 14:32 ` Felix Zielcke [this message]
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=1258036369.4591.2.camel@fz.local \
--to=fzielcke@z-51.de \
--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.