---- Andrei Borzenkov <[email protected]> wrote: > В Fri, 26 Jun 2015 12:35:09 +0000 > <[email protected]> пишет: > > > > > ---- Andrei Borzenkov <[email protected]> wrote: > > > В Thu, 25 Jun 2015 17:20:23 +0000 > > > <[email protected]> пишет: > > > > > > > I have a 15GB image file partitioned using fdisk with a single MBR > > > > partition and containing an ext4 file system which contains my LFS > > > > system. I used kpartx on this to create /dev/loop0 and > > > > /dev/mapper/loop0p1. The file system in /dev/loop0p1 is mounted on > > > > /mnt. I am chrooted into /mnt > > > > > > How exactly? chroot must have at least /dev, /sys and /proc available > > > for device detection to work. > > > > > > > Thanks for the help. > > > > Following the LFS instructions, I create mountpoints before entering the > > chroot environment: > > > > mount -v --bind /dev /mnt/dev > > mount -vt devpts devpts /mnt/dev/pts -o gid=5,mode=620 > > mount -vt proc proc /mnt/proc > > mount -vt sysfs sysfs /mnt/sys > > mount -vt tmpfs tmpfs /mnt/run > > > > > > > where my LFS system resides. Grub in the LFS system was built with the > > > following (from LFS documentation): > > > > > > > > ./configure --prefix=/usr \ > > > > --sbindir=/sbin \ > > > > --sysconfdir=/etc \ > > > > --disable-grub-emu-usb \ > > > > --disable-efiemu \ > > > > --disable-werror > > > > > > > > Command used: > > > > grub-install --target=i386-pc /dev/loop0 > > > > > > > > > > I do not have environment to test chroot, but the following works > > > using current upstream master (sans two clean up patches): > > > > > > bor@opensuse:~> sudo losetup --find --show /tmp/floppy > > > /dev/loop0 > > > bor@opensuse:~> sudo kpartx -a /dev/loop0 > > > bor@opensuse:~> sudo mount /dev/mapper/loop0p2 /mnt > > > bor@opensuse:~/build/grub> ./configure ; make > > > bor@opensuse:~/build/grub> sudo pkgdatadir=$PWD ./grub-install -d > > > grub-core --boot-directory=/mnt /dev/loop0 > > > Installing for i386-pc platform. > > > Installation finished. No error reported. > > > bor@opensuse:~/build/grub> > > > > > > As Jordan suggested, you may be missing libdevmapper dependency. > > > > > > > > > > > It does not appear libdevmapper is a part of LFS. > > Then no kpartx would be possible at all. Where do you think /dev/mapper > devices come from? >
I think you misunderstood. kpartx is run from the host Debian system. It has the mapper but does not have grub. The LFS system has grub, but does not have libdevmapper. > I could be wrong, but I don't see it anywhere. > > > > I don't understand why grub-install needs to find the partition > > /dev/mapper/loop0p1 at all. Surely all it needs to do is install to the MBR > > of /dev/loop0 and the embedded space before the first partition. Why would > > it need anything other than the device name /dev/loop0 ? > > > > Because it needs to know which drivers are requires to access $prefix; > whether $prefix is on the same drive as primary boot sector; which > partition $prefix is in; etc etc etc > I'm not sure exactly what you are referring to with $prefix. Is there no way to manually tell grub that information, rather than have it try (unsuccessfully) to auto-detect it? There should always be a way to manually override any kind of auto-detection logic, IMHO. > > Assuming libdevmapper is not an option, how could I bypass grub-install, > > also assuming my /boot/grub directory is empty at start? > > Try partitioned loop - losetup -P ... I've never heard of that option. I will see if it works. > > > I know a bunch of files in /usr/lib/grub/i386-pc need to be copied to > > /boot/grub/i386-pc and LFS provides a simple grub.cfg. Beyond that I'm lost > > as to what arguments to grub-mkimage and grub-setup would allow me to build > > a core.img and apply it directly to /dev/loop0, to work around the problem. > > > > Thanks for the help. > > > > > > > > When that failed, I also tried a number of variations on this command, > > > > all of which also failed. I tried following examples on the net > > > > regarding creating a device.map and populating it with (hd0) /dev/loop0 > > > > Grub seems to read the file OK, but the install still fails. > > > > > > > > The host machine is a 64-bit install of Debian 8, although that > > > > shouldn't matter. > > > > > > > > If I do this on a real drive instead of a mounted image it works, but > > > > that doesn't help me. Shouldn't it be possible to install grub to a > > > > loopback device? > > > > > > > > Thanks in advance for any help. > > > > > > > > > > > > > > > > > > > > ---- Andrei Borzenkov <[email protected]> wrote: > > > > > Please, describe your configuration, and provide exact command you > > > > > used. Otherwise it is impossible to say anything. > > > > > > > > > > Отправлено с iPhone > > > > > > > > > > > 25 июня 2015 г., в 14:43, <[email protected]> > > > > > > <[email protected]> написал(а): > > > > > > > > > > > > I absolutely cannot get grub-install to do what I need it to do: > > > > > > Install to the MBR on a disk image that is loop mounted with > > > > > > kpartx, while chrooted into an ext4 filesystem on the first > > > > > > partition of that image. The image will be used on a BIOS machine > > > > > > but the physical host is EFI. > > > > > > > > > > > > This is for a linux from scratch 7.7 build and so uses the grub > > > > > > version found here: > > > > > > http://alpha.gnu.org/gnu/grub/grub-2.02~beta2.tar.xz > > > > > > > > > > > > I discovered the "target" argument to override the architecture by > > > > > > searching the web (it doesn't seem to be mentioned in any detail in > > > > > > the Grub manual), but I can't get it to install regardless. I get > > > > > > some nonsensical message about being unable to find 'lvm/loop0p1' > > > > > > although I am not using lvm in the image. The image only has a > > > > > > single MBR partition. > > > > > > > > > > > > This seems like it should be a simple thing to do and if it is I > > > > > > apologize, but I really hate it when software tries to be clever in > > > > > > an effort to 'help' and makes assumptions that turn a simple matter > > > > > > into a nightmare. > > > > > > > > > > > > _______________________________________________ > > > > > > Help-grub mailing list > > > > > > [email protected] > > > > > > https://lists.gnu.org/mailman/listinfo/help-grub > > > > > > > > > > _______________________________________________ Help-grub mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-grub
