RHEL 10 的 DNF 行为变化
RHEL 10 的包管理器没有换成 DNF5——至少在 10.2 仍是 DNF 4.20。真正会咬人的是三处行为变化:模块弃用、filelists 元数据默认不下载、debug 插件被移除。本页用 UBI 10.2 容器实测,并给出升级前的脚本检查清单。
在 registry.access.redhat.com/ubi10/ubi(aarch64,digest sha256:b0a29d36…,Red Hat Enterprise Linux 10.2 (Coughlan))容器内实际执行:
cat /etc/redhat-releasednf --version | head -2rpm -q dnf dnf-plugins-corednf module listdnf config-manager --dump | grep -iE 'optional_metadata|filelists'dnf clean all && dnf makecachefind /var/cache/dnf -name '*filelists*' | wc -ldnf --setopt=optional_metadata_types=filelists makecachefind /var/cache/dnf -name '*filelists*' | wc -ldnf debug-dumpdnf debug-restore原始输出:plans/content-expansion/evidence/rhel/rhel-dnf-behavior/commands.log(sha256 90021bff3c0b4e73…)。
另在 PVE 390 rhel10-lab(RHEL 10.2 x86_64,内核 6.12.0-211.7.3.el10_2)复核 dnf --version、dnf module list、dnf debug-dump:版本同为 4.20.0,模块弃用警告与 debug 插件缺失一致;日志 evidence/rhel/rhel-dnf-behavior/rhel-vm.log,控制台截图 shots/02-dnf-version.png、shots/03-module-warning.png。
RHEL 10 仍是 DNF 4.20,不是 DNF5
Section titled “RHEL 10 仍是 DNF 4.20,不是 DNF5”Red Hat Enterprise Linux release 10.2 (Coughlan)4.20.0dnf-4.20.0-22.el10_2.noarchdnf5 命令不存在,UBI 仓库也检索不到 dnf5 包。网上“EL10 已换 DNF5”的说法,把 Fedora 41 的事件套到了 RHEL 上;RHEL 10 的 4.x 语法、插件与 python3-dnf API 继续有效。
变化一:模块功能已弃用
Section titled “变化一:模块功能已弃用”dnf module list 仍能执行,但会先打印弃用警告:
WARNING: modularity is deprecated, and functionality will be removed in a future release of DNF5.官方 adoption 文档 22.1 的口径是:RHEL 10 不再计划提供以模块形式发布的 Application Stream。对存量系统的实际影响:
- 依赖
dnf module enable/install的自动化脚本,短期内还能跑,但不应再作为新部署的前提; - 升级评估时,把“模块流版本”从依赖清单里改成普通 RPM 包版本;
- 不要按 Fedora 的模块退场时间表规划 RHEL,二者不同步。
变化二:filelists 元数据默认不下载
Section titled “变化二:filelists 元数据默认不下载”RHEL 10 默认不再下载仓库的 filelists 元数据(它体积大、多数操作不需要)。实测:
optional_metadata_types = # 默认空filelists after default makecache: 0filelists after setopt: 3后果是:当某个包依赖的是文件路径而不是包名时,DNF 可能报依赖解析错误,并提示:
(try to add '--skip-broken' to skip uninstallable packages or '--setopt=optional_metadata_types=filelists' to load additional filelists metadata)两种处置:
- 单次命令加
--setopt=optional_metadata_types=filelists; - 长期需要就在
/etc/dnf/dnf.conf的[main]里加optional_metadata_types=filelists(会增大元数据下载量)。
变化三:debug 插件已移除
Section titled “变化三:debug 插件已移除”dnf-plugins-core 里不再包含 debug 插件:
No such command: debug-dump. Please use /usr/bin/dnf --helpNo such command: debug-restore. Please use /usr/bin/dnf --help官方给出的替代:
| 原用法 | RHEL 10 替代 |
|---|---|
dnf debug-dump 列出已装包 | dnf repoquery --installed 或 dnf list --installed |
dnf debug-dump 列仓库 | dnf repolist -v |
| 复制源机包列表到目标机 | dnf repoquery --installed >/tmp/list,再 dnf install $(</tmp/list) |
升级前的脚本检查清单
Section titled “升级前的脚本检查清单”- 脚本里是否出现
dnf module?有就改成普通包名/版本锁定,别等它失效; - 是否用文件路径做依赖(
dnf install /usr/bin/...)?在 RHEL 10 上显式加--setopt=optional_metadata_types=filelists; - 是否调用
dnf debug-dump/debug-restore?换成repoquery --installed与repolist -v; - 是否按 DNF5 语法写了
dnf5命令?RHEL 10 没有dnf5,改回dnf; - 是否假设
dnf history/versionlock行为变化?RHEL 10 仍是 DNF4 语义,按原行为测试即可。
未实测与边界
Section titled “未实测与边界”- x86_64 的 RHEL 10.2 虚拟机已复核 dnf 版本、模块警告与 debug 插件缺失;filelists 计数因未注册、无仓库未复测;
- 未对比 RHEL 9.6 的同名命令输出;
- 未验证“未来 RHEL 10.x 引入 DNF5”的时间表——官方只说模块功能会在未来的 DNF5 版本移除,没有给 RHEL 的日期;
- 未测试第三方仓库(EPEL 等)在 filelists 缺省下的表现。
- RHEL 仓库与内容视图 — 订阅仓库的启用与核对
- RHEL 安装 — 安装与首启注册
- 官方:Considerations in adopting RHEL 10 · 22.1 Notable changes to DNF
- 官方:Managing software with the DNF tool
以下截图来自 PVE 上的实测环境,仅保留关键步骤。


