• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How To Retain Current And Older Linux Packages While Doing Update With ‘yum’ Command

by admin

In this post, we shall discuss about how to retain current and older Linux packages while updating the Linux OS with the ‘yum’ command. Note that /etc/yum.conf configuration file contains a [main] section. If required then we can add many additional options under the [main] section. Some of the key-value pairs in the [main] section affect how yum operates.

A sample /etc/yum.conf configuration file looks as below:

# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonlypkgs= kernel-2.6.32-279.2.1.el6.x86_64, kernel-2.6.32-100.24.1.el5
installonly_limit=3
...
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

installonlypkgs directive

Using the “installonlypkgs=space separated list of packages” directive under /etc/yum.conf file, provide a space-separated list of packages which yum can install, but will never update. Refer to the man page of yum.conf for the list of packages which are install-only by default.

# man yum.conf

If we add the installonlypkgs directive to /etc/yum.conf, we need to ensure that we provide the list of Packages that are for install-only, including any of those listed under the installonlypkgs section of man yum.conf.

In particular, kernel packages should always be listed in installonlypkgs (as they are by default), and installonly_limit should always be set to a value greater than 2 so that a backup kernel is always available in case the default one fails to boot.

# vi /etc/yum.conf
installonlypkgs=space separated list of packages

installonly_limit directive

Also please check the installonly_limit directive mentioned as below.

This option sets how many packages listed in the installonlypkgs directive can be installed at the same time. We can mark the value with an integer representing the maximum number of versions that can be installed simultaneously for any single package listed in installonlypkgs.

The defaults for the installonlypkgs directive include several different kernel packages, so be aware that changing the value of installonly_limit also affects the maximum number of installed versions of any single kernel package. The default value listed in /etc/yum.conf is installonly_limit=3, and it is not recommended to decrease this value, particularly below 2.

installonly_limit Number of packages listed in installonlypkgs to keep installed at the same time. Setting to 0 disables this feature.

# vi /etc/yum.conf
installonly_limit=value

We can disable the functionality altogether by setting installonly_limit to 0:

# vi /etc/yum.conf
installonly_limit=0

Using yumdb Command

Alternatively using yumdb command we can set a certain package to be kept from being removed on updates. To use the yumdb command we need to install “yum-utils” package:

# yum install yum-utils

Example of yumdb command:

# yumdb set installonly keep kernel-2.6.32-279.2.1.el6.x86_64

If you want to revert the previous change, you can use this command:

# yumdb del installonly kernel-2.6.32-279.2.1.el6.x86_64

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, Fedora, Linux, OEL 6, OEL 7

Some more articles you might also be interested in …

  1. How to use shell aliases in Linux
  2. Troubleshooting common NFS issues in Linux
  3. just Command Examples in Linux
  4. How to enable additional scsi logging in CentOS/RHEL
  5. CentOS / RHEL : How to Install and Configure OpenSSH Server and Client
  6. Magento 2.3.3 Redis cache grows unlimited
  7. deborphan Command Examples in Linux
  8. ClusterSSH(cssh) – Manage Multiple SSH Sessions on Linux
  9. How to delete unused kernels and keep only the running kernel in CentOS/RHEL
  10. betterlockscreen Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright