Pre-downloading packages from RHEL for faster updates

If you’re like me, you don’t like to do hundreds of tiny updates to live servers.  We batch up our RHEL updates so that we perform them every couple of months (or whenever a serious security issue crops up).  When you take this approach, you may end up with hundreds of packages requiring updates.  Just downloading those updates can take a long time, and if you’re trying to update systems in a small off-hours maintenance window, this can present problems.


yumdownloader to the rescue!  Given a list of all the packages that yum wants to update, yumdownloader can connect to your yum repository (or repositories) and download the packages.  You can then use rpm to install them. 

First, you’ll need to have the yum-utils installed:

Once you’ve done that, you’ll have yumdownloader on your system. 

Here’s a simple script that will pull down the packages:

The first command, yum list updates, gives you a detailed list of the packages that need to be updated.  We use awk and egrep to clean up the list.  We could pipe it straight to xargs, but for some reason, I wanted to see the packages in a simple text file that I could examine while yumdownloader did the heavy lifting.

Create a directory to hold the package files, cd into it, run this script, and wait for the packages to download.  You’ll want to test for missed dependencies with this command:

You may have to go track down a few more packages and call yumdownloader with those, too.  Once you’ve satisifed all dependencies, you can run

to actually update all the packages.

Leave a comment

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