Linux RHEL 7.9 Kernel(커널) 업데이트

728x90

안녕하세요!

커널을 업데이트하는 이유는 보안강화, 성능 향상, 하드웨어 지원 개선, 버그 수정, 신규 기능 추가, 소프트웨어 호환성 향상 등이 이유가 있습니다.

커널을 업데이트하는 순서는 다음과 같습니다.

 

커널 업데이트 순서

  1. 시스템의 중요 파일 및 데이터를 백업

  2. 커널을 설치할 작업 위치로 이동(/usr/src)

  3. 커널 소스코드 다운로드(일반적으로 xz라는 압축으로 배포)

  4. 커널.xz 압축해제 

  5. 커널 설치를 위한 정리(make mrproper, make clean)
    mkkefile이 잘못되거나, 업데이트 중 오류 메시지가 생겼을 때 작업을 처리하고 make mrproper, make clean 명령어를 입력하여 파일을 초기 상태로 만들어 다시 시작

  6. 커널 설치 옵션 설정(make menuconfig

  7. 커널 이미지 파일 생성을 위한 컴파일 작업(make bzlmage)
    이미지화가 되고 이 작업을 거쳐야 부팅 시 선택 목록에 출력된다.

  8. 커널 모듈 생성을 위한 컴파일(make modules)
    현재는 7,8번 과정을 make all 명령어로 대체

  9. 커널 모듈 파일 설치하기(make modules_install)
    9번 작업까지가 컴파일이 완료되었다고 생각

  10. 커널 모듈 파일 및 관련 파일 복사.
    grub.conf 파일 수정 (make install)

  11. 재부팅 (새 커널 부팅 테스트)

  12. 새로운 커널 버전 확인 및 시스템 서비스 확인

 

 

 

커널 업데이트 

업데이트 전 현재 커널 버전을 확인

[root@localhost ~]# uname -r
3.10.0-1160.el7.x86_64

 

패키지 업데이트

[root@localhost ~]# yum update

[root@localhost ~]# yum install gcc ncurses ncurses-devel

[root@localhost ~]# yum groupinstall "Development Tools"

yum update를 통해 모든 패키지들을 최신으로 업데이트합니다. 

yum install gcc ncurses ncurses-devel 

  • gcc: GNU Compiler Collection의 약자로, C, C++, Objective-C, Fortran, Ada, Go 등 다양한 프로그래밍 언어를 위한 컴파일러 모음입니다.
  • ncurses: 텍스트 사용자 인터페이스를 구축하기 위한 프로그래밍 라이브러리입니다. 터미널에서 실행되는 메뉴, 색상, 다양한 텍스트 모드 등을 지원합니다.
  • ncurses-devel: ncurses 라이브러리를 개발할 때 필요한 개발 파일(헤더 파일 등)을 포함합니다. 이 패키지는 ncurses를 사용하여 개발을 진행할 때 필요합니다.

yum groupinstall "Development Tools"

  • 이 명령은 "Development Tools" 그룹에 속하는 패키지들을 설치합니다.
  • "Development Tools" 그룹에는 C/C++ 컴파일러, make, 디버거, 기타 여러 도구들이 포함되어 있습니다. 이 그룹은 소프트웨어 개발에 필요한 주요 도구들을 제공합니다
[root@localhost ~]# cd /tmp

[root@localhost ~]# wget http://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/linux-3.15.10.tar.xz
--2024-01-18 02:47:51--  http://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/linux-3.15.10.tar.xz
Resolving mirrors.edge.kernel.org (mirrors.edge.kernel.org)... 147.75.48.161, 2604:1380:40f1:3f00::1
Connecting to mirrors.edge.kernel.org (mirrors.edge.kernel.org)|147.75.48.161|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 79699744 (76M) [application/x-xz]
Saving to: ‘linux-3.15.10.tar.xz’

100%[=======================================================================================================>] 79,699,744  8.02MB/s   in 97s

2024-01-18 02:49:28 (806 KB/s) - ‘linux-3.15.10.tar.xz’ saved [79699744/79699744]

[root@localhost src]# ln -s linux-5.10.85 linux
[root@localhost src]# ll
total 8
drwxr-xr-x.  2 root root    6 Dec 14  2017 debug
drwxr-xr-x.  3 root root   36 Dec 14  2017 kernels
lrwxrwxrwx.  1 root root   13 Jan 18 04:13 linux -> linux-5.10.85

 

 

커널 다운로드

 

wget 명령어로 커널을 다운로드합니다. 

커널 파일을 https://www.kernel.org/ 에서 다운로드합니다. 

 원하는 버전을 선택합니다          

 

최종 경로는 다음과 같습니다.

https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/

 

[root@localhost ~]# wget https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/linux-3.15.10.tar.xz
--2024-01-18 02:47:38--  https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/linux-3.15.10.tar.xz
Resolving mirrors.edge.kernel.org (mirrors.edge.kernel.org)... 147.75.48.161, 2604:1380:40f1:3f00::1
Connecting to mirrors.edge.kernel.org (mirrors.edge.kernel.org)|147.75.48.161|:443... connected.
ERROR: cannot verify mirrors.edge.kernel.org's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=R3’:
  Issued certificate has expired.
To connect to mirrors.edge.kernel.org insecurely, use `--no-check-certificate'.

위와 같은 오류가 나는 경우 https가 아닌 http로 진행합니다.

 

 

압축해제

[root@localhost ~]# ll
total 77840
-rw-------. 1 root root     3007 Jan 16 12:44 anaconda-ks.cfg
-rw-r--r--. 1 root root 79699744 Aug 13  2014 linux-3.15.10.tar.xz
-rw-------. 1 root root     1927 Jan 16 12:44 original-ks.cfg
[root@localhost ~]# tar -Jxvf linux-3.15.10.tar.xz -C /usr/src

tar 명령어를 사용해서 압축을 해제합니다.

 

 

make mrproper, make clean, make menuconfig

[root@localhost src]# cd linux-3.15.10/
[root@localhost linux-3.15.10]# make mrproper
[root@localhost linux-3.15.10]# make clean
[root@localhost linux-3.15.10]# cp /boot/config-`uname -r` ./.config
[root@localhost linux-3.15.10]# make menuconfig



1. make mrproper

이 명령은 커널 소스 디렉토리를 '깨끗한' 상태로 만듭니다. 즉, 이전 컴파일 과정에서 생성된 구성 파일, 바이너리 파일 등을 모두 제거합니다. 이는 새로운 커널 빌드를 시작하기 전에 기존의 구성 및 빌드 파일을 정리하는 데 사용됩니다.

2. make clean

이 명령은 make mrproper보다 덜 강력하지만, 컴파일 과정에서 생성된 오브젝트 파일과 바이너리 파일을 제거합니다. 이는 빌드 디렉토리를 정리하는 데 사용되며, 새로운 커널 빌드를 준비하는 데 도움이 됩니다.

3. cp /boot/config-uname -r ./.config

이 명령은 현재 실행 중인 커널의 구성(config) 파일을 복사하여 새로운 커널 소스 디렉토리의 .config 파일로 저장합니다. uname -r은 현재 실행 중인 커널의 버전을 반환하며, 이를 통해 해당 커널 버전의 구성 파일을 가져옵니다.

4. make menuconfig

make menuconfig 명령은 텍스트 기반의 메뉴를 통해 커널 옵션 및 기능을 구성할 수 있는 인터페이스를 제공합니다. 여기서 사용자는 모듈 지원, 드라이버 옵션, 시스템 기능 등 다양한 커널 옵션을 활성화하거나 비활성화할 수 있습니다.

General setup ---> space를 눌러 들어갑니다.

Enable sustem-call auditing supprot를 space를 눌러 체크해 주고 Save 하고 Exit로 빠져나옵니다.

.config파일로 로드를 하겠냐고 묻습니다. Ok를 누릅니다.

 

 

 

make all

[root@localhost src]# make all

make all 명령어를 실행합니다. 상당히 시간이 오래 걸리게 됩니다. 

[root@localhost src]# make modules_install

make modules_install 명령어로 모듈을 설치합니다.








make install

[root@localhost src]# make install

make install 명령어로 업데이트를 설치합니다.

재부팅 후 부트로더에 접속해 보면 새로운 커널이 생성된 것을 확인할 수 있습니다.

 

 

 

 

 

이상입니다.

감사합니다!

728x90
반응형