When GRUB fails and your system won’t boot, the errors can be intimidating. But fixing it with a live CD is straightforward.
Boot from an Ubuntu live CD or USB. Once the desktop loads, open a terminal.
First, mount your root partition:
sudo mkdir /mnt/newroot
sudo mount /dev/sdxy /mnt/newroot
Bind the virtual filesystems:
sudo mount --bind /dev /mnt/newroot/dev
sudo mount --bind /proc /mnt/newroot/proc
sudo mount --bind /sys /mnt/newroot/sys
Chroot into your system:
sudo chroot /mnt/newroot
Reinstall GRUB:
sudo grub-install /dev/sdx
sudo update-grub
Exit the chroot, unmount everything, and reboot. Remove the live CD when prompted.
For UEFI systems, the command changes slightly:
sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi
If you can still reach a grub rescue prompt, try booting manually:
set root=(hd0,msdos1)
set prefix=(hd0,msdos1)/boot/grub
insmod normal
normal
Enjoy!