How to install kernel 4.x on CentOS 7.x

### References

CentOS 7 最新安定版カーネルインストール、及び切り替え
http://server.etutsplus.com/centos-7-how-to-update-kernel-to-the-latest-mainline-stable/

CentOS7にelrepoからkernel 4系をインストール
https://qiita.com/tukiyo3/items/19866eebd0c52207f99c

### elrepo

```
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

rpm -Uvh http://elrepo.org/linux/kernel/el7/x86_64/RPMS/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

yum --enablerepo=elrepo-kernel install kernel-ml
#yum --enablerepo=elrepo-kernel install kernel-lt

```

### yum swap kernel-headers

```
yum --enablerepo=elrepo-kernel -y swap kernel-headers -- kernel-ml-headers
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * elrepo: elrepo.org
 * elrepo-kernel: elrepo.org
 * epel: ftp.jaist.ac.jp
 * epel-debuginfo: ftp.tsukuba.wide.ad.jp
 * epel-source: ftp.jaist.ac.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Resolving Dependencies
--> Running transaction check
---> Package kernel-headers.x86_64 0:3.10.0-693.17.1.el7 will be erased
---> Package kernel-ml-headers.x86_64 0:4.15.7-1.el7.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch      Version                  Repository        Size
================================================================================
Installing:
 kernel-ml-headers    x86_64    4.15.7-1.el7.elrepo      elrepo-kernel    1.2 M
Removing:
 kernel-headers       x86_64    3.10.0-693.17.1.el7      @updates         3.5 M

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

Total download size: 1.2 M
Downloading packages:
kernel-ml-headers-4.15.7-1.el7.elrepo.x86_64.rpm           | 1.2 MB   00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kernel-ml-headers-4.15.7-1.el7.elrepo.x86_64                 1/2 
  Erasing    : kernel-headers-3.10.0-693.17.1.el7.x86_64                    2/2 
  Verifying  : kernel-ml-headers-4.15.7-1.el7.elrepo.x86_64                 1/2 
  Verifying  : kernel-headers-3.10.0-693.17.1.el7.x86_64                    2/2 

Removed:
  kernel-headers.x86_64 0:3.10.0-693.17.1.el7                                   

Installed:
  kernel-ml-headers.x86_64 0:4.15.7-1.el7.elrepo                                

Complete!

```


### yum swap kernel-tools-libs

```
yum --enablerepo=elrepo-kernel -y swap kernel-tools-libs -- kernel-ml-tools-libs

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * elrepo: elrepo.org
 * elrepo-kernel: elrepo.org
 * epel: ftp.jaist.ac.jp
 * epel-debuginfo: ftp.tsukuba.wide.ad.jp
 * epel-source: ftp.jaist.ac.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml-tools-libs.x86_64 0:4.15.7-1.el7.elrepo will be installed
---> Package kernel-tools-libs.x86_64 0:3.10.0-693.17.1.el7 will be erased
--> Processing Dependency: kernel-tools-libs = 3.10.0-693.17.1.el7 for package: kernel-tools-3.10.0-693.17.1.el7.x86_64
--> Running transaction check
---> Package kernel-tools.x86_64 0:3.10.0-693.17.1.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch     Version                  Repository       Size
================================================================================
Installing:
 kernel-ml-tools-libs   x86_64   4.15.7-1.el7.elrepo      elrepo-kernel    58 k
Removing:
 kernel-tools-libs      x86_64   3.10.0-693.17.1.el7      @updates         18 k
Removing for dependencies:
 kernel-tools           x86_64   3.10.0-693.17.1.el7      @updates        259 k

Transaction Summary
================================================================================
Install  1 Package
Remove   1 Package (+1 Dependent package)

Total download size: 58 k
Downloading packages:
kernel-ml-tools-libs-4.15.7-1.el7.elrepo.x86_64.rpm        |  58 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kernel-ml-tools-libs-4.15.7-1.el7.elrepo.x86_64              1/3 
  Erasing    : kernel-tools-3.10.0-693.17.1.el7.x86_64                      2/3 
  Erasing    : kernel-tools-libs-3.10.0-693.17.1.el7.x86_64                 3/3 
  Verifying  : kernel-ml-tools-libs-4.15.7-1.el7.elrepo.x86_64              1/3 
  Verifying  : kernel-tools-libs-3.10.0-693.17.1.el7.x86_64                 2/3 
  Verifying  : kernel-tools-3.10.0-693.17.1.el7.x86_64                      3/3 

Removed:
  kernel-tools-libs.x86_64 0:3.10.0-693.17.1.el7                                

Dependency Removed:
  kernel-tools.x86_64 0:3.10.0-693.17.1.el7                                     

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

Complete!
```

