/var/lib/ 占用了我的大部分空间

/var/lib/ 占用了我的大部分空间

我有一台 Digital Ocean VPS,配备 2GB RAM、50GB 空间和 1 个 vCPU。运行 Ubuntu Server 20.04 LTS

但是,我只剩下 16GB 了。进一步研究后,我发现我的 /var/lib 目录占用了 22GB。但是,当我查看这些文件夹时,我没有看到任何文件占用了那么多空间。

这是为 Wordpress 安装运行 LAMP。我有两个虚拟主机。/var/www 目录仅占用 6GB,我能够处理所有事情。

uname -a
Linux website 5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

aaron@website:/var/lib$ ls
AccountsService    dpkg             man-db         phpmyadmin   tpm
PackageKit         fail2ban         mecab          plymouth     ubuntu-advantage
apache2            fwupd            misc           polkit-1     ubuntu-release-upgrader
apt                ghostscript      mysql          private      ucf
boltd              git              mysql-files    python       unattended-upgrades
clamav             grub             mysql-keyring  shim-signed  update-manager
cloud              initramfs-tools  mysql-upgrade  snapd        update-notifier
command-not-found  landscape        os-prober      snmp         usbutils
dbus               letsencrypt      pam            sudo         vim
dhcp               logrotate        php            systemd
aaron@eastonparkwiki:/var/lib$ dirsize
22G     .
aaron@website:/var/lib$ dirdu
du: cannot read directory './apt/lists/partial': Permission denied
du: cannot read directory './mysql-keyring': Permission denied
du: cannot read directory './snapd/cookie': Permission denied
du: cannot read directory './snapd/cache': Permission denied
du: cannot read directory './snapd/void': Permission denied
du: cannot read directory './mysql': Permission denied
du: cannot read directory './mysql-files': Permission denied
du: cannot read directory './update-notifier/package-data-downloads/partial': Permission denied
du: cannot read directory './polkit-1': Permission denied
du: cannot read directory './AccountsService/users': Permission denied
du: cannot read directory './php/sessions': Permission denied
du: cannot read directory './private': Permission denied
du: cannot read directory './fwupd/gnupg': Permission denied
598M    ./snapd/snaps
334M    ./clamav
197M    ./apt/lists
156M    ./snapd/seed/snaps
51M     ./mecab/dic/ipadic-utf8
40M     ./mecab/dic/ipadic
32M     ./dpkg/info
3.2M    ./command-not-found
1.8M    ./dpkg
636K    ./fwupd/remotes.d/lvfs
608K    ./usbutils
484K    ./snapd/apparmor/profiles
324K    ./ucf/cache
292K    ./systemd/deb-systemd-helper-enabled
292K    ./snapd/seccomp/bpf
200K    ./dpkg/alternatives
164K    ./cloud/instances/252343267/sem
144K    ./systemd/catalog
112K    ./ucf
108K    ./cloud/instances/252343267
aaron@website:/var/lib$ ls -lha
total 212K
drwxr-xr-x 51 root      root      4.0K Jun 28 12:12 .
drwxr-xr-x 14 root      root      4.0K Jun 27 09:13 ..
drwxr-xr-x  4 root      root      4.0K May 18 16:41 AccountsService
drwxr-xr-x  2 root      root      4.0K Jun 27 09:11 PackageKit
drwxr-xr-x  5 root      root      4.0K Jun 27 09:14 apache2
drwxr-xr-x  5 root      root      4.0K Jul 23 15:52 apt
drwxr-xr-x  2 root      root      4.0K Sep 10  2020 boltd
drwxr-xr-x  2 clamav    clamav    4.0K Jul 23 16:00 clamav
drwxr-xr-x  8 root      root      4.0K Jul 23 03:00 cloud
drwxr-xr-x  2 root      root      4.0K Jul 23 11:58 command-not-found
drwxr-xr-x  2 root      root      4.0K Jun 26 22:41 dbus
drwxr-xr-x  2 root      root      4.0K Apr 10  2020 dhcp
drwxr-xr-x  7 root      root      4.0K Jul 23 15:53 dpkg
drwxr-xr-x  2 root      root      4.0K Jun 27 12:08 fail2ban
drwxr-xr-x  6 root      root      4.0K Jun 27 09:14 fwupd
drwxr-xr-x  4 root      root      4.0K Jun 27 09:15 ghostscript
drwxr-xr-x  2 root      root      4.0K Mar  4 07:01 git
drwxr-xr-x  4 root      root      4.0K May 18 16:41 grub
drwxr-xr-x  2 root      root      4.0K Jul 23 06:20 initramfs-tools
drwxr-xr-x  2 landscape landscape 4.0K May 18 16:43 landscape
drwxr-xr-x  4 root      root      4.0K Jul 23 06:09 letsencrypt
drwxr-xr-x  2 root      root      4.0K Jul 23 00:00 logrotate
drwxr-xr-x  2 root      root      4.0K May 18 16:43 man-db
drwxr-xr-x  3 root      root      4.0K Jun 27 09:13 mecab
drwxr-xr-x  2 root      root      4.0K Apr 15  2020 misc
drwx------  9 mysql     mysql      12K Jul 23 03:00 mysql
drwx------  2 mysql     mysql     4.0K Jun 27 09:14 mysql-files
drwx------  2 mysql     mysql     4.0K Jun 27 09:13 mysql-keyring
drwxr-xr-x  2 root      root      4.0K May 11 07:49 mysql-upgrade
drwxr-xr-x  2 root      root      4.0K Jun  4  2019 os-prober
drwxr-xr-x  2 root      root      4.0K Jul 23 06:21 pam
drwxr-xr-x  4 root      root      4.0K Jun 27 09:13 php
drwxr-xr-x  3 root      root      4.0K Jun 27 09:16 phpmyadmin
drwxr-xr-x  2 root      root      4.0K Nov  2  2020 plymouth
drwx------  3 root      root      4.0K May 18 16:39 polkit-1
drwx------  2 root      root      4.0K May 18 16:39 private
drwxr-xr-x  2 root      root      4.0K May 18 16:39 python
drwxr-xr-x  3 root      root      4.0K May 18 16:48 shim-signed
drwxr-xr-x 23 root      root      4.0K Jul 23 14:50 snapd
drwxr-xr-x  2 root      root      4.0K Aug 17  2020 snmp
drwxr-xr-x  3 root      root      4.0K May 18 16:39 sudo
drwxr-xr-x 10 root      root      4.0K Jun 28 11:55 systemd
drwxr-xr-x  2 tss       tss       4.0K Dec  3  2019 tpm
drwxr-xr-x  3 root      root      4.0K Jun 26 22:44 ubuntu-advantage
drwxr-xr-x  2 root      root      4.0K Jul 17 18:49 ubuntu-release-upgrader
drwxr-xr-x  3 root      root      4.0K Jun 28 12:12 ucf
drwxr-xr-x  2 root      root      4.0K Jul 21  2020 unattended-upgrades
drwxr-xr-x  2 root      root      4.0K Jun 26 22:42 update-manager
drwxr-xr-x  4 root      root      4.0K Jul 23 15:53 update-notifier
drwxr-xr-x  2 root      root      4.0K May 18 16:41 usbutils
drwxr-xr-x  3 root      root      4.0K May 18 16:39 vim

对于为什么会发生这种情况以及如何补救,您有什么想法吗?

答案1

我忘记了我的 dirdu 别名没有 sudo。我发现它是一堆 mysql binlog。我已清除过时的 binlog,并设置了全局过期设置

相关内容