Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Whenever I get a new laptop, I've to go through the pain of doing a sudo apt-get install xxx of all the stuff I've grown used to, i.e. I've to recreate the entire environment again. Is there a hassle free way of migrating from one laptop to another, given that I'd use Ubuntu on both of them? (Other than being on a vm all the time? I've also tried physical to vm using Vmware, but hasn't been a smooth an experience)

share|improve this question
+1 have been wondering this as well; what I currently do is put everything I type in the commandline after a new install in a file, and run that file again on a new install. Works pretty well. – stijn Jul 9 '12 at 7:26
up vote 5 down vote accepted

Yes you can, to an extent

this assumes that you have the same /etc/apt/sources.list and /etc/apt/sources.list.d/files the former is for regular repositories, and the latter is where ubuntu adds PPAs to. Copy this off your source system and into your destination system, and run apt-get/aptitude/ubuntu software center's update command - see this answer on AU for more details

I've adapted the instructions for tranferring a package list from ubuntugeek.You can dump a list of packages from the source system to a text file called installedpackages with

sudo dpkg --get-selections | grep '[[:space:]]install$='| awk '{print $1}' > installedpackages

and copy over installpackages to the destination system then reinstall it with cat installedpackages | xargs sudo aptitude install in the location installedpackages is in

Copying over /etc/ may be a good idea as well for major config files.

And of course,copy over /home/username in order to get a copy of your working environment, such as your home folders and desktop.

Package list dumping and reinstalling taken from

This should cover a good chunk of files on a 'desktop' install of ubuntu. There may be some specific things this would miss (apache virtualhosts comes to mind) but package and desktop related settings should be squared off.

share|improve this answer
Thank you @Journeyman Geek ... this looks like the closest thing I'd want to do. 'll go home and give this a try! – Tathagata Jul 9 '12 at 17:35
And if you're a PHP/MySQL developer, you should NEVER forget /var/www and /var/lib/mysql. I did once... After that I just changed the default locations of mysql and www to /home/www and /home/mysql - my /home is on a separate partition and it remains unchanged when I reinstall the system or change my computer. – Donatas Olsevičius Jul 10 '12 at 8:52
ahh, yes. Thats part of the issue i guess, I don't know what sort of dev he is ;p. DB other environmental files would need to be moved too. – Journeyman Geek Jul 10 '12 at 10:12

You can copy whole file systems from one partition to another. E.g. using a combination of dd and nc.

root@old# dd if=/dev/sda1 bs=4M | nc -l -p 4444
root@new# nc old 4444 | dd of=/dev/sda1 bs=4M

This assumes that you're running a live system, e.g. from an install CD, on the new system. And that you have a host name or IP address for the old system, so you can connect to it via TCP. sda1 is assumed to be the partition of the linux file system; adjust as needed if you use a different partition, or multiple partitions. If you can get both drives connected to the same machine, you could use dd without nc.

After copying the filesystem as stated above, you can

  1. Adjust the filesystem size using resize2fs in case the new partition is larger.
  2. Mount the filesystem somewhere and chroot into it to install the bootloader. You might have to mount --bind additional filesystems like /dev from inside the live system.
  3. Again inside the chroot, adjust the set of installed drivers to match the new hardware.

I've migrated my file systems over several different hardware configurations, including several hdds. The switch from 32bit to 64bit was a bit more challenging, but with Gentoo I even managed that without having to reinstall my system from scratch.

share|improve this answer
thanks for the answer! – Tathagata Jul 9 '12 at 17:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .