# 清理系统不使用的旧内核

对于系统安装了多个内核，我们可能需要清理部分旧内核，以便释放 `/boot` 目录空间。

检查系统已经安装的内核

```bash
rpm -q kernel
```

## CentOS 7清理旧内核

CentOS 7提供了 `yum-utils` 可以集成到yum中帮助管理软件包

```bash
yum install yum-utils
```

* `package-cleanup` 可以删除旧内核:

```bash
package-cleanup --oldkernels --count=2
```

## CentOS 8清理旧内核

Fedora/CentOS 8使用了dnf，使用以下命令清理

```bash
dnf remove $(dnf repoquery --installonly --latest-limit 2 -q)
```

## 参考

* [How to Delete Old Unused Kernels in CentOS, RHEL and Fedora](https://www.tecmint.com/delete-old-kernels-in-centos-rhel-and-fedora/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/os/linux/redhat/package/delete_old_unused_kernels_in_centos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
