3

I tend to think that many of us have faced this problem:

You get a new laptop, install an OS on it and gradually install and configure new software according to your needs.

Then after some time you need to move to another PC, for example because you have bought a new laptop.

How do you transfer all your software with its unique configurations to the new machine then? Installing everything by hand and configuring it is a really cumbersome task.

I was thinking that the following software could be used to solve the problem, but I have not found any perfect solution:

  1. OpsCode Chef (you will need to write Ruby code and to maintain a Chef server in order to quickly provision a new laptop)
  2. docker.io (their repository (INDEX) does not have as many software packages as Chef does, also I am not sure that it will work well with provisioning a GUI Desktop)
  3. Ubuntu Juju (seems to be too complicated).

Maybe there is some way to just copy/save an image of the whole OS instead?

  • Why don't you just copy all the partitions? – Deer Hunter May 29 '14 at 8:34
  • @DeerHunter different hardware requires different drivers; also, disk configuration might have changed. Usually, when you buy a new computer, everything is bigger (except its case, which usually stays the same size or gets smaller ;) – so copying partitions would not make use of the new machines disk capacity. – Izzy May 29 '14 at 9:09
  • @skanatek: What OS you're talking about? On Linux, that shouldn't be too complicated: keep your /home directory on a separate partition (so you can copy it over, saving all your personal adjustments), keep track of packages you (un)install (hint: export your package list right after the initial install, and then again when "moving", and you'll get the "diff" of what you need to (un)install on the new machine). Only some small stuff remains then (changes to central configs in /etc and the like you need to keep track of). On Windows it's different, with the stupid registry stuff... – Izzy May 29 '14 at 9:13
  • Ooops... Sorry, you've mentioned the OS in the title of your question :) So are we talking Debian (.deb) or Redhat (.rpm)? And would the solution outlined with my previous comment be suitable? If so, I could make that an answer including additional details (after all, dpkg, rpm, etc. is software, so from that point it's matching our site's scope :) – Izzy May 29 '14 at 9:28
  • 1
    @DeerHunter if CloneZilla can adjust partition sizes on the target system, your solution might also work out (as long as architecture doesn't change too much): if it at least can boot its initial system, Linux should take care for changed component drivers itself (even if using some "basic" parameters first, which the user can adjust afterwards – like using a basic 2D graphics driver instead of the full-featured (proprietary?) 3D equivalent :) // Now it's up to the OP to state which solutions are acceptable, so we may place our answers (or not :) – Izzy May 29 '14 at 9:39
3

This can be done with software already shipping with the system (so in short, I'm recommending you a software called "Linux" ;). As you didn't specify the flavor of Linux used, I'll outline it for Debian based systems here. The very same principle should also work for other Linux systems; you've just to adjust the dpkg part to its corresponding counterpart (e.g. rpm).

1. User configuration (generic)

All user specific configuration etc. is stored inside the users home directories, which usually reside below /home (e.g. /home/izzy could be mine). I'm always making /home a separate partition for easy portability (so I could even install a new Linux without touching /home, and still re-use my settings afterwards). So to transfer all the users settings and files, you simply have to copy their home directories.

Software to be used for this part: cp or scp, Midnight Commander, any other file manager – all either pre-installed or at least available via standard repositories.

2. Installed software (Debian specific here)

On Linux, one usually installs software via repositories. So the corresponding repository manager keeps track of changes. I will describe this part for Debian based systems here, but it should be adaptable to almost all other Linux flavors:

Right after the first (virgin) install of your initial system, have your packager export a list of software it installed. On Debian, this can be done as follows:

dpkg --get-selections > initial_packages.txt

When the day comes you're about to move to a different machine, do the same thing again (just re-direct output to a different file, e.g. final_packages.txt). The use a "diff tool" to show the differences between the two files, and you should be able to figure which additional packages you've got to install on the new system – and which to possibly remove. Raw example ("pseudo code", you'll need to fine-tune this):

diff -u initial_packages.txt final_packages.txt | egrep '^\+' > install_me.txt
diff -u initial_packages.txt final_packages.txt | egrep '^\-' > remove_me.txt

Explanation: The resulting diff would have lines (packages) added prefixed by a +, while lines removed are prefixed by a -. Everything else is just for context and can be ignored. So following above two commands, you've got a list of packages which you need to install to the new system, and optionally another one to remove.

Make sure to take your repository configuration along to the new machine, especially when you've adjusted it. Corresponding files are /etc/apt/sources.list and /etc/apt/sources.d.

Software needed for this part: dpkg, diff, grep – all come pre-installed.

Note: Some differences might be "ignorable" and have to be skipped. This applies e.g. to kernel updates the system applied automatically. So make sure to manually check your resulting list.

3. System-wide configuration changes (generic)

For this part it's a good idea to keep track of what you're changing, so it's easier to apply these adjustments to the new system. But even if you forgot, if you notice something related on the new system, you might remember again and refer to what you did on the "old" one. Good idea to have the relevant stuff available for reference. Again, with pre-installed software, you can take care for that:

tar cjf old_machine_config.tar.bz2 /etc/*
scp old_machine_config.tar.bz2 new_machine:/opt/backup

should do that for you (adjust names and path as required – and of course you could also use tar czf with a .tar.gz file instead).

Software used for this part: tar, bzip2/gzip – all ship with your Linux distribution, and are usually pre-installed.

4. Other differences

  • system specific stuff (like proprietary drivers for your hardware) are explicitly ignored here (and you should ignore that part as well when following above "instructions": keep step 2 specific to your software (dependencies will be dealt with by apt/yum/… themselves), ignore system specific stuff as drivers and libraries unless you know you will need those on the new system e.g. for development purposes)
  • software manually installed by you with other means then the package manager might not be covered either. If you used CheckInstall, it would be listed by the diff in step 2, but you would need to take care for the "sources" (here: the .deb packages) yourself. Otherwise, you need to track those separately.
  • if you stored files outside your home directory (e.g. under /usr/local or /opt), you will need to cover those separately, too.

Conclusion

This looks like a long and cumbersome process (instead of a simple point-and-click), but actually shouldn't be too complicated as long as you've kept care for it from the beginning (with the initial package list export in step #2). It might get a little trickier if you manually installed software from places other than configured repositories (or if one of the repositories used "died"). Here you need to take care for yourself: keeping log of those changes, store the sources in a specific directory, maybe keeping the .deb files from "minor repositories" as backups (hint: Debian caches a copy for some days at least in /var/cache/apt/archives, where you could pick them from).

But after all: this should do, comes for free, and all components required are already on your machine :) Moreover: With a new machine, you probably also want to install an up-to-date version of your Linux distribution. "Imaging" your current install won't take care for that – but above described procedure does. Just keep in mind that some changes (central config, packages added/removed) might need to consider this as well, so better cross-check before applying changes to your new system then :)

And finally: As all software required already comes with your system, you don't need to acquire any additional pieces.

| improve this answer | |
  • thank you for such a detailed answer. I have some concerns though: how about proprietary video adapter drivers? How about the software which I have built manually? (checkinstall could have fixed this problem though) – skanatek May 29 '14 at 13:30
  • See my update (#4 was inserted to cover your additional questions). If anything else is missing, just let me know :) – Izzy May 29 '14 at 14:04

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.