Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to restore a complete tar backup of Ubuntu 12.04 with all my customizations, documents, installed software, etc. to a different machine.

I made the backup with the following commands:

sudo su
cd /
tar cvpzf ububackup.tgz --exclude=/ububackup.tgz --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/tmp --exclude=/media /

On the new computer I did a fresh install of Ubuntu 12.04, moved the backup file to it and then restored with the backup file with the following:

tar xvpfz backup.tgz -C /

As expected (see Mike Whatever's answer to this question: Copy Ubuntu distro with all settings from one computer to a different one) this broke grub. When I turn on the computer I get an error:

error: no such device: ...

press any key to continue ...

I believe the reason that Grub is broken is that the UUID it is looking for matches on the old hard drive not on the hard-drive for the computer.

How can I fix my grub to recognize the new hard-drive? I looked online for help "Fix GRUB UUID" but the steps seemed either out of date or complex. The response from Mike I linked to above gives me hope that there is a fairly simple way to repair this.

share|improve this question
    
Why don't you use clonezilla (clonezilla.org) to make a snapshot of your old computer and restore it on the new one? I think it would really be easier because you seem to want to keep absolutely everything as is. Otherwise, making a backup (/home, /etc, /usr/local, /var) and restoring your data and customizations, except softwares is really easy too... To solve your current problem, you'll have to change the UUID(s) in /etc/fstab and /boot/grub/menu.lst. You can use Ubuntu install CD to get the UUID(s) [gparted or command line] and make the changes. –  Golboth Aug 3 '12 at 8:45

3 Answers 3

up vote 8 down vote accepted

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.

share|improve this answer
    
Thanks Golboth. I ended up using your suggestion of using the boot repair disk and that worked. –  snowguy Aug 3 '12 at 12:50

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

share|improve this answer
    
FYI, when I started I did not see the grub startup option (maybe though because it just boot directly into Ubuntu since it was the only OS). In any case I appreciate your help. I ended up creating a boot repair disk. –  snowguy Aug 3 '12 at 12:51

In my case, the UUID that grub installed was different from my present UUID (sudo blkid) for my Windows partition (confirmed in grub.cfg). I tried various methods unsuccessfully. Finally I mounted the Windows partition with file manager and ran update-grub again and the UUID was updated successfully in grub.cfg.

share|improve this answer
    
The program is called update-grub and not grub-update. This is not quit obvious as the most grub commands starts with grub-.... –  Fa11enAngel Jul 30 '13 at 8:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.