I don’t have windows… but others do, with a linux dual boot, and I sometimes have to fix their computer after windows messes up the boot partition. So in prevision of the next time I have to do it… This worked for me, on a computer that was using grub2.
It’s easier to run that before:
sudo su mkdir /media/foo
Here, it is
fdisk -l can help. At the same time, check the boot flag.
mount /dev/sda5 /media/foo mount --bind /dev /media/foo/dev mount --bind /proc /media/foo/proc mount --bind /sys /media/foo/sys mount --bind /dev/pts /media/foo/dev/pts chroot /media/foo
Then leave chroot (ctrl-d)
grub-install --root-directory=/media/foo /dev/sda