我在 VirtualBox 中有一个 centos 7 虚拟机,用于开发 OSS 项目。我并不担心虚拟机的更新,但虚拟机已经下载了待处理的(重要)更新,并且现在已经增长到填满了我的主机分区的整个可用空间......足以让我无法管理快照并且主机操作系统正在抱怨对我。
如何从 CentOS VM 中删除这些更新文件,以及如何将它们设置为不再自动下载?
(我估计虚拟机应该在 20GB 左右……现在已经超过 50GB。)
我根据答案尝试了以下命令,并得到了以下输出。我仍然没有释放主机操作系统上的空间......
[user@centos7host ~]$ yum clean packages
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base epel extras github_git-lfs github_git-lfs-source ius
: updates
0 package files removed
[user@centos7host ~]$ yum clean metadata
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base epel extras github_git-lfs github_git-lfs-source ius
: updates
19 metadata files removed
0 sqlite files removed
0 metadata files removed
[user@centos7host ~]$ yum clean headers
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base epel extras github_git-lfs github_git-lfs-source ius
: updates
0 header files removed
[user@centos7host ~]$ yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base epel extras github_git-lfs github_git-lfs-source ius
: updates
Cleaning up everything
Maybe you want: rm -rf /var/tmp/yum-user-vce72D, to also free up space taken by orphaned data from disabled or removed repos
[user@centos7host ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 43G 15G 29G 34% /
devtmpfs 2.2G 0 2.2G 0% /dev
tmpfs 2.3G 0 2.3G 0% /dev/shm
tmpfs 2.3G 9.4M 2.3G 1% /run
tmpfs 2.3G 0 2.3G 0% /sys/fs/cgroup
tmpfs 2.3G 24K 2.3G 1% /tmp
/dev/sda1 1014M 282M 733M 28% /boot
tmpfs 454M 28K 454M 1% /run/user/1000
[user@centos7host ~]$ rm -rf /var/tmp/yum-user-vce72D/
[user@centos7host ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 43G 15G 29G 34% /
devtmpfs 2.2G 0 2.2G 0% /dev
tmpfs 2.3G 0 2.3G 0% /dev/shm
tmpfs 2.3G 9.4M 2.3G 1% /run
tmpfs 2.3G 0 2.3G 0% /sys/fs/cgroup
tmpfs 2.3G 24K 2.3G 1% /tmp
/dev/sda1 1014M 282M 733M 28% /boot
tmpfs 454M 32K 454M 1% /run/user/1000
[user@centos7host ~]$
答案1
可以使用以下命令:
清理包列表:
yum clean packages
要删除每个已启用存储库的元数据,请使用以下命令:
yum clean metadata
要删除包头,请使用以下命令:
yum clean headers
要清除所有缓存信息,请使用以下命令:
yum clean all
找到更多信息:这里
我会禁用更新守护进程:PackageKit
要禁用通过 PackageKit 进行自动更新,我们需要停止“packagekit”服务并永久禁用它。
systemctl stop packagekit systemctl mask packagekit Create symlink from /etc/systemd/system/packagekit.service to /dev/null.
有关如何执行此操作的更多信息是:这里