Clone installed packages between different CentOS versions.

May 4th, 2013 by Andrea Matesi 7862 Views



  • Say you have an old crufty CentOS host that you cannot absolutely touch because it is workingtm (apart from the occasional apache-OOM, that is).
  • Say you are required to migrate this old system to a new hardware (perhaps to a VM), and, for the occasion, to a more recent CentOS version.

Fortunately with Linux, you have plenty of options!

One of them could be by manually cloning the old CentOS configuation to the new one (essentially by trying to replicate the existing setup on the new system).

But how to clone the installed programs list to the new one? It can be done!

On the Old CentOS host:

Launch (on the old system):

rpm -qa --queryformat ā€œ%{NAME}\nā€ > yum.packages.list

This command will export the list of the applications installed on the old CentOS without the architecture extension, version number, revision, etc. (ie: "gnome-utils-libs" vs "gnome-utils-libs-2.28.3-1.fc11.i586").

Much better, but the real advantage of the previous command is that it will create a list of packages compatible to yum (ie.: this packages list could be directly supplied to the yum command)!

On the New CentOS host.

This way you could:

yum -y install < yum-packages.list

And yum will simply fetch and install the latest versions of the packages specified on the list file directly from its repos. Please note that, before launching the previous command, I'd recommend you to at least check the repos (on both systems).

Now you can focus on the serious stuff: the /etc folder and the configuration files. Good luck!



Senior Professional Network and Computer Systems Engineer during work hours and father when home.

Andrea strives to deliver outstanding customer service and heaps of love towards his family.

In this Ad-sponsored space, Andrea shares his quest for "ultimate" IT knowledge, meticulously brought to you in an easy to read format.

Rate this post

Posted in LINUX, System Administration | 4 Comments »

4 responses to “Clone installed packages between different CentOS versions.”

  1. WilbertNo Gravatar says:

    Thank you very much!

    Turns out that thet format on Fedora 20 is slightly different:

    rpm -qa --queryformat ā€œ%{NAME}ā€\\n > yum.packages.list

  2. In addition, keeping Wilbert's correction in mind as well, the above command for installing the packages on the new host is incorrect. The filename was not typed exactly as created on the old system.
    Correction below:

    yum -y install < yum.packages.list

    • In fact, the command didn't work for my on CentOS 6.5.

      The reason why this didn't work was for two reasons:
      1. because the command had the wrong double quotes that are pretty printed here.

      rpm -qa --queryformat "%{NAME}"\\n > yum.packages.list

      2. the yum install command didn't accept the file's contents properly. so I used cat instead with the following command:

      yum -y install $(cat yum.packages.list)

      There were some packages that didn't show up as available in the initial install process listing, but the dependencies resolving in the install process fixed it at the end.

  3. The above quotes won't print out correctly in the comments .. so make sure that you use universal double quotes (not left double quote and right double quotes)