Remove Old Kernel Image from CentOS 7

오래된 커널(Kernel) 이미지 삭제 가이드

리눅스 서버를 운영하다보면 보안패치 등의 이유로 Kernel 업데이트가 종종 발생 합니다. 디스크 파티션을 수동으로 생성하여 /boot 디렉토리의 파티션 용량을 넉넉하게 주었다면 상관없겠지만 파티션을 자동 생성으로 설치하였다면 오래된 Kernel(이하 커널)들의 이미지가 쌓여 디스크 공간이 부족해 집니다.

또한 디스크 공간 부족으로 인해 에러가 발생하여 커널 업데이트가 안되기도 합니다. CentOS 7 에서는 이를 해결하기 위한 방법으로 크게 3가지가 있습니다.

1. 수동 삭제 : package-cleanup 명령을 이용하여 수동으로 오래된 커널 이미지들을 삭제
2. 자동 삭제 : 자동으로 업데이트 시 오래된 커널 이미지를 삭제하도록 설정
3. 커널 고정 : 커널 업데이트를 하지 못하게 고정

수동 삭제

보존할 최신 커널 갯수를 count 옵션을 이용하여 설정해 줍니다.

[root@172-16-11-9 ~]# yum install -y yum-utils
[root@172-16-11-9 ~]# package-cleanup --oldkernels --count=2

자동 삭제

installonly_limit 값에 보존할 커널 갯수를 지정해 줍니다.
: vi /etc/yum.conf

installonly_limit=2

커널 고정

UPDATEDEFAULT 값을 no 로 설정해 줍니다.
: vi /etc/sysconfig/kernel

UPDATEDEFAULT=no

이 방법들 외에도 yum update 시에 exclude 를 주어 커널 업데이트를 제외해 줄 수도 있습니다.

[root@172-16-11-9 ~]# yum update --exclude=kernel

이 방식은 업데이트 할 때마다 해줘야 하는 불편함이 있기 때문에 아래와 같이 설정 파일에 직접 exclude 를 줄 수도 있습니다.
: vi /etc/yum.conf

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=2
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release


#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

exclude=kernel*

You may also like...

Subscribe
Notify of
guest

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x