Linux | CentOS 使用 yum update 时不升级系统和内核

问题

centos 系列在使用 yum update 时,会默认升级内核和系统。不像 Debian/Ubuntu 系列那样,update 和 upgrade 是分开的。这可能会导致出现一些问题,例如驱动、软件不兼容新版本内核/系统组件等,在生产环境下,为了避免因为更新内核导致出现问题,可以禁止 centos 自动更新内核和系统。

解决方案

Centos 内置了一个系统更新配置文件,位于 /etc/yum.conf。如果要禁止升级内核的话,我们只需要在其 [main] 部分末尾新增 “exclude=kernel*” 就可以了。如果要禁止升级系统,那么需要在其 [main] 部分末尾再新增 “exclude=centos-release*” 即可。

实现步骤

  1. vim /etc/yum.conf

在 [main] 的最后添加:

  1. #禁止更新内核
  2. exclude=kernel*
  1. # 禁止更新系统
  2. exclude=centosrelease*

假如您不想修改配置文件,则这样执行命令即可(例如不更新内核):

  1. yum exclude=kernel* update

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

5 × 2 =

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据