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'm new to Ubuntu and recently started using it on my PC. I'm going to replace that PC with a new machine. I want to transfer my data and settings to the nettop. What aspects should I consider?

Obviously I want to move my data over. What things am I missing if I only copy the entire home folder?

This is a home pc (not corporate) so user rights and other security issues are not a concern, except that the files should be accessible on the new machine!

Please take into account that the new machine is a nettop that doesn't have an optical drive and doesn't allow me to hook the old SATA disk into it, so any data transfer must be handled via home network (I can have both the old and the new machine turned on and connected to the home LAN) and I have an USB thumbdrive with limited capacity (2GB).
This sounds like it might limit the general applicability, but it would in fact make it more general.

share|improve this question

9 Answers 9

up vote 21 down vote accepted

User settings are stored in the Home folder by design. So, if you copy your /home/your-username to your new computer, you should be fine...

...but there are caveats:

  • Permissions. It is common that "programs" (shellscripts, custom build programs) are put in the home folder. To preserve permissions, use the --preserve=mode switch (using cp) or -p (using tar)
  • UserID / GroupID. Even if the usernames are equal on both systems, the user ID do not have to. Usually, this is not a problem, but if you've scripts/programs/settings relaying on the UserID, you should make sure that the user ID and group ID should be the same on the target system.
    You can find the current userID and groupID by executing id. For example, to change the userID of user "your-username", run sudo usermod --uid 1234 your-username. To change the groupID, you have to run sudo groupmod --gid 1234 your-username.

Settings (Firefox profile, appearance, ...) are often stored in hidden folders (or files). Hidden folders/files are prefixed with a dot, like .mozilla for Firefox (and other Mozilla applications).

As security is not an issue, and you want to have the copying job done as fast as possible, I suggest a combination of the netcat and tar programs. Both applications are installed by default. Make sure that the firewalls on both computers allows ingoing access to destination port 8888 (source computer) and outgoing to destination port 8888 (target computer). Put the nettop next to the computer so you can run the commands quickly.

On the source computer, you need to have the traditional netcat program installed (a.k.a. Swiss Army Knife, not the BSD one). To do so, install the netcat-traditional package. You may also want to configure the traditional netcat program as default. Commands to install netcat-traditional and use it as default:

sudo apt-get install netcat-traditional 
sudo update-alternatives --set nc /bin/nc.traditional

On the source computer, type the next command in a terminal (do not press Enter yet):

 tar cz -C/home $(whoami) | nc -l -p 8888 -w 10

Explanation:

  • tar is an utility for packing files
  • cz creates such a packed file ("tarball")
  • The tarball is compressed using the GZip algorithm to lower the file size.
  • -C/home $(whoami) changes the working directory to /home and puts your username folder. Alternative, you can type your your-username folder in the tarball
  • nc (netcat) is used for setting up connections between machines easily
  • -l: Listening mode, allows other machines to connect to the current machine
  • -p 8888: Listens on port 8888 (randomly chosen number, it could be any other number higher than 1024 as well)
  • -w 10: quit netcat after 10 seconds silence. You must connect to this source computer within this time.

Now go to the target computer (nettop). To add the files to the target machine, type (do not run it yet):

nc 192.168.1.2 8888|tar xzp -C/home
  • 192.168.1.2 is the IP address of the source computer. To get its IP address, run: ifconfig on the source machine
  • 8888 is the port number as entered on the source machine
  • xzp: extracts the GZip-compressed tarball while preserving permissions.
  • -C/home: extracts the your-username folder to /home/your-username
  • Optionally, add the -v switch to the tar command for verbose extraction, so you can get an idea of the progress. This could slow down the copy process because every file has to be printed.

Now go to the source computer, press Enter to run the server command. Quickly switch to your nettop and press Enter to run the client command.

If you have any questions, just use the comment field below.

share|improve this answer
    
Absolutely excellent overview! Thank you also for the detailed explanation of the commands. Given that I only have one monitor, I'd like to set up both machines next to each other and use some kind of VNC to access the old machine. I'm sure I can quickly google a great guide for dummies - but perhaps can you recommend one? –  Torben Gundtofte-Bruun Feb 11 '11 at 9:42
    
I have not used other VNC other than the supplied application with Kubuntu (Krdc). If you do not need a GUI (like this copy process), just install openssh-server and you'll be able to connect with your machine by running ssh [email protected]. For remote GUI access, I do not use VNC as it's painfully slow, even over a (wireless) network. I recommend X2go for remote GUI control (installation guide). –  Lekensteyn Feb 11 '11 at 20:28
    
