Fixing an unbootable computer after a failed grub installation can be a bit tricky.
Here’s what I ended up doing.
First of all, boot the machine up and get access to the root partition:
Step 1. Get a Debian installation CD for the same architecture
The distro version doesn’t matter too much: a lenny CD will boot squeeze just fine.
Step 2.Boot the install CD and select Rescue mode under Advanced options.
Step 3. Answer the language, keyboard and network questions any way you want and provide the decryption passphrases for any of the encrypted partitions you need to mount.
Step 4.When prompted, request a shell on the root partition:
If you need to upgrade the version of the grub package
a) Make sure that the network interface is up (ifup eth0).
b) Make sure that /etc/resolv.conf has at least one nameserver line, otherwise add one.
c) Install the latest version using apt-get or dpkg.
Step 5.Now that you have the right grub version, run the following
Step 6.Finally, reboot.