How to migrate user settings and data to new machine?
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.
Solution 1:
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 (usingcp
) or-p
(usingtar
) - 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 executingid
. For example, to change the userID of user "your-username", runsudo usermod --uid 1234 your-username
. To change the groupID, you have to runsudo 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 youryour-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 theyour-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.
Solution 2:
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...
Solution 3:
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.
Solution 4:
Ubuntu devs are working on it, it is called OneConf.
Solution 5:
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.
- Plug the new machine's disk into the existing machine (or vice versa).
- Boot from the existing installation.
- 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
wheresdz
is the new disk and1
is the partition number. - If you assigned names to your volumes, you may want to assign different names.
- 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
- 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.
- If the disks have the same size: start the partition tool (System / Administration / GParted, package
- Mount the root partition of the new installation which should now appear in Places.
- (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). - 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.
- 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.
- Edit
- Move the disk with the new installation back to its rightful machine.
- If you didn't clone the disk as a whole, pop in a live CD/USB and repair the bootloader.
- 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.