Skip to main content

安裝最新的 Kernel,並移除舊的核心套件

請先匯入最新的核心來源,指令如下:

# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
正在擷取 http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
正在擷取 http://elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
正在準備…                       ################################# [100%]
Updating / installing...
   1:elrepo-release-7.0-4.el7.elrepo  ################################# [100%]

然後安裝最新的核心 5.x 版本。

# yum --enablerepo=elrepo-kernel install kernel-ml -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror01.idc.hinet.net
 * elrepo: ftp.yz.yamagata-u.ac.jp
 * elrepo-kernel: ftp.yz.yamagata-u.ac.jp
 * extras: mirror01.idc.hinet.net
 * updates: mirror01.idc.hinet.net
elrepo                                                   | 3.0 kB     00:00
elrepo-kernel                                            | 3.0 kB     00:00
(1/2): elrepo/primary_db                                   | 580 kB   00:00
(2/2): elrepo-kernel/primary_db                            | 2.1 MB   00:00
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml.x86_64 0:5.18.6-1.el7.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package        Arch        Version                    Repository          Size
================================================================================
Installing:
 kernel-ml      x86_64      5.18.6-1.el7.elrepo        elrepo-kernel       56 M

Transaction Summary
================================================================================
Install  1 Package

Total download size: 56 M
Installed size: 257 M
Is this ok [y/d/N]: y
Downloading packages:
kernel-ml-5.18.6-1.el7.elrepo.x86_64.rpm                   |  56 MB   00:05
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : kernel-ml-5.18.6-1.el7.elrepo.x86_64                         1/1
  Verifying  : kernel-ml-5.18.6-1.el7.elrepo.x86_64                         1/1

Installed:
  kernel-ml.x86_64 0:5.18.6-1.el7.elrepo

Complete!

然後查詢一下目前有安裝在系統上的核心版本,指令如下:

# rpm -qa |grep kernel
kernel-tools-3.10.0-1160.66.1.el7.x86_64
kernel-3.10.0-1160.49.1.el7.x86_64
kernel-tools-libs-3.10.0-1160.66.1.el7.x86_64
kernel-3.10.0-1160.66.1.el7.x86_64
kernel-3.10.0-1160.53.1.el7.x86_64
kernel-3.10.0-1160.59.1.el7.x86_64
kernel-3.10.0-1160.62.1.el7.x86_64
kernel-ml-5.18.6-1.el7.elrepo.x86_64

接下來移掉舊版本的 kernel,以及其它核心的 tools、libs 套件,因為等一下要改安裝 kernel-5.18 的 libs、tools 等套件,會有衝突,故要先移除舊的,不過要小心處理,不要移錯,不然有可能等一下開不了機!以本例來說,我們要移掉以下套件,範例如下。

# yum remove kernel-tools-3.10.0-1160.66.1.el7.x86_64 kernel-tools-libs-3.10.0-1160.66.1.el7.x86_64
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package kernel-tools.x86_64 0:3.10.0-1160.66.1.el7 will be erased
---> Package kernel-tools-libs.x86_64 0:3.10.0-1160.66.1.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package               Arch       Version                    Repository    Size
================================================================================
Removing:
 kernel-tools          x86_64     3.10.0-1160.66.1.el7       @updates     337 k
 kernel-tools-libs     x86_64     3.10.0-1160.66.1.el7       @updates      18 k

Transaction Summary
================================================================================
Remove  2 Packages

Installed size: 355 k
Is this ok [y/N]:確認再按 y 鍵

移掉後,再查詢一下目前的 Kernel 版本。

# rpm -qa|grep kernel                                    kernel-3.10.0-1160.49.1.el7.x86_64
kernel-3.10.0-1160.66.1.el7.x86_64
kernel-3.10.0-1160.53.1.el7.x86_64
kernel-3.10.0-1160.59.1.el7.x86_64
kernel-3.10.0-1160.62.1.el7.x86_64
kernel-ml-5.18.6-1.el7.elrepo.x86_64

除了 kernel-ml-5.18.6-1.el7.elrepo.x86_64kernel-3.10.0-1160.66.1.el7.x86_64 外,其它舊版本都可以移掉了。

