sjuxax / gdu

Disk usage analyzer with console interface written in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go DiskUsage()

Build Status codecov Go Report Card Maintainability CodeScene Code Health

Pretty fast disk usage analyzer written in Go.

Gdu is intended primarily for SSD disks where it can fully utilize parallel processing. However HDDs work as well, but the performance gain is not so huge.

asciicast

Packaging status

Installation

Head for the releases and download binary for your system.

Using curl:

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

Arch Linux:

yay -S gdu

Debian:

dpkg -i gdu_*_amd64.deb

Ubuntu

add-apt-repository ppa:daniel-milde/gdu
apt-get update
apt-get install gdu

NixOS:

nix-env -iA nixos.gdu

Homebrew:

brew install gdu

Snap:

snap install gdu-disk-usage-analyzer
snap connect gdu-disk-usage-analyzer:mount-observe :mount-observe
snap connect gdu-disk-usage-analyzer:system-backup :system-backup
snap alias gdu-disk-usage-analyzer.gdu gdu

Binenv

binenv install gdu

Go:

go get -u github.com/dundee/gdu/v4

Usage

  gdu [flags] [directory_to_scan]

Flags:
  -h, --help                  help for gdu
  -i, --ignore-dirs strings   Absolute paths to ignore (separated by comma) (default [/proc,/dev,/sys,/run])
  -l, --log-file string       Path to a logfile (default "/dev/null")
  -c, --no-color              Do not use colorized output
  -x, --no-cross              Do not cross filesystem boundaries
  -p, --no-progress           Do not show progress in non-interactive mode
  -n, --non-interactive       Do not run in interactive mode
  -a, --show-apparent-size    Show apparent size
  -d, --show-disks            Show all mounted disks
  -v, --version               Print version

Examples

gdu                                   # analyze current dir
gdu -a                                # show apparent size instead of disk usage
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 -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 / > file                          # write stats to file, do not start interactive mode

Gdu has two modes: interactive (default) and non-interactive.

Non-interactive mode is started automtically when TTY is not detected (using go-isatty), for example if the output is being piped to a file, or it can be started explicitly by using a flag.

Hard links are counted only once.

File flags

Files and directories may be prefixed by a one-character flag with following meaning:

  • ! An error occurred while reading this directory.

  • . An error occurred while reading a subdirectory, size may be not correct.

  • @ File is symlink or socket.

  • H Same file was already counted (hard link).

  • e Directory is empty.

Running tests

make test

Benchmarks

Benchmarks performed on 50G directory (100k directories, 400k files) on 500 GB SSD using hyperfine. See benchmark target in Makefile for more info.

Cold cache

Filesystem cache was cleared using sync; echo 3 | sudo tee /proc/sys/vm/drop_caches.

Command Mean [s] Min [s] Max [s] Relative
gdu -npc ~ 3.714 ± 0.036 3.685 3.809 1.00
dua ~ 4.703 ± 0.011 4.691 4.721 1.27 ± 0.01
duc index ~ 20.776 ± 0.093 20.591 20.924 5.59 ± 0.06
ncdu -0 -o /dev/null ~ 20.933 ± 0.113 20.757 21.073 5.64 ± 0.06
diskus ~ 3.747 ± 0.027 3.707 3.779 1.01 ± 0.01
du -hs ~ 20.096 ± 0.128 19.916 20.313 5.41 ± 0.06
dust -d0 ~ 16.281 ± 0.118 16.148 16.490 4.38 ± 0.05

Warm cache

Command Mean [ms] Min [ms] Max [ms] Relative
gdu -npc ~ 643.5 ± 11.3 623.8 659.9 1.99 ± 0.12
dua ~ 389.7 ± 13.0 374.2 410.4 1.20 ± 0.08
duc index ~ 1241.1 ± 19.6 1205.4 1274.9 3.84 ± 0.23
ncdu -0 -o /dev/null ~ 1846.7 ± 11.9 1823.0 1859.9 5.71 ± 0.33
diskus ~ 323.4 ± 18.8 302.1 362.2 1.00
du -hs ~ 1027.7 ± 9.7 1009.0 1037.5 3.18 ± 0.19
dust -d0 ~ 8864.4 ± 35.9 8798.8 8906.6 27.41 ± 1.60

Gdu is inspired by ncdu, godu, dua and df.

About

Disk usage analyzer with console interface written in Go

License:MIT License


Languages

Language:Go 95.7%Language:Makefile 2.7%Language:Roff 1.6%