EC2 ubuntu 实例已满但找不到原因

EC2 ubuntu 实例已满但找不到原因

以下是当前用法

Filesystem      Size  Used Avail Use% Mounted on
udev            488M     0  488M   0% /dev
tmpfs           100M   11M   89M  11% /run
/dev/xvda1      7.7G  7.7G  396K 100% /
tmpfs           496M     0  496M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           496M     0  496M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user/1000

以下是du -ah . | sort -rh | head -20各个文件夹的输出:

/用户

223M  .
179M  ./.composer/cache/repo/https---packagist.org
179M  ./.composer/cache/repo
179M  ./.composer/cache
179M  ./.composer
44M ./git/myapp
44M ./git
20M ./git/myapp/.git
19M ./git/myapp/.git/objects
16M ./git/myapp/.git/objects/pack/pack-906b417ebaebc4922a90397b82f180cdd8f59570.pack
16M ./git/myapp/.git/objects/pack
14M ./git/myapp/marc-v2-backend.zip
6.9M  ./git/myapp/public
5.0M  ./.composer/cache/repo/https---packagist.org/provider-illuminate$view.json
5.0M  ./.composer/cache/repo/https---packagist.org/provider-illuminate$validation.json
5.0M  ./.composer/cache/repo/https---packagist.org/provider-illuminate$support.json
5.0M  ./.composer/cache/repo/https---packagist.org/provider-illuminate$session.json
5.0M  ./.composer/cache/repo/https---packagist.org/provider-illuminate$routing.json
5.0M  ./.composer/cache/repo/https---packagist.org/provider-illuminate$queue.json
5.0M  ./.composer/cache/repo/https---packagist.org/provider-illuminate$mail.json

/var

287M  ./lib
272M  ./www/html/myapp
272M  ./www/html
272M  ./www
172M  ./www/html/myapp/node_modules
152M  ./lib/apt/lists
152M  ./lib/apt
124M  ./cache
116M  ./cache/apt
115M  ./lib/dpkg
114M  ./lib/dpkg/info
66M ./www/html/myapp/vendor
40M ./lib/apt/lists/ap-southeast-1.ec2.archive.ubuntu.com_ubuntu_dists_xenial_universe_binary-amd64_Packages
35M ./lib/apt/lists/ap-southeast-1.ec2.archive.ubuntu.com_ubuntu_dists_xenial_universe_source_Sources
31M ./cache/apt/srcpkgcache.bin
31M ./cache/apt/pkgcache.bin
28M ./cache/apt/pkgcache.bin.PysQE6
27M ./cache/apt/archives
23M ./lib/apt/lists/ap-southeast-1.ec2.archive.ubuntu.com_ubuntu_dists_xenial_universe_i18n_Translation-en

尝试运行/但却没有足够的空间存放日志。

有一个 1GB 的交换文件:

              total        used        free      shared  buff/cache   available
Mem:           990M        121M         88M         22M        781M        624M
Swap:          1.0G        101M        922M

什么原因造成 6GB 的膨胀?

答案1

大部分用法是在/usr/src

显然其中有大量的 Linux 头文件,总计有 3GB!

做了以下事情:

sudo apt-get update
sudo apt-get -f install (cause there were some unmet dependencies)
sudo apt-get autoremove

ubuntu@:~$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  linux-aws-headers-4.4.0-1022 linux-aws-headers-4.4.0-1039 linux-aws-headers-4.4.0-1041 linux-aws-headers-4.4.0-1043
  linux-aws-headers-4.4.0-1044 linux-aws-headers-4.4.0-1048 linux-aws-headers-4.4.0-1049 linux-aws-headers-4.4.0-1052
  linux-aws-headers-4.4.0-1054 linux-aws-headers-4.4.0-1055 linux-aws-headers-4.4.0-1057 linux-aws-headers-4.4.0-1060
  linux-aws-headers-4.4.0-1061 linux-aws-headers-4.4.0-1062 linux-aws-headers-4.4.0-1065 linux-aws-headers-4.4.0-1066
  linux-aws-headers-4.4.0-1069 linux-aws-headers-4.4.0-1070 linux-aws-headers-4.4.0-1072 linux-aws-headers-4.4.0-1074
  linux-aws-headers-4.4.0-1075 linux-aws-headers-4.4.0-1077 linux-aws-headers-4.4.0-1079 linux-aws-headers-4.4.0-1083
  linux-headers-4.4.0-1022-aws linux-headers-4.4.0-1039-aws linux-headers-4.4.0-1041-aws linux-headers-4.4.0-1043-aws
  linux-headers-4.4.0-1044-aws linux-headers-4.4.0-1048-aws linux-headers-4.4.0-1049-aws linux-headers-4.4.0-1052-aws
  linux-headers-4.4.0-1054-aws linux-headers-4.4.0-1055-aws linux-headers-4.4.0-1057-aws linux-headers-4.4.0-1060-aws
  linux-headers-4.4.0-1061-aws linux-headers-4.4.0-1062-aws linux-headers-4.4.0-1065-aws linux-headers-4.4.0-1066-aws
  linux-headers-4.4.0-1069-aws linux-headers-4.4.0-1070-aws linux-headers-4.4.0-1072-aws linux-headers-4.4.0-1074-aws
  linux-headers-4.4.0-1075-aws linux-headers-4.4.0-1077-aws linux-headers-4.4.0-1079-aws linux-headers-4.4.0-1083-aws
  linux-image-4.4.0-1022-aws linux-image-4.4.0-1039-aws linux-image-4.4.0-1041-aws linux-image-4.4.0-1043-aws
  linux-image-4.4.0-1044-aws linux-image-4.4.0-1048-aws linux-image-4.4.0-1049-aws linux-image-4.4.0-1052-aws
  linux-image-4.4.0-1054-aws linux-image-4.4.0-1055-aws linux-image-4.4.0-1057-aws linux-image-4.4.0-1060-aws
  linux-image-4.4.0-1061-aws linux-image-4.4.0-1062-aws linux-image-4.4.0-1065-aws linux-image-4.4.0-1066-aws
  linux-image-4.4.0-1069-aws linux-image-4.4.0-1070-aws linux-image-4.4.0-1072-aws linux-image-4.4.0-1074-aws
  linux-image-4.4.0-1075-aws linux-image-4.4.0-1077-aws linux-image-4.4.0-1079-aws linux-image-4.4.0-1083-aws
  linux-modules-4.4.0-1077-aws linux-modules-4.4.0-1079-aws linux-modules-4.4.0-1083-aws
0 upgraded, 0 newly installed, 75 to remove and 205 not upgraded.
After this operation, 3214 MB disk space will be freed.

删除这些头文件后,使用量下降到 3.3GB。1GB 交换空间意味着大约 2GB 的各种文件,我认为这是相当合理的。

Filesystem      Size  Used Avail Use% Mounted on
udev            488M     0  488M   0% /dev
tmpfs           100M   11M   89M  11% /run
/dev/xvda1      7.7G  3.3G  4.5G  42% /
tmpfs           496M     0  496M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           496M     0  496M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user/1000

相关内容