# yum remove kernel-3.10.0-1160.49.1.el7.x86_64 kernel-3.10.0-1160.53.1.el7.x86_64 kernel-3.10.0-1160.59.1.el7.x86_64 kernel-3.10.0-1160.62.1.el7.x86_64
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-1160.49.1.el7 will be erased
---> Package kernel.x86_64 0:3.10.0-1160.53.1.el7 will be erased
---> Package kernel.x86_64 0:3.10.0-1160.59.1.el7 will be erased
---> Package kernel.x86_64 0:3.10.0-1160.62.1.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package       Arch          Version                      Repository       Size
================================================================================
Removing:
 kernel        x86_64        3.10.0-1160.49.1.el7         @updates         64 M
 kernel        x86_64        3.10.0-1160.53.1.el7         @updates         64 M
 kernel        x86_64        3.10.0-1160.59.1.el7         @updates         64 M
 kernel        x86_64        3.10.0-1160.62.1.el7         @updates         64 M

Transaction Summary
================================================================================
Remove  4 Packages

Installed size: 257 M
Is this ok [y/N]:一樣確認後再按 y 鍵

再安裝新核心的表頭、libs 及 tools 套件。

# yum --enablerepo=elrepo-kernel install kernel-ml-headers kernel-ml-tools kernel-ml-tools-libs -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror01.idc.hinet.net
 * elrepo: ftp.ne.jp
 * elrepo-kernel: ftp.ne.jp
 * extras: mirror01.idc.hinet.net
 * updates: mirror01.idc.hinet.net
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml-headers.x86_64 0:5.18.6-1.el7.elrepo will be installed
---> Package kernel-ml-tools.x86_64 0:5.18.6-1.el7.elrepo will be installed
---> Package kernel-ml-tools-libs.x86_64 0:5.18.6-1.el7.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch     Version                  Repository       Size
================================================================================
Installing:
 kernel-ml-headers      x86_64   5.18.6-1.el7.elrepo      elrepo-kernel   1.6 M
 kernel-ml-tools        x86_64   5.18.6-1.el7.elrepo      elrepo-kernel   267 k
 kernel-ml-tools-libs   x86_64   5.18.6-1.el7.elrepo      elrepo-kernel   152 k

Transaction Summary
================================================================================
Install  3 Packages

Total download size: 2.0 M
Installed size: 6.2 M
Downloading packages:
(1/3): kernel-ml-tools-5.18.6-1.el7.elrepo.x86_64.rpm      | 267 kB   00:00
(2/3): kernel-ml-tools-libs-5.18.6-1.el7.elrepo.x86_64.rpm | 152 kB   00:00
(3/3): kernel-ml-headers-5.18.6-1.el7.elrepo.x86_64.rpm    | 1.6 MB   00:00
--------------------------------------------------------------------------------
Total                                              2.6 MB/s | 2.0 MB  00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kernel-ml-tools-libs-5.18.6-1.el7.elrepo.x86_64              1/3
  Installing : kernel-ml-tools-5.18.6-1.el7.elrepo.x86_64                   2/3
  Installing : kernel-ml-headers-5.18.6-1.el7.elrepo.x86_64                 3/3
  Verifying  : kernel-ml-headers-5.18.6-1.el7.elrepo.x86_64                 1/3
  Verifying  : kernel-ml-tools-5.18.6-1.el7.elrepo.x86_64                   2/3
  Verifying  : kernel-ml-tools-libs-5.18.6-1.el7.elrepo.x86_64              3/3

Installed:
  kernel-ml-headers.x86_64 0:5.18.6-1.el7.elrepo
  kernel-ml-tools.x86_64 0:5.18.6-1.el7.elrepo
  kernel-ml-tools-libs.x86_64 0:5.18.6-1.el7.elrepo

Complete!

最後再更新一下,確認是否還有其它更新套件。

# yum update -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror01.idc.hinet.net
 * elrepo: hkg.mirror.rackspace.com
 * extras: mirror01.idc.hinet.net
 * updates: mirror01.idc.hinet.net
Resolving Dependencies
--> Running transaction check
---> Package elrepo-release.noarch 0:7.0-4.el7.elrepo will be updated
---> Package elrepo-release.noarch 0:7.0-5.el7.elrepo will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch         Version                   Repository    Size
================================================================================
Updating:
 elrepo-release       noarch       7.0-5.el7.elrepo          elrepo       8.6 k

Transaction Summary
================================================================================
Upgrade  1 Package

Total download size: 8.6 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
elrepo-release-7.0-5.el7.elrepo.noarch.rpm                 | 8.6 kB   00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : elrepo-release-7.0-5.el7.elrepo.noarch                       1/2
  Cleanup    : elrepo-release-7.0-4.el7.elrepo.noarch                       2/2
  Verifying  : elrepo-release-7.0-5.el7.elrepo.noarch                       1/2
  Verifying  : elrepo-release-7.0-4.el7.elrepo.noarch                       2/2

Updated:
  elrepo-release.noarch 0:7.0-5.el7.elrepo

Complete!