I'm sure it happened to migrate a linux server, maybe in a slightly dirty way (rsync'ing) or had some issues with the boot loader. And when you reach the point with this:
grub rescue>
...and you start to cry (or almost) :-)
Well, here some steps that helped me to boot the server and restore grub.
Use ls to see the list of available partitions. Find the one where you know (or think) the kernel is installed. In my case it was (hd0,msdos1), which is basically /dev/sda1
After that, use the following:
grub rescue > set root=(hd0,msdos1)
grub rescue > set prefix=(hd0,msdos1)/boot/grub
grub rescue > insmod normal
grub rescue > insmod linux
grub rescue > linux /vmlinuz root=/dev/sda1 ro
grub rescue > initrd /initrd.img
grub rescue > boot
With these commands, I have been able to boot into my OS. After that, I re-installed grub:
update-grub
grub-install /dev/sda
NOTE: UUID could be a cause of failed boot too. Under Debian/Ubuntu there is a file
/etc/default/grubwhere you can disable the UUID format. This could generate some issues if you have swapped the disk so it might be good to check this config file and eventually enableGRUB_DISABLE_LINUX_UUID=trueand re run theupdate-grub. To remember as well, the UUID is set in/etc/fstab. You can replace that with/dev/sdXyaccordingly as well.
I hope this will help someone else that, like me, got stuck in restoring a VM.
Sources: