33

I use ubuntu to deal with daily job. Now I buy a new laptop, and I want to migrate my whole system(programs, packages, data, settings, etc) to the new machine.

I know I can copy my home folder to new machine and I will get (almost) all data and settings. But is there a safe way to copy the whole system? Or it's a bad idea?

2
  • Is anything stopping you from swapping the old drive to the new system, or the image of it to a new drive? I got a new laptop and just put the drive from the old one in the new one and that was it. – Bert Mar 27 '13 at 1:24
  • Related, maybe a duplicate: How to copy an Ubuntu install from one laptop to another – wjandrea Apr 30 '19 at 14:37
26

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/

5
  • 9
    Step 2 is still rather vague – Adonis K. Kakoulidis Oct 26 '13 at 12:28
  • 1
    There may be a change to Ubuntu's setup because following these instructions will cause system failure - necessitating a re-installation of the operating system. Best option is to just start from scratch on the new machine. – mjp Jan 18 '17 at 17:12
  • @mjp True. This rendered my freshly installed ubuntu 16.04 unusable. After running the install package commands System Settings went missing. I restarted. The machine then rebooted into a blank desktop. I tried to reinstall unity desktop from command but no result. Going to re-install ubuntu – Mohammed Joraid Jul 19 '17 at 11:56
  • To find changes in /etc I used debsums -ce – PiTheNumber Mar 17 '20 at 12:45
  • This does not work anymore! See askubuntu.com/questions/1006641/… – PiTheNumber Mar 17 '20 at 19:12
11

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.

0
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.

1
  • Thanks for this! While it's not free ($25 for a personal license), it is much more comprehensive than most other answers here (getting custom repos, packages, configurations, and more in addition to just the home directory) and apparently doesn't bork an Ubuntu 18.04 install, which appears to be the result of some of the other, older answers here when applied to modern distros. – Doktor J Jul 26 '19 at 19:11
0

Most configs and personal files will be in /home. For example by default my GNOME theme, shell settings, Chromium history/bookmarks/etc., vimrc, bash_profile, and most settings carried over nicely.

An important thing is to preserve permissions and timestamps. See Copy files without losing file/folder permissions The -a flag for rsync is ideal for this. Rsync is recommended for large file transfers. Use --partial-dir to be able to restart progress. I also exclude .gvfs (not a real file) and .cache.


Also consider installing /home on a separate partition if you are just reinstalling the system on the same hard drive. What are the pros and cons of having a separate home partition?

-1

There are several utilities that can make direct copies of your file system and some (Norton Ghost for example) can adjust your partitions to adapt to the new disk. Software like this allows you to not only copy from disk to disk but also keep a separate, compressed backup for yourself in the future.

There's also the tool dd to do this, however it takes a bit more knowledge and research to produce the results that you would like.

3
  • There's also filezilla which works well. – ShadowMitia Mar 18 '15 at 17:02
  • 1
    @ShadowMitia Clonezilla I guess you meant? – Mohammed Joraid Jul 16 '17 at 8:52
  • Norton Ghost? No thanks we have rsync and gParted... – qwr Mar 23 '19 at 23:28
-1

Remember that you can easily remove your hard disk from one machine to another without any problem.

1
  • Not necessarily, if the new system is a laptop and 1) the drive has a 3.5" form factor or 2) even with the right form factor all drive bays of the laptop are full. – David Foerster Mar 18 '15 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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