CentOS 7 Upgrade Kernel

(Last Updated On: May 16, 2020)

kernel.org 도 있지만 elrepo 에서 제공하는 커널을 사용하겠다.

1 Update Packages

최신 YUM Repository정보로 업데이트함.

yum -y update

2 Enable elrepo

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

2-1 CentOS 8

yum -y install https://www.elrepo.org/elrepo-release-8.1-1.el8.elrepo.noarch.rpm

2-2 CentOS 7

yum -y install https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm

3 Check Available Kernels

sudo yum list available --disablerepo='*' --enablerepo=elrepo-kernel
Available Packages
kernel-lt.x86_64                               4.4.217-1.el7.elrepo              elrepo-kernel
kernel-lt-devel.x86_64                         4.4.217-1.el7.elrepo              elrepo-kernel
kernel-lt-doc.noarch                           4.4.217-1.el7.elrepo              elrepo-kernel
kernel-lt-headers.x86_64                       4.4.217-1.el7.elrepo              elrepo-kernel
kernel-lt-tools.x86_64                         4.4.217-1.el7.elrepo              elrepo-kernel
kernel-lt-tools-libs.x86_64                    4.4.217-1.el7.elrepo              elrepo-kernel
kernel-lt-tools-libs-devel.x86_64              4.4.217-1.el7.elrepo              elrepo-kernel
kernel-ml.x86_64                               5.6.1-1.el7.elrepo                elrepo-kernel
kernel-ml-devel.x86_64                         5.6.1-1.el7.elrepo                elrepo-kernel
kernel-ml-doc.noarch                           5.6.1-1.el7.elrepo                elrepo-kernel
kernel-ml-headers.x86_64                       5.6.1-1.el7.elrepo                elrepo-kernel
kernel-ml-tools.x86_64                         5.6.1-1.el7.elrepo                elrepo-kernel
kernel-ml-tools-libs.x86_64                    5.6.1-1.el7.elrepo                elrepo-kernel
kernel-ml-tools-libs-devel.x86_64              5.6.1-1.el7.elrepo                elrepo-kernel
perf.x86_64                                    5.6.1-1.el7.elrepo                elrepo-kernel
python-perf.x86_64                             5.6.1-1.el7.elrepo                elrepo-kernel

 

4 Install Latest Kernel

4-1 MAINLINE kernel

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

4-2 Long Term Support kernel

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

5

5-1 Reboot (권장)

재부팅 후 GRUB 부트로더에서 최신커널을 선택해서 부팅.
부팅이 성공적이면 다시 5-2.

5-2 부팅순서 변경 (production에서 매우매우매우 비권장)

5-2-1 GRUB_DEFAULT가 saved 인지 확인
grep GRUB_DEFAULT /etc/default/grub
# grep GRUB_DEFAULT /etc/default/grub
GRUB_DEFAULT=saved
5-2-2 저장되어있는 Kernel 확인
grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
CentOS Linux (5.6.1-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux 7 Rescue 5fcf8f8edca74fab9577cc1ff85475ca (3.10.0-1062.18.1.el7.x86_64)
CentOS Linux (3.10.0-1062.18.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.11.6.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-00a62363617944e08db8db894ba6145e) 7 (Core)

 

5-2-3 기본 부팅 커널로 변경
grub2-set-default "CentOS Linux (5.6.1-1.el7.elrepo.x86_64) 7 (Core)"

맨 위에 새 커널이 있는걸로 보아, 이러한 명령어도 가능 할 거같다.

grub2-set-default "`grep ^menuentry /boot/grub2/grub.cfg | cut -d \"'\" -f2 | head -n 1`"
5-2-3 reboot
reboot

6 Check Kernel Version

# uname -sr
Linux 5.6.1-1.el7.elrepo.x86_64

7 Clear Old Kernel

yum -y install yum-utils
package-cleanup --oldkernels --count=1

not recommend

?????

yum clean all

뭔가.. 기본repo와 kernel이 중복되는 것 같다.