LoginSignup
5
9

More than 3 years have passed since last update.

CentOS 古い kernelを整理する & 増殖させない

Last updated at Posted at 2020-01-12

この記事に書いてある事

  • updateを繰り返しているうちに増えてしまう kernelを整理する
  • 増えすぎないように設定する方法

増えすぎたkernelの整理

  • CentOS6 / 7

    • package-cleanup コマンドを使って整理
      kernelを新しい方から二つ残して後を消す場合
    [user01@centos7 ~]$ sudo package-cleanup --oldkernels --count=2
    
  • CentOS8

    • dnf で installonly_limit 以上に古いパッケージを削除する
      コマンドラインに kernel に関する設定はされていませんが、大抵の場合 installonly に設定されているのはkernel関連だけです。
      dnf repoquery --installonly で確認後にremove --oldinstallonly を実行してください。
      ただ、手元のCentOS8はinstallonly_limit=3に設定されているのであまり整理が必要な状況にならない気がします。
    [user01@cent8 ~]$ dnf repoquery --installonly
    [user01@cent8 ~]$ sudo dnf -y remove --oldinstallonly
    

    kernelが増えすぎないように設定する

  • CentOS6 / 7
    /etc/yum.conf の installonly_limit= で保持する世代数を指定
    0に設定すると無制限になります。通常 5に設定されているようです。

    [user01@centos7 ~]$ sudo 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=5
    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
    
    
  • CentOS8
    /etc/dnf/dnf.conf の installonly_limit= で保持する世代数を指定
    ただし 1,0 に設定すると無制限とみなされます。2が最低の設定値になります。

    [main]
    gpgcheck=1
    installonly_limit=3
    clean_requirements_on_remove=True
    best=True
    [user01@cent8 ~]$ 
    
5
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
9