Le 13/07/2017 à 21:12, Jordan Uggla a écrit :
On Wed, Jul 12, 2017 at 9:09 AM, Hao Lee 
<[email protected]> wrote:

3. Attach the whole image to /dev/loop0 and attach the first partition
to /dev/loop1

sudo losetup /dev/loop0 hd.img

You're fine up to here.

sudo losetup -o $((2048*512)) /dev/loop1 hd.img

This is where your problem is. When you run grub-install it detects
two disks, /dev/loop0 and /dev/loop1 where /dev/loop0 appears to be a
partitioned disk with none of its partitions mounted and /dev/loop1
appears to be a disk without any partition table where the whole disk
is mounted to /mnt/.

Agreed.

Instead, you should run "sudo kpartx -a /dev/loop0" which will probe
the partition table of /dev/loop0 and add device nodes in /dev/mapper/
for each of the partitions found. In this case, it would create a
device node /dev/mapper/loop0p1 . When grub-probe looks at
/dev/mapper/loop0p1 it will be able to detect that it is a partition
of the disk /dev/loop0 and thus grub-install will configure things
appropriately.

I did not think that grub-install was able to detect that a /dev/mapper device was actually a partition of another device.

An alternative method is to make the kernel aware that the loop device is partitioned by loading the loop module with the max_part= option or adding the -P/--partscan option to losetup.

That is because grub-install detected that /boot/grub/ was on a "disk"
with no partition table, and thus didn't include the part_msdos module
in the core.img. Again, the solution to that problem is described
above.

Or one could force grub-install to include the part_msdos module in the core image with the --modules=part_msdos option.

_______________________________________________
Help-grub mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-grub

Reply via email to