help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grub2 fails to detect partitions if it was installed into file


From: Pascal Hambourg
Subject: Re: grub2 fails to detect partitions if it was installed into file
Date: Thu, 19 Jul 2018 00:02:28 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Le 18/07/2018 à 13:20, Sergey Naumov a écrit :

I just had to use "losetup --partscan" instead of mounting the main
partition manually, as with my method there is no information about
partition size. Anyway, thanks a lot for part_msdos, it helped!

Using losetup -o like you did previously, the loop device end was the end of the whole image file instead of the end of the partition. You should have set the right size in losetup with the option --sizelimit or in mkfs.ext4. Otherwise the filesystem extended to the end of the image file, beyond the partition boundaries.

Regarding the need to force inclusion of part_msdos in the GRUB core image, it seems that grub-install does not detect that loop0p1 is a partition of loop0, so it does not consider that this driver is useful.

2018-07-18 12:26 GMT+03:00 Sergey Naumov <address@hidden>:

Thanks, Pascal, that helped a bit.

But now there is another problem:
error: attempt to read or write outside of partition.

So grub see partition and its content, it can even load some modules from
(hd0,msdos1)/boot/grub/i386-pc.

But when I'm trying to load some other modules, like "normal", I see this
error:
grub rescue> ls
(hd0) (hd0,msdos2) (hd0,msdos1)
grub rescue> ls (hd0,msdos1)/boot/grub
./ ../ gfxblacklist.txt unicode.pf2 i386-pc/ locale/ fonts/ grubenv
grub.cfg
grub rescue> set root=(hd0,msdos1)
grub rescue> set prefix=(hd0,msdos1)/boot/grub
grub rescue> insmod normal
error: attempt to read or write outside of partition.

What is also interesting, if I use --modules=part_msdos,ext2 instead of
--modules=part_msdos, then grub tries to load a system, but neither
succeeds nor emits rescue shell - it just hangs.

As to your question - I used "losetup -o 1M -f image.img" to create loop
device that I can format with mkfs.ext4.

Thanks,
Sergey.


2018-07-17 21:12 GMT+03:00 Pascal Hambourg <address@hidden>:

Hello,

Le 17/07/2018 à 18:09, Sergey Naumov a écrit :


I'm trying to prepare an image that I can dd into disk or boot using PXE,
so I install basic system + kernel + grub-pc into directory, then create
an
image file, partition it using sfdisk, mount main partiton (ext4), copy
content of the rootfs into it, and then run grub-install and update-grub
under chroot.

Everything seems OK, grub.cfg detected kernel and initramfs installed
into
created image, but when I try to boot this image either on real system or
using kvm, grub2 can't find device partitions. What could be a reason of
it?

I posted the question with more detailed explanation here:
https://serverfault.com/questions/922319/grub2-fails-to-dete
ct-partitions-if-it-was-installed-into-file


You really could have copied all the relevant information in your post to
the list, so subscribers do not have to fetch them on the web.

How did you make the ext4 partition in the image appear as a block device
so that it can be mounted ?

AFAIK, GRUB looking for the filesystem containing /boot/grub by UUID
means that grub-install believes that it is on a different drive from the
boot+core image. So maybe grub-install did not care to embed the MSDOS
partition table driver into the core image. You can try to force it with

grub-install --modules=part_msdos <other parameters>



_______________________________________________
Help-grub mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-grub




reply via email to

[Prev in Thread] Current Thread [Next in Thread]