
使用GO编写的非常快的磁盘用法分析仪。
GDU主要用于SSD磁盘,可以充分利用并行处理。但是HDD也可以工作,但是性能增长并不是那么巨大。
前往发布页面,然后下载系统的二进制文件。
使用卷发:
curl -L 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安装到系统的其他方法,请参见“安装”页面。
或者,您可以直接通过Docker使用GDU:
docker run --rm --init --interactive --tty --privileged --volume /:/mnt/root ghcr.io/dundee/gdu /mnt/root
gdu [flags] [directory_to_scan]
Flags:
--config-file string Read config from file (default is $HOME/.gdu.yaml)
-g, --const-gc Enable memory garbage collection during analysis with constant level set by GOGC
--enable-profiling Enable collection of profiling data and provide it on http://localhost:6060/debug/pprof/
-L, --follow-symlinks Follow symlinks for files, i.e. show the size of the file to which symlink points to (symlinks to directories are not followed)
-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)
-X, --ignore-from string Read absolute path patterns to ignore from file
-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. 12 cores available (default 12)
-c, --no-color Do not use colorized output
-x, --no-cross Do not cross filesystem boundaries
--no-delete Do not allow deletions
-H, --no-hidden Ignore hidden directories (beginning with dot)
--no-mouse Do not use mouse
--no-prefix Show sizes as raw numbers without any prefixes (SI or binary) in non-interactive mode
-p, --no-progress Do not show progress in non-interactive mode
-u, --no-unicode Do not use Unicode symbols (for size bar)
-n, --non-interactive Do not run in interactive mode
-o, --output-file string Export all info into file as JSON
-r, --read-from-storage Read analysis data from persistent key-value storage
--sequential Use sequential scanning (intended for rotating HDDs)
-a, --show-apparent-size Show apparent size
-d, --show-disks Show all mounted disks
-C, --show-item-count Show number of items in directory
-M, --show-mtime Show latest mtime of items in directory
-B, --show-relative-size Show relative size
--si Show sizes with decimal SI prefixes (kB, MB, GB) instead of binary prefixes (KiB, MiB, GiB)
--storage-path string Path to persistent key-value storage directory (default "/tmp/badger")
-s, --summarize Show only a total in non-interactive mode
-t, --top int Show only top X largest files in non-interactive mode
--use-storage Use persistent key-value storage for analysis data (experimental)
-v, --version Print version
--write-config Write current configuration to file (default is $HOME/.gdu.yaml)
Basic list of actions in interactive mode (show help modal for more):
↑ or k Move cursor up
↓ or j Move cursor down
→ or Enter or l Go to highlighted directory
← or h Go to parent directory
d Delete the selected file or directory
e Empty the selected directory
n Sort by name
s Sort by size
c Show number of items in directory
? Show help modal
gdu # analyze current dir
gdu -a # show apparent size instead of disk usage
gdu --no-delete # prevent write operations
gdu <some_dir_to_analyze> # analyze given dir
gdu -d # show all mounted disks
gdu -l ./gdu.log <some_dir> # write errors to log file
gdu -i /sys,/proc / # ignore some paths
gdu -I '.*[abc]+' # ignore paths by regular pattern
gdu -X ignore_file / # ignore paths by regular patterns from file
gdu -c / # use only white/gray/black colors
gdu -n / # only print stats, do not start interactive mode
gdu -np / # do not show progress, useful when using its output in a script
gdu -nps /some/dir # show only total usage for given dir
gdu -nt 10 / # show top 10 largest files
gdu / > file # write stats to file, do not start interactive mode
gdu -o- / | gzip -c >report.json.gz # write all info to JSON file for later analysis
zcat report.json.gz | gdu -f- # read analysis from file
GOGC=10 gdu -g --use-storage / # use persistent key-value storage for saving analysis data
gdu -r / # read saved analysis data from persistent key-value storage
GDU具有三种模式:交互式(默认),非相互作用和导出。
当未检测到TTY(使用Go-Isatty)时,自动启动非相互作用模式,例如,如果输出被管道输送到文件,或者可以通过使用标志明确启动。
导出模式(flag -o )输出所有用法数据作为JSON,稍后可以使用-f标志打开。
硬链路仅计数一次。
文件和目录可以由一个单字符标志以以下含义为前缀:
!阅读此目录时发生了错误。
.在阅读子目录时发生错误,大小可能不正确。
@文件是符号链接或套接字。
H相同的文件已经计数(硬链路)。
e目录是空的。
GDU可以读取(并写)YAML配置文件。
$HOME/.config/gdu/gdu.yaml和$HOME/.gdu.yaml默认情况下检查了配置文件的架构。
请参阅所有配置选项的完整列表。
echo "no-color: true" >> ~/.gdu.yaml
sorting:
by: name // size, name, itemCount, mtime
order: desc
echo "change-cwd: true" >> ~/.gdu.yaml
gdu --write-config
浪费了如何将终端涂色的方式。某些GDU原始图(例如基本文本)附加到不同的配色模式,但是所选/突出显示的行没有。
如果默认外观不够,则可以在配置文件中更改,例如:
style:
selected-row:
text-color: black
background-color: "#ff0000"
GDU可以在后台删除项目,因此不会阻止UI进行其他工作。启用:
echo "delete-in-background: true" >> ~/.gdu.yaml
目录项目也可以并行删除,这可能会增加删除速度。启用:
echo "delete-in-parallel: true" >> ~/.gdu.yaml
GDU试图平衡性能和内存使用量。
当GDU使用的内存少于主机的总自由存储器时,则在分析阶段完全禁用垃圾收集以获得最大速度。
否则启用了GC。使用内存越多,自由的内存就越少,GC发生的经常越多。
如果您想要对垃圾收集的手动控制,则可以使用--const-gc / -g标志。它将在分析阶段以持续的侵略性水平运行垃圾收集。结果,该分析将慢约25%,并且记忆的消耗率将减少约30%。要更改级别,您可以设置GOGC环境变量以指定垃圾收集的频率。较低的值(大于100)意味着GC会更频繁地运行。较高意味着较少的频率。负数将停止GC。
示例以常数GC运行GDU,但不像默认值那样激进:
GOGC=200 gdu -g /
GDU可以存储分析数据以持续键值存储而不是仅仅是内存。 GDU的运行速度将慢得多(约10倍),但它应该使用更少的内存(当使用小型GOGC时)。 GDU还可以通过保存的数据重新打开。目前,仅支持BadgerDB作为键值存储(嵌入式)。
GOGC=10 gdu -g --use-storage / # saves analysis data to key-value storage
gdu -r / # reads just saved data, does not run analysis again
make install-dev-dependencies
make test
设置--enable-profiling标志时,GDU可以收集分析数据。数据通过URL http://localhost:6060/debug/pprof/ 。
然后,您可以使用EG go tool pprof -web http://localhost:6060/debug/pprof/heap在您的Web浏览器中以SVG图像打开堆配置文件。
使用HyperFine对500 GB SSD的50G目录(100K目录,400K文件)进行基准测试。有关更多信息,请参见MakeFile中的benchmark目标。
使用sync; echo 3 | sudo tee /proc/sys/vm/drop_caches 。
| 命令 | 方法] | 最小[S] | 最大[S] | 相对的 |
|---|---|---|---|---|
diskus ~ | 3.126±0.020 | 3.087 | 3.155 | 1.00 |
gdu -npc ~ | 3.132±0.019 | 3.111 | 3.173 | 1.00±0.01 |
gdu -gnpc ~ | 3.136±0.012 | 3.112 | 3.155 | 1.00±0.01 |
pdu ~ | 3.657±0.013 | 3.641 | 3.677 | 1.17±0.01 |
dust -d0 ~ | 3.933±0.144 | 3.849 | 4.213 | 1.26±0.05 |
dua ~ | 3.994±0.073 | 3.827 | 4.134 | 1.28±0.02 |
gdu -npc --use-storage ~ | 12.812±0.078 | 12.644 | 12.912 | 4.10±0.04 |
du -hs ~ | 14.120±0.213 | 13.969 | 14.703 | 4.52±0.07 |
duc index ~ | 14.567±0.080 | 14.385 | 14.657 | 4.66±0.04 |
ncdu -0 -o /dev/null ~ | 14.963±0.254 | 14.759 | 15.637 | 4.79±0.09 |
| 命令 | 平均[MS] | 最小[MS] | 最大[MS] | 相对的 |
|---|---|---|---|---|
pdu ~ | 226.6±3.7 | 219.6 | 231.2 | 1.00 |
diskus ~ | 227.7±5.2 | 221.6 | 239.9 | 1.00±0.03 |
dust -d0 ~ | 400.1±7.1 | 386.7 | 409.4 | 1.77±0.04 |
dua ~ | 444.9±2.4 | 442.4 | 448.9 | 1.96±0.03 |
gdu -npc ~ | 451.3±3.8 | 445.9 | 458.5 | 1.99±0.04 |
gdu -gnpc ~ | 516.1±6.7 | 503.1 | 527.5 | 2.28±0.05 |
du -hs ~ | 905.0±3.9 | 901.2 | 913.4 | 3.99±0.07 |
duc index ~ | 1053.0±5.1 | 1046.2 | 1064.1 | 4.65±0.08 |
ncdu -0 -o /dev/null ~ | 1653.9±5.7 | 1645.9 | 1663.0 | 7.30±0.12 |
gdu -npc --use-storage ~ | 9754.9±688.7 | 8403.8 | 10427.4 | 43.04±3.12 |
C (LTS)或zig (稳定)编写的工具Rust编写的工具,界面类似于GDU(和NCDU)Rust写Rust写的工具显示树,例如磁盘使用的结构Rust写的工具显示树,例如磁盘使用的结构Nikita Golubev -Flaticon创建的HDD图标