The source machine tells me: "This is nc from the netcat-openbsd package. An alternative nc is available in the netcat-traditional package. usage: nc [-46DdhklnrStUuvzC] [-i interval] [-P proxy_username] [-p source_port] [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_protocol] [-x proxy_address[:port]] [hostname] [port[s]]", the terminal prompt is visible again, and the target machine gets nothing. Am I doing something wrong? –  Daniel Nov 22 '11 at 14:29
    
@Daniel: The only thing you're doing wrong is to post your question as a comment. Open a new question and link to this one. –  Torben Gundtofte-Bruun Jan 11 '12 at 16:08
    
Hi @Lekensteyn, I get many "Cannot open" and "Cannot mkdir: no such file or directory" ... Does the same apply when trying to do that on a VM (as guest) ? –  George Katsanos Apr 26 '13 at 15:10

For the software packages, you should read the following : http://www.omgubuntu.co.uk/2010/05/transfer-your-packages-to-a-clean-install/

oldmachine$ sudo dpkg --get-selections > installedsoftware
newmachine$ sudo dpkg --set-selections < installedsoftware
newmachine$ sudo apt-get --show-upgraded dselect-upgrade

For the settings and data, it's a little more complicated :-( Most of the settings are stored in your home folder, so making a backup of your HOME may do the trick... But then of course this doesn't cover the system apps, that have their config stored in /etc...

share|improve this answer

Ubuntu devs are working on it, it is called OneConf.

share|improve this answer
    
Oh that's right -- I'd forgotten about that. Here's a link: omgubuntu.co.uk/2010/06/oneconf-to-reinstall-applications.html –  eugenemarshall Aug 3 '10 at 15:31
    
It has landed today but not much is to explore. –  akshatj Aug 3 '10 at 16:19
    
still look like a work in progress. Is this package mature ? –  lenzai Jun 14 '12 at 9:53

The majority of all settings for applications are in your home folder hidden by default. If you press Ctrl+h in Nautilus you'll see these folders. I've found the easiest way is to simply rsync the folders you need over for the configurations. Something like this:

rsync -avz me@remote:/home/me/.foo me@remote:/home/me/.var me@remote:/home/me/.ack me@remote:/home/me/.bar /home/me/

You could also - just rsync your entire home folder to the new machine - but that may cause problems depending on your setups.

share|improve this answer

All your data and setting live on your home.

If you only copy it, you will lose:

  • Installed programs. But see Sabacon answer to this question.
  • System wide configurations, in a home computer, this usually are just extra PPAs.
  • System wide programs (usually daemons) data (like MySQL databases).

I feel that the easiest way to make a network copy is this:

  • Install OpenSSH Server Download Gwibber in the old computer.
  • Make sure that both computers are hooked to the net.
  • Open Nautilus (the file browser) in the new computer.
  • In the View Menu, check "Show Hidden Files".
  • Press CTRL+L, in the address bar type ssh://ip-of-old-computer/home/
  • You should be asked for your username and password on the old computer.
  • Copy everything that you want using the GUI.

enter image description here

share|improve this answer

If you have an installation you like on one machine, you can simply clone it. It doesn't matter if the machines have different hardware as long as they run the same architecture (32-bit or 64-bit, i.e., i386 or amd64 or ...).

