We can exclude a list of packages from being installed or updating from all repositories by specifying that we want to exclude them in the yum.conf file.
This will prevent yum from updating these packages and all future updates will be ignored as we will see here.
To prevent a specific package from receiving updates, we simply edit the /etc/yum.conf file to make use of the ‘exclude’ option.
For example, on my CentOS 7 system I currently have an update available for the ‘epel-release’ package as shown below.
Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.mirror.digitalpacific.com.au * epel: fedora.mirror.serversaustralia.com.au * extras: mirror.nsw.coloau.com.au * updates: centos.mirror.digitalpacific.com.au epel-release.noarch
Now let’s edit the /etc/yum.conf file to specifically exclude updates to this package.
Note that this file is all default except for the ‘exclude’ option that I have added to the bottom of the file, specifying the package that I want to exclude. We can add multiple packages that we want to exclude from being updated by simply adding more afterwards separated by a space.
Now when I perform the same ‘yum check-update epel-release’ command there are no results shown, because the epel-release package has been excluded from the server and will therefore not be updated.
Loaded plugins: fastestmirror, langpacks base | 3.6 kB 00:00:00 epel/x86_64/metalink | 2.9 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 Loading mirror speeds from cached hostfile * base: mirror.nsw.coloau.com.au * epel: fedora.mirror.serversaustralia.com.au * extras: mirror.nsw.coloau.com.au * updates: mirror.nsw.coloau.com.au
While in this example we have excluded a package that is already installed from updating, we can also specify packages that we don’t want to install.
It’s important to keep in mind that doing this will also disable security updates for a package if it’s already installed as all future updates will be excluded which may not be ideal.
We have seen that by performing this simple modification to the /etc/yum.conf file we can easily prevent a specific package from being installed, disabling future updates for that package.