Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ( 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
up vote 11 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" :

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

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

What I did instead of editing fstab and grub:

  1. I backed up those files on the fresh install of ubuntu ( tar -cvf /somedir/boot.tar /etc/fstab /boot/grub/grub.cfg )
  2. Restored from backup ( tar -xvpf /mnt/remotebk/full.tar )
  3. copy restored fstab file (cp /etc/fstab /somedir/fstab.restored)
  4. restore my fresh install boot files ( tar -xvpf /somedir/boot.tar -C / )
  5. Rebooted and it worked.

I'm using vmware virtual machines, I did this process to move one linux server from one host to another host.

share|improve this answer

I have a laptop with 1TB drive for /dev/sda. Four partitions named sda1, sda2, and sda3, plus linux swap. After my wife tried learning Ubuntu 15.10 in the quick with some keyboard and touch pad issues, and passing the laptop over a table with lid up, causing some more mistypes, I found that only sda1 was still sane. sda2 and sda3 were no longer accessible via the GUI and would neither mount or umount. So I fired up gparted.

gparted had problems too, but the "/device/attempt data rescue" and using "sda2 view". But prior to this, bparted wanted me to install fpart, si I dis "sudo apt-get -y install gpart". I found that the data was intact. But sda3 showed that it could not be mounted Read-Only. So I worked with "Partition" i gparted, but it said the partition table overlapped another partition. That's dangerous, so I deleted sda3 and did "new", and put it back as it had been with an auto "format". I then quit gparted, mounted sda2 and sda3 in the GUI, entered a Terminal and typed the following:

cd /m*// # a shortcut way to get to /media// dir # just to verify sda2 and sda3 both got mounted sudo cp -rfp sda2/ sda3/ # copy the now-good sda2's contents to the new sda3

This process took hours as I have over 200GB data on each partition. No errors were reported. But it turns out, nothing got copied. The original folders and files on sda3 showed up instead. How this happened I don't know. This step may have been unnecessary, or maybe it played a role in the recovery process.

I then located and installed Ubuntu boot-repair. I could run in from the good partition of sda1, but created a script file of the commands to install and run it and copied it to /m*//sda2/home//. That worked. But sda3 failed to be copied too. So I went back to gparted and did another data rescue on sda3. and this time the original folders showed up. only I did not know that then. This time I could copy the script file file to my iser account on /m*/*/sda3/home//

I ran a mix of the following commands several times. To run them. I first decided to become root and eliminate the need to type sudo repeatedly, or sudo -i at least once, and be timed out on after 10 minutes or whatever the time is adjusted to be.

It's simple, just enter "sudo su root". You keep $HOME and $PATH as they were, but "~" becomes /root. Now no more timeouts and no need to know root's password, although you could change the root password with "sudo passwd root". You just need administrative powers as a user, and you have control when you needit. Son;t overdo though, as you have the power to ruin or destroy as well. So here atr the mix of commands to run as super user or root:

apt-get -f install # fix lingering problems or identify unresolved issues and suggest courses of action, not all as simple as suggested.

apt-get -qq update # needed to run once to get update listings from the various repositories covered in /etc/apt/sources.list, any *.list files in the /etc/apt/sources.list.d folder, or the PPAs that were added at some point. Always a good thing to run before every effort to do an upgrade.

apt-get -qq -y dist-upgrade # best choice of the three (upgrade and full-upgrade, as update just does package add-ons but does not update the kernel (that's the real Linux core), and fupp-upgrade takes you up to the latest release.

like going from 14.04 to 15.10 was too big a jump. and to get around this I had to remove 14.04 completely using a LiveCD or other partition leaving only /home and its contents behind ("cd /m*///home", or "cd /m///home;pwd" and verify that you are on the right partition). To geg rid of the system folders only, you type "sudo rm -r ../![h]*". and this will delete everything except files in ../ that start with "h", and all folders in ../ that don't start with "h" plus their contents. Then you install the new version of Ubuntu 15.10 or later.

The reason you have to do it this way is as failing of the LiveCD or LiveUSB process, or the "sudo apt-get install full-upgrade" or Sortware Updater processes, and how they handle inter-dependencies. All these inter-dependencies were done incrementally and in a certain order, and were properly resolved at key points by "sudo apt-get -f install", , which forced some dependents, such as libraries, to be installed before their appeared to be a need for them.

The opposite of "sudo apt-get -f install" is "sudo apt-get -y remove", but you have to actually name all the dependents or packages to be removed on the same line as this command with a space separator. You can first try removing them individually, perhaps in a script list, but when two or more get hung, you need to hammer at them with a single remove command until they are finally removed in the right order. "sudo apt-get autoremove" works for most obsolete packages. files, and libraries, but tells you when it can't do the job, and suggest you run "sudo apt-get install -f" instead.

The position of flags like "-f" is not critical, as long as it comes after the apt-get.

The -qq just removes routine progress results, but may hide some critical details about which actions did not get acted on. In the install process, it can also suggest other packages that you might want as well. The best course of action is to add " | less " behind these commands so that you can scroll through the output afterwards, or redirect the output to a temporary file using " > filename" or " >> filename", The ">" would start a new file or delete and existing file of whatever name you use in place of filename, and the ">>" would either start a new file of that name if it does not exist, or append to an existing file of that name. You would not use "-qq" if you go this route.

In place of ">" and ">>" you can use " | tee filename" and " | tee -a filename". This splits the output so that it both goes to the file and returns to the StfOut as well, which normally appears on the screen unless redirected again by another "]", ">", ">>", or possibly a "<". These are called pipes, and used to redirect StdIn, StdOut, and StdErr.

The importance of getting the results into a file is that it can be processed by a script or other app, program, or utility like grep, awk, sed, cut, and so on. Or write your own in Python, Perl, C/C++, truebasic, or what have you. You can eliminate the standard returns in the file which follow a pattern, and focus on the problem areas which have their own patterns.

You can strip out the significant portions and determine the next steps to take, then program those steps into their own script file, act on them immediately, or report them as unresolved. That's what progrsmming is about, making the computer do its best for us. We aply our smarts in a way that the computer can understand and follow, then anybody can do it. Not having done all that yet, which takes time, I just kept throwing the problems back into apt-get's lap until they sorted themselves out.

One solution "apt-get -f install" used to offer was to use "sudo dpkg --configure -a" as a way of putting a band-aid on a failing system by having it verify what was still alive and sane and discarding broken packages if they could not be healed. But dpkg has been altered and --configure is no longer supported, and I don't know if there is a suitable replacement or not. Fortunately I did not need it this time around. but it is unsettling to know that it is gone.

As wonderful as apt-get is, what bothers me is that it can suggest a course of action, but does not act on its own suggestions. Why doesn't it just take the steps and fix the problem for me? I've lamented this lack before. And another problem is that one pass of any apt-get install or Sortware Updater may not be enough. Remember that the upgrades have to come in a certain order, and going through the Repositories and other sources may not occur in that order. Hence use "apt-get -f install" and try again, and repeat if there were any changes made in the last pass.

Since none of the existing update/upgrade process go to this extent, you have to either write your own or wait until someone does it for you.

But back to my final results. Two recovered partitions, onesuppose to be a clone of the other, but somehow brought back to good health instead. But there is a problem: The /etc/fstab file did get replaced. Using simolar techniques to the above, I used "dir /dev/disk// to get all the ways the drives and partitions are referenced and copied these into a text file, then used "blkid /dev/dis/sd" and got a complete breakdown on each one. I then used "sudo gedit /m*/*/*3/etc/fstab" and replace the UUID for root ( / ) with the UUID given for sda3, and changed the "instally installed" comment to sda3 as well. For grub that would have been enough. But not for grub2. I got here by searching for what other change is needed. Now I know by reading the above.

There is comment made that boot-rescue would find and fix this problem. Nope, doesn't work. Nor does the combination of "sudo update-grub && grub-install /dev/sda". What was happening was for sda3, I was getting the ogiginal folders and files back (mostly), but neither boot-rescue nor update-grub were verifying that sda3 had /boot on it, a /etc/fstab file, where the / was suppose to be or that there was a bootable image file on it. No, they went with the previous determinations by grub2. I was getting the /home folders for sda3, but the actual root was still sda2. This raises some interesting possibilities for quick recovery if a partition fails to boot by just switching to another partition for root (/), or using the same root and setting up /home on different partitions.

Rather than do the grub2 file manually, it makes more sense to script the process or have prepared substitutions in place in case a given partition fails to act as it should. Either the system files or the user accounts could be remoted or put on an external drive. The possibilities are huge if you think about it.

having covered so much ground, here are a few more tips:

(1) If on a laptop with a backlit screen, you can install xbacklight and automate the intensity of the light.

(2) For any monitor/graphics card. install and run xrandr, This identifies and allows you to change screen resolutions to sizes that agree with the card's capabilities. You can switch resolutions on the fly by manual commands, which can of course be scripted. The resolutions effect all users and all work spaces, but you can set .profile or other start-up scripts so that logging in under a different userid can assume their favorite setting.

(3) Using gnome-session-fallback or gnome-session-flashback (aka Gnome Session Manager), you get a 3-in-1 interface choice. One is your present interface, which is the default. The most informative and organized interface found so far is Metacity, which is the 2nd choice. Under Metacity, all login choices are listed under the top rightmost button. By clicking on any one, you are instantly able to switch to it, but your existing login continues to run. No need to log out and back in as the other user anymore. It's like the terminal entry "su user" command, but done via the GUI. Very handy. Makes it easy to share a PC without disrupting work in progress.

(4) When it comes to getting eyeglasses or contacts, the better way is to so it online. New glasses for as little as $9, but more if you want frames with style, which they also carry. Decent good-looking glasses for as little as $35 - $40.

They fit you for the frames online and one site can even correctly determine the PD, or distance between the pupils. I verified its measurement by using on screen rulers (screenruler and kruler) and used gimp to rotate my head and displayed credit/debit card (a standard in these measurements) which I glued temporarily to my forehead with Elmer's rubber cement (wait for it to dry on the card then stick, don't put the cement on you forehead as it will sting).

Some sites invite you to email the image to them and they will do the measurements for you. Most rulers are inches and Centimeters, but they want millimeters, which are 1/10th of a centimeter. To go from inches to millimeters, just use simple math: Inches + n/m fractions of an inch gives you a whole number. Then multiply the whole number by 25.4 and you have millimeters. My careful efforts, repeated with several selfies (I had to remember to look off into the distance), found that center to center, my PD was 62.8mm. The assumption is that close up vision like reading, the pupils wiil be about 3mm closer together. For anything closer, you need custom glasses with a separate PD measurement.

The online system said 63mm, which is what 62.8mm rounds up to. You can\t get closer than that. Much more precise than someone in a eyeglass store holding a short mm gauge before your distance-focused eyes and moving their head back and forth, trying for a perfect 90 degree angle into the exact center of each pupil as you eyes try to avoid shifting, and their hand wanders slightly. The only thing lacking in the online process is the eye exam itself, where they have a machine and try different correction lenses and you tell them what looks better to each uncovered eye. That they can't duplicate.

What I did not know at the start is that the field involving vision correction has a lock on federal and state laws. They are unregulated and can charge whatever they want for eye exams, lenses, and frames. They even keep their own hours, and may have a separate entrance into their shop. Corporations like Walmart, Target, Sears, Lenscrafters, and such may enter into agreements or contracts with them, but can do little to nothing to control their management, prices, or practices.

And the staff is paid on commission, meaning spike the price when and where you can. and sell the customer on upgrades like anti-glare, non-reflective, scratch resistant, tinted, or a different, more expensive lens material. One of the best optical materials is simply referred to as plasric, and is 1/4th the cost of the next material up the ladder. They won't quote you a price up front, unless you insist on knowing. If this happens, they may quote you a orice per lens, so that when you try to settle up, those treatments cost you twice as much as you were quoted. People pay because they need the glasses, feel they are committed, or think they are paying what everybody else pays. True on one, false on the other two.

You can try on franes online as well. You can user the existing lens width - bridge width - temple length engraved somewhere on your existing frams, or you can be fitted online using a selfie photo without glasses or getting a shot with your webcam. Nobody has asked for a profile to determine temple length though. which is from the front outer edge of the frame all the way to the tip of the end where it falls behind your ear. Since heads tend to be round. they can roughly estimate temple length based on a front view of your head and something like a credit/debit card to judge distance by. Some sites prefer to see the card held in front of your mouth. All prefer the white side forward to more distinctly determine the width across. To work with machines, credit, debit, ATM, and other cards have to have a uniform size, and almost everybody has one or the other. As found online with a search:

"The size of credit cards is 85.60 × 53.98 mm (3.370 ×2.125 in) and rounded corners with a radius of 2.88–3.48 mm, in accordance with ISO/IEC 7810#ID-1, the same size as ATM cards and other payment cards, such as debit cards."

The best prices are online, and this even goes back before there was an internet, at least 85 years back. Back then it was word of mouth, ads, telephone calls, and smail. My family could go into NYC, visit one of these places, have an eye exam done, and be out with new glasses within an hour. The company occupied a whole floor of a building on Wall Street and was looking to expand.

I quit going when I joined the military and started getting it all for free. If you are a military retiree or Vet and want to go the free government route, I would not bother. Scheduling is hard, getting approval even harder, and you get three ugly frame choices with lacks to each one. And no special treatments for the lenses. Dependents have no eyeglass coverage through the government, unless you are some kind of person with special needs, like living below the poverty level and a child whose future is at risk because you can't see to read. No programs exist for the elderly, who won't be around that long, and whom nobody cares about, the kids all having families of their own to care for, or whom know that they can't deal what is really wrong with you, like aging, becoming sixkly, and dying.

(5) I see we are on the verge of extending human life to 1,000 years or more, and much of that time we will be fit and vigorous, Like we aren't overcrowding this earth enough already, and there isn't a long enough line for available jobs. What are we going to have to do, work 500 years to earn enough to retire on for another 500 years and more? We live with inflation, at an ongoing rate, and government spending out of control, and hust imagine the swelling of the government welfare programs as there are too many bodies and not enough opportunities to go around. Imagine going to a paradise resort and finding it crowded with the equivalent of 58 years of normal vacationers. You think our cities and highways are packed now? TGhere wull be no comparison. And every year you live your earned retirement slips further in value as inflation continues to run its course.

What's going to happen is that government is going to step in, and long life will be regulated and controlled so that only the brightest, most gifted, most attractive, most wealthy, and most powerful will have access to it. There is no other way it can work. But there will be a blaxk market in the knowledge and means to make it happen, and that is going to really cause some problems. Most thinking people reject the idea of getting high on drugs or alcohol, preferring an uncluttered and uncompromised mind that can deal with facts.

But a lot of people are ready to get high on the prospects of long life for themselves and their loved ones. Only life here on earth will lose its appeal. However the prospects of converting large asteroids to interstellar space homes and vehicles, then taking generations to scoot off to other solar systems may seem appealing. Lot's of solitude, lot's of time, and just getting there is the goal.

Just a few things I thought to share. Hard to find a place to share them from though. At least with spots like this, I find thinking people that want answers, which I did provide. In some cases for questions not yet asked, But when you don't know something, how do you know that you don't know it? Or that you don't know that you don't know it? The answer is most often a chance encounter. Unsought, unplanned for, if it happens it happens. Maybe this is your chance encounter for the day.

share|improve this answer

Your Answer


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.