How to migrate the whole system to a new machine?

Solution 1:

Prerequisites:

The same version of Ubuntu is installed on both machines. The architecture (32/64 bit) can be different.

Step 1: Store the list of installed packages

Run the following command on the source machine to store the installed packages names in ~/pkglist:

sudo dpkg --get-selections | sed "s/.*deinstall//" | sed "s/install$//g" > ~/pkglist

Step 2: Transfer your config

Use scp or rsync or even a flash drive to transfer your home directory (~/, ~/.), the source list (/etc/apt/sources.list) and any other files you customized or installed (like apache config under /etc or softwares on /opt) from the source machine to the target one.

Step 3: Install packages

On the target machine run the following command in a failsafe terminal session to install your packages:

sudo aptitude update && cat pkglist | xargs sudo aptitude install -y

Extract from:

http://eggsonbread.com/2010/01/28/move-ubuntu-to-another-computer-in-3-simple-steps/

Solution 2:

First off, How to list all installed packages this question covers exporting (then installing) your exact set of packages.

As you noted, most of your configuration will be in /home.

That being said, each time I do this, I start from scratch so to speak. I'll install ubuntu and manually add packages that I know I use, configuring them one at a time. The list of packages installed on your old computer is a good starting place to find different pieces. Once stuff is more or less set up, I'll then copy over just the data files (but not the config files) from my old computer. This does take more time to do, but it's worth it to switch to the newest version. (My old desktop runs 10.04, my new on currently runs 11.10, although I plan on updating that to 12.04 when it has been around for a month to work off any remaining rough edges) But this plan is for if you're ok with a few things working slightly differently than before. If you need things to be exactly the same, go ahead and do the above.

Solution 3:

I was looking for an easier way of doing this and I found Aptik:

Aptik is a tool for migrating settings and data from one Linux installation to another. It can be used while re-installing the operating system, and when moving to next release of a Linux distribution.

I just used it to migrate from an old laptop to a new one, both running Ubuntu 18.04. Seemed to work pretty well.