大网数据广告活动
服务器运维问答

Safe way to clear all packages from yum cache?

· 52CE 我爱测

I know that yum clean all doesn't necessarily clear all the package files. I know from " Maybe you want: rm -rf /var/cache/yum " that I might have to, good grief, bluntly clear all of /var/cache/yum . But I've just discovered tha…

问题原文

原帖链接 · Steve Summit · CC BY-SA 4.0

I know that yum clean all doesn't necessarily clear all the package files. I know from "Maybe you want: rm -rf /var/cache/yum" that I might have to, good grief, bluntly clear all of /var/cache/yum. But I've just discovered that I very definitely do not want to clear all of /var/cache/yum, because evidently the record of which packages are installed is also kept down in there somewhere. Without certain files in /var/cache/yum, rpm -qa seems to print nothing.

So is there a simple rule for which other files underneath /var/cache/yum can be manually deleted, to save space by deleting package files that aren't needed (or can be easily redownloaded), but preserving the installation state of the system?

It's possible I'm completely mistaken on one or more of my assumptions here. Corrections welcome if so.

Update: I'm skipping some details here, but copying all of /var/cache/yum from the system that had it to the system that didn't did not fix rpm -qa (it's still printing nothing), so it's looking like one of my assumptions is flawed, and the system's installed state is kept somewhere under /var other than /var/cache/yum.

Update 2: I was wrong in one of my assumptions. As I eventually discovered, and as @shodanshok points out in an answer, the database of packages currently installed is down under /var/lib/rpm, not /var/cache/yum. So clearing all of /var/cache/yum should be safe.

已采纳解答

原帖链接 · shodanshok · CC BY-SA 4.0

Running yum clean all is generally sufficient for all intents and purposes, as it will only leave so little used space behind. The exception is when you disabled a repo before running yum clean all, forbidding yum from clearing that repo cache.

Anyway, deleting /var/cache/yum should have no bad effects, especially because RPM database is located under /var/lib/rpm rather that under /var/cache.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-01-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。