Comment 6 for bug 1487365

Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2015-09-08 22:10 EDT-------
It seems grub2 doesn't support RAID arrays of this sort (which it handles as 'diskfilter'), at least not for writing (which is required by grub-install).

It fails here, in grub-install.c:

if (write_to_disk (ins_dev, imgfile))
grub_util_error ("%s", _("failed to copy Grub to the PReP partition"));

write_to_disk() fails in

err = grub_disk_write (dev->disk, 0, 0,
core_size, core_img);

grub_disk_write() fails in

if ((disk->dev->write) (disk, transform_sector (disk, sector),
n, buf) != GRUB_ERR_NONE)
goto finish;

and disk->dev->write() fails in

return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"diskfilter writes are not supported");

That is also present upstream:
http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/disk/diskfilter.c#n908

That module (diskfilter.c) states in its heading:

/* diskfilter.c - module to read RAID arrays. */

So, to /read/ RAID arrays.. not /write/.

Here's a gdb session with a unstripped binary that I took from the package build and put in the installer's /target/usr/sbin/grub-install:

The pkg build path / binary (not stripped)
# file obj/grub-ieee1275/grub-install
obj/grub-ieee1275/grub-install: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=1b326c701ee38d75d8e8739062a79046eb5ddfad, not stripped

The gdb session:

# gdb
...
(gdb) file /usr/sbin/grub-install
Reading symbols from /usr/sbin/grub-install...done.
(gdb) b grub_disk_write
Breakpoint 1 at 0x1013660c: file ../../grub-core/lib/disk.c, line 61.
(gdb) run --force /dev/md0p1
Starting program: /usr/sbin/grub-install --force /dev/md0p1
...
Installing for powerpc-ieee1275 platform.
device node not found
device node not found
device node not found
device node not found
device node not found
device node not found
device node not found
device node not found
device node not found
device node not found

Breakpoint 1, grub_disk_write (disk=0x101e4a30, sector=0, offset=0,
size=96212, buf=0x10d99960) at ../../grub-core/lib/disk.c:61

(gdb) b transform_sector
Breakpoint 2 at 0x10134b00: transform_sector. (2 locations)
(gdb) c
Continuing.

Breakpoint 2, transform_sector (disk=0x101e4a30, sector=34)
at ../../grub-core/lib/../kern/disk_common.c:45
(gdb) s
46 in ../../grub-core/lib/../kern/disk_common.c

(gdb) s
grub_diskfilter_write (disk=0x101e4a30, sector=34, size=187,
buf=0x10d99960 "\177ELF\001\002\001")
at ../../grub-core/disk/diskfilter.c:821

(gdb) s
grub_error (n=GRUB_ERR_NOT_IMPLEMENTED_YET,
fmt=0x10194d10 "diskfilter writes are not supported")
at ../../grub-core/kern/err.c:41

(gdb) fin
Run till exit from #0 grub_error (n=GRUB_ERR_NOT_IMPLEMENTED_YET,
fmt=0x10194d10 "diskfilter writes are not supported")
at ../../grub-core/kern/err.c:41
0x0000000010159ffc in grub_diskfilter_write (disk=0x101e4a30, sector=34,
size=187, buf=0x10d99960 "\177ELF\001\002\001")
at ../../grub-core/disk/diskfilter.c:821

Value returned is $1 = GRUB_ERR_NOT_IMPLEMENTED_YET

(gdb) s
823 in ../../grub-core/disk/diskfilter.c
(gdb) s
grub_disk_write (disk=0x101e4a30, sector=34, offset=0, size=96212,
buf=0x10d99960) at ../../grub-core/lib/disk.c:135
(gdb) s
150 in ../../grub-core/lib/disk.c

(gdb) fin
Run till exit from #0 grub_disk_write (disk=0x101e4a30, sector=34, offset=0,
size=96212, buf=0x10d99960) at ../../grub-core/lib/disk.c:150
0x0000000010004c60 in write_to_disk (dev=0x10355fd0,
fn=0x101e80b0 "/boot/grub/powerpc-ieee1275/core.elf")
at ../../util/grub-install.c:704
Value returned is $2 = GRUB_ERR_NOT_IMPLEMENTED_YET

(gdb) fin
Run till exit from #0 0x0000000010004c60 in write_to_disk (dev=0x10355fd0,
fn=0x101e80b0 "/boot/grub/powerpc-ieee1275/core.elf")
at ../../util/grub-install.c:704
0x0000000010008684 in main (argc=3, argv=0x3ffffffffbd8)
at ../../util/grub-install.c:1824
1824 in ../../util/grub-install.c
Value returned is $3 = GRUB_ERR_NOT_IMPLEMENTED_YET

(gdb) s
1825 in ../../util/grub-install.c
(gdb) s
_ (str=0x10169f70 "failed to copy Grub to the PReP partition")
at ../../include/grub/i18n.h:56