Retroactively Minimizing Installed Packages on CentOS 5.1

In my CentOS 5.1 Minimal VPS Install Guide I describe how to install a very lean set of OS packages when starting from scratch. But what if the VPS is preinstalled for you by a hosting provider? There will be things preinstalled that you don’t need, which will slow down backups and updates, and waste the relatively tiny amount of disk space that VPS plans offer. So here are some instructions to help you identify and remove packages that you don’t need, when they’ve already been installed.

The first thing you need is a list of minimal packages that your server must have in order to function. This is somewhat subjective, so you may wish to customize it, but here is a roughly minimal list of yum package names for CentOS 5.1. Save that on your CentOS machine as minimal_package_names.txt.

Next, you need a way to compare this list to the list of what you have installed. Here’s a command line that I used:

(The awk command is there to strip out the version number and architecture from the package name.)

Now you can run that command and see a list of package names that are not in your minimal_package_names.txt list. You can switch that grep command so it looks for ‘>’ instead of ‘<', and see things that you consider minimal which are not currently installed. Then it's just a matter of "yum install foo" and "yum remove foo". I encourage you to use "yum info foo" to make removal decisions one by one, since someone at the ISP probably took the time to research them and thought you might find them useful. You should probably also remove packages in small groups or one by one, because you might be surprised at the dependencies you find. I was surprised to find that uninstalling postgresql-libs would cause httpd (Apache) to be removed as well. But if you want to automate it, just tack | xargs yum remove on the end of that command, and it will automatically remove them all at once. Using this as a starting point, you can change your "minimal" packages list to fit your preferences, or even as a quick and dirty alternative to using Kickstart.

Leave a Reply

Your email address will not be published. Required fields are marked *