[packages/grub2] Rel 4; try to fix: "disk `md0' not found" on grub-install
arekm
arekm at pld-linux.org
Thu Mar 26 23:43:29 CET 2026
commit 9412555edd4994052ad2688e747780d66f4d6ac1
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Mar 26 23:43:00 2026 +0100
Rel 4; try to fix: "disk `md0' not found" on grub-install
grub2.spec | 6 +++---
md-name.patch | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 3 deletions(-)
---
diff --git a/grub2.spec b/grub2.spec
index 57a8a00..36009c0 100644
--- a/grub2.spec
+++ b/grub2.spec
@@ -144,7 +144,7 @@ Summary(pl.UTF-8): GRUB2 - bootloader dla x86 i ppc
Summary(pt_BR.UTF-8): Gerenciador de inicialização GRUB2
Name: grub2
Version: 2.14
-Release: 3
+Release: 4
License: GPL v2
Group: Base
Source0: https://ftp.gnu.org/gnu/grub/grub-%{version}.tar.xz
@@ -166,7 +166,7 @@ Patch10: ignore-kernel-symlinks.patch
Patch11: choose-preferred-initrd.patch
Patch12: %{name}-cfg.patch
Patch13: image-base.patch
-
+Patch14: md-name.patch
Patch15: x32.patch
URL: http://www.gnu.org/software/grub/
BuildRequires: autoconf >= 2.64
@@ -540,7 +540,7 @@ Motyw starfield dla GRUB-a.
%patch -P11 -p1
%patch -P12 -p0
%patch -P13 -p1
-
+%patch -P14 -p1
%patch -P15 -p1
# we don't have C.utf-8 and need an UTF-8 locale for build
diff --git a/md-name.patch b/md-name.patch
new file mode 100644
index 0000000..c5869da
--- /dev/null
+++ b/md-name.patch
@@ -0,0 +1,61 @@
+ diskfilter: Fix md RAID device naming for numeric arrays
+
+ grub-install fails with 'disk `md0' not found' on mdraid1x arrays with
+ numeric names (the common case for /dev/md0, /dev/md1, etc.).
+
+ Two subsystems must agree on GRUB device names for md arrays:
+
+ - grub_util_get_raid_grub_dev() translates OS device paths to GRUB
+ names: /dev/md0 and /dev/md/0 both produce "md0", while
+ /dev/md/boot produces "md/boot".
+
+ - grub_diskfilter_make_raid() constructs the internal array name from
+ on-disk superblock metadata. It unconditionally prepends "md/" to
+ the identifier, producing "md/0" for a RAID 1.x array whose
+ set_name is "hostname:0" (after homehost stripping).
+
+ The mismatch ("md0" vs "md/0") is normally masked by UUID-based lookup
+ (mduuid/...) when mdadm is available. When mdadm is unavailable --
+ common in chroot and rescue environments -- the name-based fallback
+ path is taken and the mismatch causes the failure.
+
+ Fix grub_diskfilter_make_raid() to choose "md<N>" for numeric names and
+ "md/<name>" for free-form names, matching grub_util_get_raid_grub_dev().
+
+ Also fix grub_mdraid_detect() for RAID 0.9x which passed "md0" (already
+ prefixed) to grub_diskfilter_make_raid(), producing "md/md0". Pass just
+ the minor number so the callee applies the prefix consistently.
+
+ Bug: https://savannah.gnu.org/bugs/?67868
+
+diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c
+index 3a26de6..de24958 100644
+--- a/grub-core/disk/diskfilter.c
++++ b/grub-core/disk/diskfilter.c
+@@ -1131,8 +1131,11 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
+ {
+ /* Strip off the homehost if present. */
+ char *colon = grub_strchr (name, ':');
+- char *new_name = grub_xasprintf ("md/%s",
+- colon ? colon + 1 : name);
++ const char *base = colon ? colon + 1 : name;
++ /* Use "md<N>" for numeric names and "md/<name>" for free-form names,
++ matching the convention in grub_util_get_raid_grub_dev(). */
++ char *new_name = grub_xasprintf (base[0] >= '0' && base[0] <= '9'
++ ? "md%s" : "md/%s", base);
+
+ if (! new_name)
+ goto fail;
+diff --git a/grub-core/disk/mdraid_linux.c b/grub-core/disk/mdraid_linux.c
+index e40216f..e003f6d 100644
+--- a/grub-core/disk/mdraid_linux.c
++++ b/grub-core/disk/mdraid_linux.c
+@@ -252,7 +252,7 @@ grub_mdraid_detect (grub_disk_t disk,
+ id->id = grub_md_to_cpu32 (sb->this_disk.number);
+
+ char buf[32];
+- grub_snprintf (buf, sizeof (buf), "md%d", grub_md_to_cpu32 (sb->md_minor));
++ grub_snprintf (buf, sizeof (buf), "%d", grub_md_to_cpu32 (sb->md_minor));
+ ret = grub_diskfilter_make_raid (16, (char *) uuid,
+ grub_md_to_cpu32 (sb->raid_disks), buf,
+ (sb->size) ? ((grub_disk_addr_t)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/grub2.git/commitdiff/9412555edd4994052ad2688e747780d66f4d6ac1
More information about the pld-cvs-commit
mailing list