How to fix the UUID in Grub after restore from another machine?

To solve your current problem, you'll have to change the UUID(s) in "/etc/fstab" and "/boot/grub/grub.cfg" (very tricky).

You can use Ubuntu install CD to get the UUID(s) with gparted (you just have to right click on the partition for which you want to get the UUID, and click on "Information", then select UUID and copy it with CTRL + C) or command line (sudo blkid).

Then you have to edit "/etc/fstab" on the right volume with gedit, nano or else.

In a terminal, type:

gksudo gedit /etc/fstab

and replace the old UUIDs by the new ones.

IMPORTANT : Of course, if you use a boot CD to do that you'll have to add "/media/xxxxx" before "/etc/fstab" : "/media/xxxxx/etc/fstab". You can also use gksudo gedit and open the file to edit yourself.

WARNING : Modifying "/boot/grub/grub.cfg" is very tricky. It should normally be generated with the command sudo update-grub.

Replace the old UUIDs by the new ones in "/boot/grub/grub.cfg" by entering the following in a terminal :

gksudo gedit /boot/grub/grub.cfg

IMPORTANT : Of course, if you use a boot CD to do that you'll have to add "/media/xxxxx" before "/boot/grub/grub.cfg" : "/media/xxxxx/boot/grub/grub.cfg". You can also use gksudo gedit and open the file to edit yourself.

If you use the tricky solution, I recommend you to launch sudo update-grub once you have successfully booted the system.

A cleaner but simple way to reconfigure grub properly may be using a boot repair disk like "Boot-Repair-Disk" : http://sourceforge.net/p/boot-repair-cd/home/Home/

I hope that this will help you to solve your problem.

However you might consider using Clonezilla to replicate the old computer on the new one as indicated in my comment.


Presumably this means grub starts and displays an option to boot to Ubuntu but when you select that it doesn't boot?

There are two options, I think:

  1. Use the GRUB line editor to modify the linux boot option to correctly load linux (and then run grub-install as root to permanently set the correct config).
  2. Boot from an Ubuntu USB stick, mount the ubuntu disk partition, chroot into it and then run grub-install.

The first case should be easier if you only have Ubuntu and only have a single hard disk, in which case select the "Ubuntu recovery" option, and press "e" to edit:

The entry should look something like:

insmod gzio
insmod part_msdos
insmod ext2
set root=('hd0,msdos0')
search --no-floppy --fs-uuid --set=root XXXXXX
linux /boot/vmlinuz-YYYYY root=UUID=XXXXXX ro recovery nomodeset
initrd /boot/initrd.img-YYYYY

Remove the "search" line and replace "root=UUID=XXXXX" in the "linux" line with "root=/dev/sda1". Try and boot this and hopefully after a short time it will give you the Ubuntu recovery menu, which should have a grub option, which should properly re-install grub.

Otherwise, or if you'd rather not mess around with grub directly (which should carry a health warning, use a CD/USB stick as documented in https://help.ubuntu.com/community/Grub2/Installing#Reinstalling_GRUB_2