How can I specify a different disk to be root in grub.cfg when running grub-mkconfig (from script/noninteractively)?

Yes, chroot will be fine, however, be sure that the system you chroot from fit to the system that you chroot into.

The chroot is used to move an operating system to a new disk without rebooting, installing an operating system, and other tasks that require installation of a new file system.

How to chroot with the correct mounts, correspond to the present system (Kernel) to a new file system. Install and setup GRUB 2 and possibly doing more tasks.

1) Mount your normal system partition. X is the drive letter. Y is the partition number:
sudo mount /dev/sdXY /mnt

2) If you are using a separate boot disk or partition, it must be mounted (where sdXY is the /boot partition designation):
sudo mount /dev/sdXY /mnt/boot

3) Mount the critical virtual filesystems (Kernel):
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done

4) Chroot into the new file system:
sudo chroot /mnt

5) Install GRUB 2 on the drive that the BIOS is set up to boot. If the drive is part of a RAID setup, repeat the command with all drive letters used in the array.
(Only specify a drive letter because the master boot record is installed in a very specific way):
grub-install /dev/sdX

6) Generate the GRUB 2 menu file (grub.cfg):
update-grub

7) Perform other tasks such as updates, install applications, configure, etc:
...

8) Exit chroot:
CTRL-D on the keyboard

https://help.ubuntu.com/community/Grub2/Installing#via_ChRoot

Tags:

Linux

Grub