### yum install kernel-ml-tools

```
yum --enablerepo=elrepo-kernel -y install kernel-ml-tools
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * elrepo: elrepo.org
 * elrepo-kernel: elrepo.org
 * epel: ftp.jaist.ac.jp
 * epel-debuginfo: ftp.tsukuba.wide.ad.jp
 * epel-source: ftp.jaist.ac.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml-tools.x86_64 0:4.15.7-1.el7.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch       Version                 Repository         Size
================================================================================
Installing:
 kernel-ml-tools     x86_64     4.15.7-1.el7.elrepo     elrepo-kernel     152 k

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

Total download size: 152 k
Installed size: 350 k
Downloading packages:
kernel-ml-tools-4.15.7-1.el7.elrepo.x86_64.rpm             | 152 kB   00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kernel-ml-tools-4.15.7-1.el7.elrepo.x86_64                   1/1 
  Verifying  : kernel-ml-tools-4.15.7-1.el7.elrepo.x86_64                   1/1 

Installed:
  kernel-ml-tools.x86_64 0:4.15.7-1.el7.elrepo                                  

Complete!
```




### yum swap kernel-devel

```shell-session
yum --enablerepo=elrepo-kernel -y swap kernel-devel -- kernel-ml-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * elrepo: elrepo.org
 * elrepo-kernel: elrepo.org
 * epel: ftp.jaist.ac.jp
 * epel-debuginfo: ftp.tsukuba.wide.ad.jp
 * epel-source: ftp.jaist.ac.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Resolving Dependencies
--> Running transaction check
---> Package kernel-devel.x86_64 0:3.10.0-693.17.1.el7 will be erased
---> Package kernel-ml-devel.x86_64 0:4.15.7-1.el7.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch       Version                 Repository         Size
================================================================================
Installing:
 kernel-ml-devel     x86_64     4.15.7-1.el7.elrepo     elrepo-kernel      12 M
Removing:
 kernel-devel        x86_64     3.10.0-693.17.1.el7     @updates           36 M

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

Total download size: 12 M
Downloading packages:
kernel-ml-devel-4.15.7-1.el7.elrepo.x86_64.rpm             |  12 MB   00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kernel-ml-devel-4.15.7-1.el7.elrepo.x86_64                   1/2 
  Erasing    : kernel-devel-3.10.0-693.17.1.el7.x86_64                      2/2 
  Verifying  : kernel-ml-devel-4.15.7-1.el7.elrepo.x86_64                   1/2 
  Verifying  : kernel-devel-3.10.0-693.17.1.el7.x86_64                      2/2 

Removed:
  kernel-devel.x86_64 0:3.10.0-693.17.1.el7                                     

Installed:
  kernel-ml-devel.x86_64 0:4.15.7-1.el7.elrepo                                  

Complete!
```


### yum remove kernel


```shell-session
yum -y remove kernel

Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-693.17.1.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package       Arch          Version                      Repository       Size
================================================================================
Removing:
 kernel        x86_64        3.10.0-693.17.1.el7          @updates         59 M

Transaction Summary
================================================================================
Remove  1 Package

Installed size: 59 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : kernel-3.10.0-693.17.1.el7.x86_64                            1/1 
  Verifying  : kernel-3.10.0-693.17.1.el7.x86_64                            1/1 

Removed:
  kernel.x86_64 0:3.10.0-693.17.1.el7                                           

Complete!
```