To install Grub2 from command line, you can just use:
# grub2-install /dev/sda
or, if you want to install to a VBR (partition boot sector):
# grub2-install --force /dev/sda2
Notice the use of the option **–force ** in this case. That’s because it is discouraged (and will stop working if core.img has moved). The setup default is wrong. It is an ‘opensusism’ for compatibility with Windows. But it has been wrong for so many years that it will never change. That’s just the way it is. On the other hand, it makes openSUSE the most Windows friendly Linux distro (see MS/Novell agreement for more info lol! ).
To reinstall from live CD or DVD rescue system in sda2, mount this partition in /mnt,
# mount /dev/sda2 /mnt
# grub2-install --force --boot-directory=/mnt/boot /dev/sda2
You should this the following (non fatal) error message:
/usr/sbin/grub2-bios-setup: warning: Embedding os not possible. GRUB can only be installed in this setup by using blocklists. **However, blocklists are UNRELIABLE and their use is discouraged**... Installation finished. No error reported.
I am with Grub devs on this. Don’t install Grub2 (only) in a partition bootsector if you have a better possibility. However you can install it in the partition bootsector as well. It cannot hurt. That’s what I always do.
And set the bootflag on sda2
# sfdisk -A2 /dev/sda
If you install the boot loader to MBR (sda), the bootflag is irrelevant.
Then write the boot menu with:
# grub2-mkconfig -o /mnt/boot/grub2/grub.cfg
I never needed to do this under openSUSE, but I did it a lot under Ubuntu, because - just like in your case - Grub installation failed during setup. So if it wasn’t a I/O error (DVD, DVD reader or HDD) or a bug in Perl bootloader, it could be that Grub2 - or whatever involved in the installation process (os-prober or Perl bootloader) failed to scan your partititions. In such a cas, it would exit before installing the boot loader (and probably activating the partition in your case) and you’ll end up with a system without Grub. In my case, unconventional Unix disklabels (openBSD+NetBSD+FreeBSD) caused the partitions scan to fail. Since then, everytime I install Linux on a computer with Unix partitions, I remove this partition entries from partition table and rewrite the partition table afterwards. I’m not happy with this but I got used to it (meaning that I haven’t needed to reinstall Grub2 as I just explained above for several years).
IMO, you should have blanked the first track before installing in BIOS mode after a failed attempt to install in UEFI mode. Maybe the left over GPT headers confused Grub2 or the Perl bootloader. It’s just a possible explanation though and not the only one.