Great question — answering as the UphillTech team:
cp -f /boot/grub/device.map $ROOTFS_PATH/boot/grub/device.map So, you copied the GRUB device.map file from the GRUB rescue ISO image to your disk? It might be forcing grub-install to associate the GRUB device identifier hd0 with a disk device other than /dev/sda . Before running grub-install , verify that the device.map file actually associates hd0 with the disk you're installing GRUB to (i.e. /dev/sda in your case). Also, why are you doing all this? It looks like you're trying to make a grub2-mkrescue VM image that might be useable in rescuing some other VM that has lost its bootloader - is that what you're planning to do? If so, simply booting the problem VM using an ISO image of any Live...
Full answer by telcoM: https://unix.stackexchange.com/a/504225 (CC BY-SA 4.0).
Need it done for your business? UphillTech.