需要释放 /var/cache/apt/archives 中的空间以应用更新

需要释放 /var/cache/apt/archives 中的空间以应用更新

我是一名 Windows 用户,但我们的 Linux 用户不在,所以请原谅我的无知。

我有一台运行 20.04 的服务器,它显示我有很多更新需要应用。当我运行命令 sudo apt-get updates 时,它会滚动浏览更新,然后出现错误“写入输出文件时出错 - 写入(28:设备上没有剩余空间)

当我跑步时df -H我看到了这个:

administrator@ntpjjc1:~$ sudo df -H
Filesystem      Size  Used Avail Use% Mounted on
udev            2.1G     0  2.1G   0% /dev
tmpfs           413M  1.3M  412M   1% /run
/dev/sda2        42G  8.3G   32G  21% /
tmpfs           2.1G     0  2.1G   0% /dev/shm
tmpfs           5.3M     0  5.3M   0% /run/lock
tmpfs           2.1G     0  2.1G   0% /sys/fs/cgroup
/dev/sda8       8.9G  3.0M  8.5G   1% /home
/dev/sda4       2.1G  1.9G   37M  99% /var
/dev/sda3       512M   70k  474M   1% /tmp
/dev/loop0       59M   59M     0 100% /snap/core18/2538
/dev/loop1       59M   59M     0 100% /snap/core18/2785
/dev/loop2       67M   67M     0 100% /snap/core20/1695
/dev/loop6       56M   56M     0 100% /snap/snapd/19361
/dev/loop5       97M   97M     0 100% /snap/lxd/24061
/dev/loop3       97M   97M     0 100% /snap/lxd/23991
/dev/loop4       67M   67M     0 100% /snap/core20/1891
/dev/sda6       5.3G   74M  4.9G   2% /var/log
/dev/sda5       2.1G   33k  2.0G   1% /var/tmp
/dev/sda7       2.1G  529k  2.0G   1% /var/log/audit
tmpfs           413M     0  413M   0% /run/user/1000

好的,看起来好像问题出在 /var 上……

当我运行时,sudo du /var -h dl我发现它的/var/lib/snapd大小为 1.4G,并且/var/lib/snapd/snaps占用了 712M。

当我尝试运行时,sudo apt upgrade我收到以下错误消息:“您可能需要运行apt --fix-broken install来更正这些问题。以下软件包具有未满足的依赖关系:”

当我运行时,sudo apt --fix broken install收到以下错误:You don't have enough free space in /var/cache/apt/archives

administrator@ntpjjc1:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  linux-generic linux-headers-5.4.0-150 linux-headers-5.4.0-150-generic linux-headers-generic linux-image-5.4.0-150-generic linux-image-generic
  linux-modules-5.4.0-150-generic linux-modules-extra-5.4.0-150-generic open-vm-tools
Suggested packages:
  fdutils linux-doc | linux-source-5.4.0 linux-tools open-vm-tools-desktop
The following NEW packages will be installed:
  linux-headers-5.4.0-150 linux-headers-5.4.0-150-generic linux-image-5.4.0-150-generic linux-modules-5.4.0-150-generic
  linux-modules-extra-5.4.0-150-generic
The following packages will be upgraded:
  linux-generic linux-headers-generic linux-image-generic open-vm-tools
4 upgraded, 5 newly installed, 0 to remove and 197 not upgraded.
5 not fully installed or removed.
Need to get 77.9 MB of archives.
After this operation, 380 MB of additional disk space will be used.
E: You don't have enough free space in /var/cache/apt/archives/.

最后,当我跑步的时候sudo du /var/cache/apt/archives/ -h

dministrator@ntpjjc1:~$ sudo du /var/cache/apt/archives/ -h
4.0K    /var/cache/apt/archives/partial
20K     /var/cache/apt/archives/

所以,我的问题是,如何释放空间以便安装更新?

我已经运行了以下命令:

sudo apt clean
sudo apt autoclean
sudo apt autoremove

当我运行时,sudo apt autoremove我回到上面提到的损坏的依赖关系错误。

我似乎陷入了一个循环,但不确定什么命令可以打破这个循环。

谢谢!-迈克

答案1

您有一些旧的快照版本可以删除,这样可以释放一些空间。

sudo snap remove core18 --revision=2538
sudo snap remove core20 --revision=1695
sudo snap remove lxd --revision=23991

这些是这些软件包的先前版本,不需要。它们只在您需要将损坏的软件包恢复为正常工作时才保留。

相关内容