본문 바로가기

운영체제/Unix & Linux

리눅스 부팅 커널 변경 및 커널 업그레이드

반응형

1.설치전 요구사항

/boot 용량 100M 이상 여유가 있는지 확인

2. 부팅 환경 파일

 /boot/grub2/grub.cfg  ==> bios 환경

 /boot/efi/EFI/<centos or redhat>/grub.cfg  ==> efi 환경

3. 디폴트 부팅 커널 변경 방법
 3.1 부팅 커널 목록 확인(efi 환경)
  > awk -F\' '$1=="menuentry " {print $2}' /boot/efi/EFI/centos/grub.cfg  ==> centos

  > awk -F\' '$1=="menuentry " {print $2}' /boot/efi/EFI/redhat/grub.cfg   ==> redhat

** bios 환경일 경우 /boot/grub2/grub.cfg 

 3.2 디폴트 커널 변경

 방법1)
  > grub2-set-default 'Red Hat Enterprise Linux Server (3.10.0-1160.el7.x86_64) 7.9 (Maipo)'
 **  'Red Hat Enterprise Linux Server (3.10.0-1160.el7.x86_64) 7.9 (Maipo)' 은 3.1 에서 확인인 커널 목록
 ** grub2-set-default 은 /boot/efi/EFI/<centos or redhat>/grubenv 파일을 업데이트

방법2)
> grubby --info=ALL
> grub2-set-default 0  ==> 0은 index 값

3. 커널 업그레이드

 3.1 버전별 커널 의존성 파일

[root@rhel79 ~]# yum deplist kernel
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
=== RedHat 7.9 ===
package: kernel.x86_64 3.10.0-1160.76.1.el7
  dependency: /bin/sh
   provider: bash.x86_64 4.2.46-35.el7_9
  dependency: /usr/sbin/new-kernel-pkg
   provider: grubby.x86_64 8.28-26.el7
  dependency: dracut >= 033-502
   provider: dracut.x86_64 033-572.el7
  dependency: fileutils
   provider: coreutils.x86_64 8.22-24.el7_9.2
  dependency: grubby >= 8.28-2
   provider: grubby.x86_64 8.28-26.el7
  dependency: initscripts >= 8.11.1-1
   provider: initscripts.x86_64 9.49.53-1.el7_9.1
  dependency: linux-firmware >= 20190429-72
   provider: linux-firmware.noarch 20200421-80.git78c0348.el7_9
  dependency: module-init-tools >= 3.16-2
   provider: kmod.x86_64 20-28.el7
  dependency: system-release
   provider: redhat-release-server.x86_64 7.9-6.el7_9
[root@rhel79 ~]# 

===== CentOS 7.6 =====
[root@testsvr1 7]# yum deplist kernel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.packet.stream
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
package: kernel.x86_64 3.10.0-1160.76.1.el7
  dependency: /bin/sh
   provider: bash.x86_64 4.2.46-35.el7_9
  dependency: /usr/sbin/new-kernel-pkg
   provider: grubby.x86_64 8.28-26.el7
  dependency: dracut >= 033-502
   provider: dracut.x86_64 033-572.el7
  dependency: fileutils
   provider: coreutils.x86_64 8.22-24.el7_9.2
  dependency: grubby >= 8.28-2
   provider: grubby.x86_64 8.28-26.el7
  dependency: initscripts >= 8.11.1-1
   provider: initscripts.x86_64 9.49.53-1.el7_9.1
  dependency: linux-firmware >= 20190429-72
   provider: linux-firmware.noarch 20200421-80.git78c0348.el7_9
  dependency: module-init-tools >= 3.16-2
   provider: kmod.x86_64 20-28.el7
  dependency: system-release
   provider: centos-release.x86_64 7-9.2009.1.el7.centos
[root@testsvr1 7]#

3.2. 커널 다운로드만
[root@testsvr1 ~]# yum install -y kernel --downloadonly --downloaddir=/root/packages
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-1160.76.1.el7 will be installed
--> Processing Dependency: linux-firmware >= 20190429-72 for package: kernel-3.10.0-1160.76.1.el7.x86_64
--> Running transaction check
---> Package linux-firmware.noarch 0:20180911-69.git85c5d90.el7 will be updated
---> Package linux-firmware.noarch 0:20200421-80.git78c0348.el7_9 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================
 Package                                Arch                           Version                                              Repository                       Size
==================================================================================================================================================================
Installing:
 kernel                                 x86_64                         3.10.0-1160.76.1.el7                                 updates                          50 M
Updating for dependencies:
 linux-firmware                         noarch                         20200421-80.git78c0348.el7_9                         updates                          80 M

Transaction Summary
==================================================================================================================================================================
Install  1 Package
Upgrade             ( 1 Dependent package)

Total download size: 131 M
Background downloading packages, then exiting:
exiting because "Download Only" specified
[root@testsvr1 ~]#

 

3.2 rpm 명령어를 이용한 커널 업그레이드

[root@testsvr3 packages]# uname -a
Linux testsvr3 3.10.0-1160.66.1.el7.x86_64 #1 SMP Wed May 18 16:02:34 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[root@testsvr3 packages]# ls
kernel-3.10.0-1160.76.1.el7.x86_64.rpm
[root@testsvr3 packages]# rpm -Uvh kernel-3.10.0-1160.76.1.el7.x86_64.rpm 

** 기존 커널을 유지하려면 rpm -i 명령어 사용
준비 중...                         ################################# [100%]
Updating / installing...
   1:kernel-3.10.0-1160.76.1.el7      ################################# [ 33%]
Cleaning up / removing...
   2:kernel-3.10.0-1160.66.1.el7      ################################# [ 67%]
   3:kernel-3.10.0-1160.el7           ################################# [100%]
[root@testsvr3 packages]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        3.8G     0  3.8G   0% /dev
tmpfs           3.9G   12K  3.9G   1% /dev/shm
tmpfs           3.9G   12M  3.8G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda4        16G  4.0G   12G  26% /
/dev/sda2       197M  104M   94M  53% /boot
/dev/sda1       100M   12M   89M  12% /boot/efi
tmpfs           781M     0  781M   0% /run/user/1001
tmpfs           781M     0  781M   0% /run/user/0
[root@testsvr3 packages]# 


yum update kernel -y --downloadonly 시 --downloaddir 옵션을 생략할 경우 디폴트 다운로드 위치
:  /var/cache/yum/base/packages

반응형