
使用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圖標