I'm currently attempting to install GRUB on a disk image, for testing in QEMU. To generate the GRUB configuration file, you need to chroot into /mnt (as per this previous answer) and then run grub-mkconfig, as otherwise the command attempts to read your kernel image and initramfs from your real /boot.
I have attached my FAT32 filesystem to a loop device /dev/loop1, mounted it at /mnt and made the following further mounts:
- A bind of
/devto/mnt/dev - A bind of
/usrto/mnt/usr - A
sysfsat/mnt/sys - A
procfsat/mnt/proc
all without error. I have also created a directory /mnt/boot and /mnt/boot/grub, containing the kernel image and initramfs, and GRUB device map, respectively. However, when I attempt to run chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg to generate the configuration, it yields the cryptic error:
chroot: failed to run command `grub-mkconfig`: No such file or directory
This also happens when I replace grub-mkconfig with $(which grub-mkconfig), out of the possibility that PATH isn't exported correctly. I have verified that /mnt/usr/bin/grub-mkconfig does exist, due to the aforementioned bind mount.
When I attempt to simply run chroot /mnt, it tells me a similar message, this time with /usr/bin/bash, despite /mnt/usr/bin/bash also existing and /mnt/usr/lib and /mnt/usr/lib64 having the intended contents...
What have I done wrong here? Apologies if it's a trivial oversight.