Here's a way to do it. It's a bit long, but fairly low-tech. Many variations are possible.

  1. Plug the new machine's disk into the existing machine (or vice versa).
  2. Boot from the existing installation.
  3. Set up the new disk:
    • If the disks have the same size: start the partition tool (System / Administration / GParted, package gparted) and copy the whole old disk to the new disk.
      • You should give the copies of the filesystems new unique identifiers, to avoid any confusion if you ever mount one machine's disk in the other machine later. For ext2/ext3/ext4 filesystem, use a command like sudo tune2fs -U $(uuidgen) /dev/sdz1 where sdz is the new disk and 1 is the partition number.
      • If you assigned names to your volumes, you may want to assign different names.
    • Otherwise, set up partitions on the new disk with GParted or System / Administration / Disk Utility and format them. If you have partitions that have the same size on both disks, you can copy them in GParted.
  4. Mount the root partition of the new installation which should now appear in Places.
  5. (Skip this step if you've copied the whole disk.) Copy the data from the old installation's root partition to the new one's. Note that it is vital to preserve permissions and file ownership at this step, and this means you must do it as the superuser (root). I don't know what the Ubuntu GUI way of doing it is. On the command line, run sudo cp -ax / /media/disk9 (replace /media/disk9 by the location where the new root partition is mounted).
  6. Repeat the previous two steps for any other partition you may have (e.g. a separate home partition), unless you copied that partition (or the disk) as a whole in step 3.
  7. Tweak the new installation (assuming it's mounted at /media/disk9; adjust as needed):
    • Edit /media/disk9/etc/hostname to set the new machine's name. Check files under /media/disk9/etc/ for other occurrences of the host name — it might appear in /media/disk9/etc/hosts, /media/disk9/etc/mailname, etc.
    • If you're running an ssh server, remove /media/disk9/etc/ssh/ssh_host_*_key*. The server will generate new keys when you boot the new installation.
    • If you've configured the network by editing /etc/network/interfaces, edit /media/disk9/etc/network/interfaces for the new installation.
    • Optionally, remove the files /etc/udev/rules.d/70-persistent-*.rules if present, so that your disks and network interfaces reuse the same names (sda, eth0, …) on the new machine.
    • If you're using proprietary video drivers (ATI or Nvidia) and the new machine shouldn't use the same driver, move /media/disk9/etc/X11/xorg.conf to /media/disk9/etc/X11/xorg.conf.old-machine, otherwise you may not be able to boot to a GUI in the new machine.
  8. Move the disk with the new installation back to its rightful machine.
  9. If you didn't clone the disk as a whole, pop in a live CD/USB and repair the bootloader.
  10. Boot from the new installation and do any necessary left-over transition steps:
    • You may need to install new proprietary drivers (System / Administration / Hardware drivers).
    • If you had a static IP address set up through Network Manager, set up networking for the new machine.
    • If you run an ssh server, run dpkg-reconfigure openssh-server to generate a new host key.
share|improve this answer
    
Hello from 2013:) Are you sure that different hardware is not important? Even if I move from some Chinese laptop to Mac Air? –  scythargon Jun 12 '13 at 4:25
    
@scythargon As long as it's the same CPU type (x86 in both cases), there's no major difference, just perhaps some drivers to install and the configuration files I mention. Unlike Windows, Linux concentrates its hardware dependencies in a few easy-to-identify files. –  Gilles Jun 12 '13 at 9:15
    
You may take a look on this (similar) guide I wrote: positon.org/clone-a-linux-system-install-to-another-computer –  Marc M Apr 6 at 17:45
    
Thanks for the summary. I would love it if you could add the removal of /etc/udev/rules.d/70-persistent-net.rules which is a autogenerated file by udev, it is used to guarantee that new network devices don't get the same name as previously installed. –  tvn Oct 30 at 10:55
    
@tvn You don't actually need to remove that file. It'll prevent the same interface/disk names from being reused, but that isn't necessarily a bad thing. –  Gilles Oct 30 at 11:46

Dropbox.

This is how I back up my settings from one machine to another, and if I completely lose my hard disk it doesn't matter.

Dropbox is an online backup/synchronization service, and it kicks major booty, and you can get it for free. It's available under ubuntu Karmic and up under the Partner repositories. You're looking for a package called nautilus-dropbox. Or, you can just download it from the site: https://www.dropbox.com/downloading?os=lnx

As above people mentioned, most of your relevant settings are saved under /home/yourname/.whatever

For example gnome configuration settings are saved under

/home/username/.gnome2

So, to do the synchronization:

Part one: Back up config settings to Dropbox. (This is all on the "old" machine, where you have your settings/configuration how you want them.)

  1. Go to your home directory, and find as many "dotfiles" and directories as you can. Almost all of these are going to be relevant to personal configuration settings.(Hit Control+H in Nautilus to view hidden files.)
  2. You're going to want to copy those configuration files files over to your Dropbox folder. MAKE A BACKUP IF YOU'RE AFRAID OF LOSING THEM.
  3. Remove the original files from your home directory, then create a link from the file in its new home (under your dropbox folder) to home directory. You can do this by dragging and dropping the file/folder to your home directory name while holding the "Alt" key, and select "create link".

Part two: (On new machine.) Create links from Dropbox-synchronized config settings.

  1. On your "new" machine, ie. fresh Ubuntu install, delete (AND BACK UP IF NECESSARY) your old home directory configuration files. Install dropbox on the new machine. Allow it to synchronize, AKA download your your old machine settings.
  2. Repeat step 3 above on new machine - copy links from Dropbox-synchronized folders to home directory.

Voila. You now have internet-based settings backup and migration.

share|improve this answer

Take a look at Stipple, looks interesting to me:

"Save a list of installed applications, .config files, and other settings to a couchDB. Sync this DB to other computers with Ubuntu One. This application also helps you install those packages and .config files on your other computers."

https://launchpad.net/stipple

share|improve this answer

Mackup can backup many apps to the cloud or version control. It's easy to extend, for example, this is how the ssh plugin looks like

share|improve this answer

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.