Move your Ubuntu system to another computer in 3 simple steps

You just got a brand new machine but you won’t like to spend hours tuning it to get the same configuration as the one you have used for years?

Let’s transfer your Ubuntu configuration and applications to your new computer in three simple steps.

This method is cross-architecture. I moved successfully my configuration and applications from an Ubuntu 9.04 32bit to a 64bit one.

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

That’s all folks!

Log into your new machine and keep working as if you were using the previous one.

A freshly transfered Ubuntu install

Post to Twitter

. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

24 Comments

  1. Nitin
    Posted June 11, 2010 at 03:22 | Permalink

    Exactly what I was looking for. vey helpful. Thanks

  2. Posted June 27, 2010 at 01:31 | Permalink

    ……
    Hit http://archive.ubuntu.com lucid-security/multiverse Packages
    Hit http://archive.ubuntu.com lucid-security/multiverse Sources
    Reading package lists… Done

    after this, nothing else happens, it’s just stuck with a blinking cursor. Any ideas?

    Thank you :)

    • Posted June 27, 2010 at 09:26 | Permalink

      Does this happen when you run sudo aptitude install `xargs ~/pkglist`? If so, what does xargs ~/pkglist display?

  3. Lamer
    Posted August 24, 2010 at 03:22 | Permalink

    I think you should use `xargs -a ~/pkglist`

    • Jared Kline
      Posted June 4, 2011 at 20:38 | Permalink

      Thanks, you’re suggestion was the only one that worked on my 10.10 install in the slightest.

    • Posted June 14, 2011 at 08:33 | Permalink

      I’m happy that this tutorial is still working on 10.10.

  4. demidrol
    Posted January 27, 2011 at 09:34 | Permalink

    > sudo aptitude install `xargs ~/pkglist`

    OMG, that will take much time. Better do the following

    cat ~/pkglist | dpkg –set-selections
    apt-get dselect-upgrade

    • veelck
      Posted July 12, 2011 at 02:21 | Permalink

      It should be sth like:
      cat ~/pkglist | awk ‘{print $1 ” install”}’ | dpkg –set-selections
      apt-get dselect-upgrade

  5. Marek
    Posted August 26, 2011 at 14:40 | Permalink

    Hi Philippe,
    thank you for this very simple mothod, I was searching a lot, and hitting very complex many steps methods. This one was easy and great.
    Take care
    Marek

  6. Marek
    Posted August 26, 2011 at 15:17 | Permalink

    sorry, forgot to mention, that last scripts work on 11.04 but i had to change last one as follows:
    sudo apt-get update && sudo apt-get install `xargs -a ~/pkglist`

    I am a bit lame in linux, so in step 2 I was missing more info about which files except of home directory to transfer as well. Otherwise it was succesful.

  7. אילן
    Posted September 29, 2011 at 11:39 | Permalink

    Thanks for the technique. Some things were transferred correctly and this saved me work.

    Things that were not installed that I came across: Cairo-dock and VLC. I’ll update is there are more.

    There SHOULD be a utlity to make this process foolproof and easy…

    • אילן
      Posted September 29, 2011 at 12:59 | Permalink

      It turns out DOZENS of apps were left behind. Some like desktopnova have an install procedure that bypasses apt-get, but most are run-of-the-mil, standard ubuntu software center apps.

      Guess we should come up with a more complete way to do this.

  8. JB
    Posted December 2, 2011 at 05:48 | Permalink

    Hey,

    How long is the last command supposed to take? it has been running (well I hope it runs, because I cannot see anything happening except that blank line) for 40 minutes and still nothing …

    I ran
    sudo aptitude install `xargs /home/user/pkglist`

    cheers,

    • JB
      Posted December 2, 2011 at 05:49 | Permalink

      By the way thank you for this post, and I am running ubuntu 10.04,

      cheers,

  9. Shay Guy
    Posted December 27, 2011 at 11:59 | Permalink

    I can’t seem to follow the various tutorials for rsync that are out there. Do I need to run in daemon mode or whatever? That seems more complex than it should be. I can’t even figure out how to resolve the hostname. (Both systems are on the same wireless home network — “network” meaning they can use the same router to access the Internet. But just using “destname” — as in “myname@destname:~$” — doesn’t work, I can’t find a USB-to-USB cable, and I don’t know if an Ethernet cable will do any good.)

  10. David
    Posted December 28, 2011 at 17:41 | Permalink

    Step 1 doesn’t work for me, I got “illegal variable name” error.

    I have 10.04

    • David
      Posted December 28, 2011 at 17:47 | Permalink

      never mind, I wasn’t running bash…

  11. Aymen
    Posted January 19, 2012 at 09:58 | Permalink

    Hi,
    It seems very helpful article, but in Step 2 how I can transfer directories like /etc and /opt to the new machine? cause cp -r doesn’t work fine for me. Moreover, are the /etc and /opt directories enough for this kind of migration? Or should I transfer all under /?
    Thanks

    • Posted January 19, 2012 at 12:03 | Permalink

      I would rather leave /etc alone unless you edited files yourself. I guess you should use “sudo cp -r” :)

  12. Posted February 6, 2012 at 00:17 | Permalink

    Have anyone tried this on version 11.10? I’m planning to migrate my ubuntu to my other PC right after I fix it. Thanks for this anyway, nice stuff you got there

  13. R Sarath
    Posted February 20, 2012 at 08:26 | Permalink

    Could someone please explain the above steps in detail( a walk through) as I am a newbie to ubuntu . I run ubuntu 11.10 on my desktop and i wish to port it to my laptop with all the updates and software downloads.

  14. Posted March 24, 2012 at 11:44 | Permalink

    Hi Philippe!

    Thanks A LOT for this!! I followed the steps you kindly shared with us but for the 3rd step I did (to the target machine):
    sudo apt-get install dselect
    dpkg –set-selections < ~/pkglist
    dselect update
    apt-get dselect-upgrade show

    I am using Kubuntu (when I do lsb_release -d I get: Ubuntu 10.04.4 LTS though).

  15. Posted April 22, 2012 at 08:47 | Permalink

    Will this transfer Ruby Bundles (Bundler) and RVMs as well? Or should I back those up separately?

One Trackback

  1. [...] [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>