Skip to contentSkip to conversation

Problem with gnu-setup

DISCUSSION Yves BLUSSEAU 2 participants 2 messages Jun 27, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

i'm trying to install grub2 to a partition instead of the MBR (i known it's a bad idea, but i need to chainload grub2 from another bootloader). The problem is when i try to install the boot stages with grub-setup i have this error:

/usr/local/sbin/grub2-setup -v --force --directory=/tmp/mnt/boot/grub2 --device-map=/tmp/mnt/boot/grub2/device.map '(hd2,2)'

grub-setup: error: Cannot read `/tmp/mnt/boot/grub2/core.img' correctly

The problem came from line 405 of grub-setup.c
core_path_dev = grub_util_get_path (dir, core_file);

core_path_dev need to contain the path AND the device to the core file, but it's only a "concatenation" of dir and core_file.

In my case it contain /tmp/mnt/boot/grub2/core.img so when grub try to read the core image FROM grub it can't: grub_file_open return with an error because it don't know the device.

core_path_dev need to be (hd2,2)//tmp/mnt/boot/grub2/core.img in my case to work.

Can someone fix this bug ?

Another think i don't understand is that i don't see where the blocklists are saved because at this end of grub-setup.c (line 520):
fp = fopen (core_path, "r+b");
if (! fp)
grub_util_error ("Cannot open `%s'", core_path);

grub_util_write_image (core_img, GRUB_DISK_SECTOR_SIZE * 2, fp);

the core file is open in read mode so no datas can be written.

I hope that this can help you.

Yves Blusseau

#1 lore raw
Quoted 4 lines · Yves BLUSSEAU

Hi,

i'm trying to install grub2  to a partition instead of the MBR (i known it's a bad idea, but i need to chainload grub2 from another bootloader).

I would rather chainload other bootloader from grub2. If you use another bootloader because of a specific feature speak about it here perhaps someone will be interested to implement it in grub2

Quoted 15 lines

The problem is when i try to install the boot stages with grub-setup i have this error:

/usr/local/sbin/grub2-setup -v --force --directory=/tmp/mnt/boot/grub2 --device-map=/tmp/mnt/boot/grub2/device.map '(hd2,2)'

grub-setup: error: Cannot read `/tmp/mnt/boot/grub2/core.img' correctly

The problem came from line 405 of grub-setup.c core_path_dev = grub_util_get_path (dir, core_file);

core_path_dev need to contain the path AND the device to the core file, but it's only a "concatenation" of dir and core_file.

Quoted 8 lines

In my case it contain /tmp/mnt/boot/grub2/core.img so when grub try to read the core image FROM grub it can't: grub_file_open return with an error because it don't know the device.

core_path_dev need to be (hd2,2)//tmp/mnt/boot/grub2/core.img in my case to work.

Can someone fix this bug ?

use patch by Felix Zielcke

Quoted 21 lines

Another think i don't understand is that i don't see where the blocklists are saved because at this end of grub-setup.c (line 520):
 fp = fopen (core_path, "r+b");
 if (! fp)
  grub_util_error ("Cannot open `%s'", core_path);

 grub_util_write_image (core_img, GRUB_DISK_SECTOR_SIZE * 2, fp);

the core file is open in read mode so no datas can be written.

I hope that this can help you.

Yves Blusseau

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

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git