How to restore grub after Windows installation

There's nothing magical about it, you can easily Google it up, but I always forget the "find /boot/grub..." part and there are many other ways people explain this procedure, so I'm adding a screenshot as I'm doing it yet another time.

This is a best and easiest way to fix MBR after Windows f*ck it up.

In short:
1. boot from Ubuntu live CD (or any other live cd)
2. start a terminal

sudo grub
find /boot/grub/stage1
root (hdX,Y)
setup (hdX)

If you've got several drives you should check if your Windows partition is bootable and the other ones are not, otherwise if you install grub into linux partition, Windows will "fix" itself by changing bootable flag. To view and change bootable flags in Ubuntu Live go to System > Administration > Partition Editor (or run sudo gparted in terminal). The rest is illustrated below.

If grub loads but boot fails, it means grub detected your partitions incorrectly. Hit 'e' on linux entry, change the "root (hd1,0)" to "root (hd0,0)" or vice versa and press 'b' to attempt a modified boot. Repeat the "sudo grub" procedure when booted, but choose "setup (hdX)" target the oposite of your "root", i.e., if you did "root (hd1,0)", do "setup (hd0)" instead of "setup (hd1)". You should also edit /boot/grub/menu.lst afterwards and change all (hd0 to (hd1 and (hd1 to (hd0 to fix the boot menu.

Does all software have to suck?..