原文地址:https://lala.im/7988.html,請支持原作者!該處僅作轉載。
有台吃灰了快1年的小鸡一直没登录过,昨天登录上去发现硬盘莫名其妙满了,啥操作都做不了。
硬盘本身也不大一共就8G,很小的小鸡,还是白嫖的。。估计还能用个1年多,得想办法把空间腾出来一点。
然后我想到前段时间发现了一个硬盘使用分析的工具:gdu。
项目地址:https://github.com/dundee/gdu
这会儿可以派上用场了,看看是哪些玩意把我的硬盘吃了。。。
安装很简单,下载给个执行权限就行了:
wget https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz | tar xz
chmod +x gdu_linux_amd64
mv gdu_linux_amd64 /usr/bin/gdu
分析一下/:
gdu /
很快啊,啪的一下就发现是systemd的journal占了近1G空间:
清理日志:
journalctl --vacuum-size=100M
这个工具挺实用的,功能也很多,有需要的可以试试:
Usage:
gdu [directory_to_scan] [flags]
Flags:
-h, --help help for gdu
-i, --ignore-dirs strings Absolute paths to ignore (separated by comma) (default [/proc,/dev,/sys,/run])
-I, --ignore-dirs-pattern strings Absolute path patterns to ignore (separated by comma)
-f, --input-file string Import analysis from JSON file
-l, --log-file string Path to a logfile (default "/dev/null")
-m, --max-cores int Set max cores that GDU will use. 1 cores available (default 1)
-c, --no-color Do not use colorized output
-x, --no-cross Do not cross filesystem boundaries
-H, --no-hidden Ignore hidden directories (beginning with dot)
-p, --no-progress Do not show progress in non-interactive mode
-n, --non-interactive Do not run in interactive mode
-o, --output-file string Export all info into file as JSON
-a, --show-apparent-size Show apparent size
-d, --show-disks Show all mounted disks
-v, --version Print version