0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ディスク容量アラート発生時使用コマンド

Last updated at Posted at 2022-05-15

サーバのディスク使用量がしきい値を超えるとアラートが来るようになっている。
アラートが発生したときに使用するコマンドのメモ。

dfコマンドで概要確認

環境はサンプル。

$ df -h --total
Filesystem      Size  Used Avail Use% Mounted on
udev            448M     0  448M   0% /dev
tmpfs            99M  760K   98M   1% /run
/dev/vda3        46G   37G  6.8G  85% /
tmpfs           491M     0  491M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           491M     0  491M   0% /sys/fs/cgroup
tmpfs            99M     0   99M   0% /run/user/1001
tmpfs            99M     0   99M   0% /run/user/1000
total            47G   37G  8.5G  81% -

duコマンドで問題となっているディレクトリを特定

  • sortで大きい順に表示。
  • max-depthやheadの値は適宜調整。
  • 実際には特定のディレクトリにアクセスできない旨のエラーメッセージも表示されましたが省略しています。
$ du --max-depth=3 -h | sort -hr | head -n 10
36G     .
29G     ./var
21G     ./var/spool/test
21G     ./var/spool
4.4G    ./var/log
4.2G    ./var/lib
4.1G    ./var/log/journal
3.8G    ./usr
3.5G    ./var/lib/docker
3.1G    ./home/testuser

原因になっているディレクトリの内容を確認

$ cd /var/spool/test/
$ ls -lh
total 21G
-rw-r--r-- 1 root root 20G May 15 22:09 dummy

(参考)容量が大きいファイルを作成したコマンド

dd if=/dev/zero of=dummy bs=1M count=20480
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?