Fixing grub errors after Ubuntu distribution upgrade

Written 2011-04-29 by Timo Dickscheid, tagged as computers, ubuntu

After running an Ubuntu distribution upgrade on a machine where the primary boot disk is not /dev/sda, but let's say /dev/sdb, you may experience the following grub error:

error: symbol not found: 'grub_env_export'

This happens because the grub-update is apparently run on the first disk by default. You'll need to reinstall grub using the correct partition by booting from a live disk, as explained in this post. In the live system, fire up a terminal and (assuming your desired boot partition is on /dev/sdb1) do

sudo mount /dev/sdb1 /mnt/sdb1
sudo mount -o bind /dev /mnt/sdb1/dev
sudo mount -o bind /sys /mnt/sdb1/sys
sudo mount -o bind /proc /mnt/sdb1/proc
sudo chroot /mnt/sdb1

This will make the boot partition your current root directory tree. Then reinstall grub there:

grub-install /dev/sdb
update-grub

Reboot the machine, and hope for the best - it worked for me when upgrading from Maverick to Natty.