No description
Find a file
2021-04-06 11:23:40 +02:00
.github/workflows Create codeql-analysis.yml 2021-03-08 23:01:15 +01:00
analyze more stable assert 2021-03-27 21:28:48 +01:00
build use cobra [BC break] 2021-01-15 00:06:36 +01:00
cmd max-cores flag added to readme and man page 2021-04-06 11:23:40 +02:00
common check if the diven directory exists 2021-03-19 09:09:07 +01:00
device Add MountCmd parameter. 2021-04-05 20:34:57 +02:00
internal use channel instead of mutex 2021-03-25 18:50:01 +01:00
stdout use channel instead of mutex 2021-03-25 18:50:01 +01:00
tui Keep cursor on selection when swapping between apparent/actual size. 2021-03-27 21:31:36 +01:00
.gitignore Make some logic changes in '-m flag processing' 2021-04-06 11:14:48 +02:00
.travis.yml added first test, added badges 2020-12-24 21:22:58 +01:00
codecov.yml do not fail builds on codecov 2021-01-23 22:56:58 +01:00
gdu.1 max-cores flag added to readme and man page 2021-04-06 11:23:40 +02:00
gdu.1.md max-cores flag added to readme and man page 2021-04-06 11:23:40 +02:00
go.mod upgrade to go 1.16 2021-03-01 14:06:41 +01:00
go.sum dependencies updated 2021-02-21 19:58:03 +01:00
LICENSE.md added copyright for debian 2021-01-17 17:37:10 +01:00
main.go fixed module version 2021-02-22 10:25:16 +01:00
Makefile always copy man page to dist 2021-03-25 23:01:58 +01:00
README.md max-cores flag added to readme and man page 2021-04-06 11:23:40 +02:00
snapcraft.yaml snap: use system-backup interface instead of system-files 2021-01-26 23:07:05 +01:00

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")
  -m, --max-cores int         Set max cores that GDU will use. 8 cores available (default 8)
  -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.