0

I would like to know if it is possible to change the distro but keep the programs you installed.

I know this is a terrible idea across distros (unless they run on the same base -> ubuntu, xubuntu, kubunty; and still maybe a bad idea), but could work if you are just reinstalling the same distro, same version.

1
  • do you mean by "change distro" that you keep all your binaries in place or to have a new installation with the same packages installed?
    – blissini
    Nov 12 '15 at 11:15
2

With debian (and derivatives like ubuntu, mint, etc) you can save the current set of selected packages with:

dpkg --get-selections '*' > /tmp/selections.txt

Copy that file to a USB stick or somwehere convenient, so you can use it with dpkg --set-selections after you have re-formatted and installed the base OS.

Login as root (or sudo -i to get a root shell) and:

  • mount the usb stick, e.g. under /media
  • apt-get update
  • dpkg --set-selections < /media/myusbstick/selections.txt
  • apt-get dist-upgrade

Note: this will NOT keep any custom configuration of any packages. If you want to do that, you will need to backup your old /etc directory and restore (some or all of) that after the packages have been re-installed on the new system. I doubt that this is an issue, because the only good reason to do what you want (fresh install, re-install all the same packages) is if you have completely messed up the configuration of something important. Even then, you're probably better off purging that package (or packages) and then re-installing it/them.

This --get-selections / --set-selections method can be useful for small-scale cloning of mostly-similar machines, without the need to set up pxe, tftp, etc infrastructure, or clonezilla and an nfs or samba server. For large-scale cloning, it's worth putting in the effort to set up the infrastructure to automate mass-cloning.

2
  • Any clue why I'm getting $ sudo dpkg --set-selections < ~/Documents/software.txt dpkg: warning: package not in database at line 3: for many lines? Missing ppa?
    – Camandros
    Nov 12 '15 at 12:09
  • Found solution childsplay.mobi/blog/?p=197
    – Camandros
    Nov 12 '15 at 12:16

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.