Failed to get canonical path of /cow

After booting from the Ubuntu live CD (tried 14.04 and 16.04) I was able to work around this problem by running update-grub chroot'ed to the grub partition. (Substitute /dev/sda1 below with whatever partition you installed grub on. All commands as root.)

mkdir /mnt/chrootdir
mount /dev/sda1 /mnt/chrootdir
for dir in proc dev sys etc bin sbin var usr lib lib64 tmp; do
    mkdir /mnt/chrootdir/$dir && mount --bind /$dir /mnt/chrootdir/$dir
done
chroot /mnt/chrootdir
grub-install /dev/sda # May not be required
update-grub2

Find your drive that's supposed to boot with

mount

Or

parted -l

Or

fdisk /dev/sda

And type p to list the partitions, look for type 83.

(If you've got Fedora you might have to use the commands "vgs" and "lvs" and if you've got mdraid you might have to "cat /proc/mdstat" or mdadm -A --scan or insmod raid1 or insmod raid5 and then mdadm -A --scan) and you will use /dev/md0 or /dev/mapper/my-vg instead of /dev/sda

then try mount it

mkdir /mnt
mount /dev/sda1 /mnt
cd /mnt
ls -l

Is this your drive? Cool!

grub-install --recheck --root-directory=/mnt /dev/sda 

(Or whichever /dev drive your root is, with it's mounted path)

grub-install --recheck --root-directory=/mnt /dev/sda --force

(Force it if it doesn't like your partitions.)

Now it should boot into grub, and you can use the grub commands to boot up, after rebooting and selecting the right boot drive from the BIOS Setup, or by pressing ESC or F12 depending on your BIOS and whether you are quick enough, then at the Grub prompt - you can use tab completion to find it if it's not (hd0,1) but (hd1,3) or something else instead, but beware, tab completion sometimes hangs for a few seconds if grub can't read the drive.

insmod linux
ls
root=(hd0,1)
linux /boot/vmlinuz root=/dev/sda1
initrd /boot/initrd
boot

Or, hopefully you've still got an intact grub.cfg file...

ls
ls (hd0,1)/
ls (hd0,1)/boot
configfile (hd0,1)/boot/grub.cfg

or maybe this will work:

grub-mkconfig -o /mnt/boot/grub/grub.cfg

Your paths may differ of course, so just play with these commands until you can see what's where and what's going on.

It might be a sign of imminent hard drive failure at worst, or at best maybe just a partition flag or boot file that got overwritten accidentally.


Revised solution based on code above

The solution from above will not work totally without problems because it mounts the boot partition into the / (root) of the file system. That makes grub complain that /boot does not exist, of course. This will fix that problem:

mkdir /mnt/chrootdir
mkdir /mnt/chrootdir/boot
mount /dev/sda1 /mnt/chrootdir/boot
for dir in proc dev sys etc bin sbin var usr lib lib64 tmp; do mkdir /mnt/chrootdir/$dir && mount --bind /$dir /mnt/chrootdir/$dir ; done
chroot /mnt/chrootdir
update-grub2  # inside chroot

As you see i also removed the line breaks so that it is easier to execute for everyone.

Another (simpler) solution

If you keep having problems getting it to work you should look to copy the /boot partition onto the / (root) partition. For that start your system with the Ubuntu live boot dvd and open the terminal. Inside it type:

sudo su
fdisk -l

To find out which partitions you have. In my case sda1 is my /boot partition which is about 250MB large and an sda5 which is about 500GB. I use these values in the commands below:

mkdir /mnt/boot/
mount /dev/sda1 /mnt/boot/

mkdir /mnt/root/
mount /dev/sda5 /mnt/root/

cp -R /mnt/boot/ /mnt/root/boot/

Set the bootable flag for the data partition and remove it for the boot partition:

fdisk /dev/sda
b -> 1 (unset the bootable flag for the first partition)
b -> 5 (set the bootable flag for the fifth partition)
w -> write changes to the MBR

Your computer will now look inside the sda5 for the boot files. Time to do the chrooting again, this time with some required folders needed for grub and which are generated by your Ubuntu live disc already:

mkdir /mnt/chrootdir/
mkdir /mnt/chrootdir/dev/
mkdir /mnt/chrootdir/proc/
mkdir /mnt/chrootdir/sys/

mount /dev/sda5 /mnt/chrootdir/
mount --bind /dev/ /mnt/chrootdir/dev/
mount --bind /proc/ /mnt/chrootdir/proc/
mount --bind /sys/ /mnt/chrootdir/sys/

chroot /mnt/chrootdir/

grub-install /dev/sda

Installation finished. No error reported.

If you do not see a message that the grub.cnf file is generated then also run the update command:

update-grub2 /dev/sda

Now you can safely reboot and see the well known boot menu appear again.

This solution was the only one which was working for me after migrating from a physical server to a virtual machine. I hope someone finds this useful!