Code Monkey home page Code Monkey logo

gdu's Introduction

go DiskUsage()

Gdu

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 page and download the 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

See the installation page for other ways how to install Gdu to your system.

Or you can use Gdu directly via Docker:

docker run --rm --init --interactive --tty --privileged --volume /:/mnt/root ghcr.io/dundee/gdu /mnt/root

Usage

  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. 8 cores available (default 8)
  -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
  -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 is /tmp/badger) (default "/tmp/badger")
  -s, --summarize                     Show only a total 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

Examples

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 / > 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

Modes

Gdu has three modes: interactive (default), non-interactive and export.

Non-interactive mode is started automatically 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.

Export mode (flag -o) outputs all usage data as JSON, which can be later opened using the -f 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.

Configuration file

Gdu can read (and write) YAML configuration file.

$HOME/.config/gdu/gdu.yaml and $HOME/.gdu.yaml are checked for the presense of the config file by default.

Examples

  • To configure gdu to permanently run in gray-scale color mode:
echo "no-color: true" >> ~/.gdu.yaml
  • To set default sorting in configuration file:
sorting:
    by: name // size, name, itemCount, mtime
    order: desc
  • To configure gdu to set CWD variable when browsing directories:
echo "change-cwd: true" >> ~/.gdu.yaml
  • To save the current configuration
gdu --write-config

Styling

There are wast ways how terminals can be colored. Some gdu primitives (like basic text) addapt to different color schemas, but the selected/highlighted row does not.

If the default look is not sufficient, it can be changed in configuration file, e.g.:

style:
    selected-row:
        text-color: black
        background-color: "#ff0000"

Deletion in background and in parallel (experimental)

Gdu can delete items in the background, thus not blocking the UI for additional work. To enable:

echo "delete-in-background: true" >> ~/.gdu.yaml

Directory items can be also deleted in parallel, which might increase the speed of deletion. To enable:

echo "delete-in-parallel: true" >> ~/.gdu.yaml

Memory usage

Automatic balancing

Gdu tries to balance performance and memory usage.

When less memory is used by gdu than the total free memory of the host, then Garbage Collection is disabled during the analysis phase completely to gain maximum speed.

Otherwise GC is enabled. The more memory is used and the less memory is free, the more often will the GC happen.

Manual memory usage control

If you want manual control over Garbage Collection, you can use --const-gc / -g flag. It will run Garbage Collection during the analysis phase with constant level of aggressiveness. As a result, the analysis will be about 25% slower and will consume about 30% less memory. To change the level, you can set the GOGC environment variable to specify how often the garbage collection will happen. Lower value (than 100) means GC will run more often. Higher means less often. Negative number will stop GC.

Example running gdu with constant GC, but not so aggressive as default:

GOGC=200 gdu -g /

Saving analysis data to persistent key-value storage (experimental)

Gdu can store the analysis data to persistent key-value storage instead of just memory. Gdu will run much slower (approx 10x) but it should use much less memory (when using small GOGC as well). Gdu can also reopen with the saved data. Currently only BadgerDB is supported as the key-value storage (embedded).

GOGC=10 gdu -g --use-storage /    # saves analysis data to key-value storage
gdu -r /                          # reads just saved data, does not run analysis again

Running tests

make install-dev-dependencies
make test

Profiling

Gdu can collect profiling data when the --enable-profiling flag is set. The data are provided via embedded http server on URL http://localhost:6060/debug/pprof/.

You can then use e.g. go tool pprof -web http://localhost:6060/debug/pprof/heap to open the heap profile as SVG image in your web browser.

Benchmarks

Benchmarks were 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
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

Warm cache

Command Mean [ms] Min [ms] Max [ms] Relative
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

Alternatives

  • ncdu - NCurses based tool written in pure C (LTS) or zig (Stable)
  • godu - Analyzer with a carousel like user interface
  • dua - Tool written in Rust with interface similar to gdu (and ncdu)
  • diskus - Very simple but very fast tool written in Rust
  • duc - Collection of tools with many possibilities for inspecting and visualising disk usage
  • dust - Tool written in Rust showing tree like structures of disk usage
  • pdu - Tool written in Rust showing tree like structures of disk usage

Notes

HDD icon created by Nikita Golubev - Flaticon

gdu's People

Contributors

agsimmons avatar aliesbelik avatar amigan avatar bpetrynski avatar bucku avatar chutzimir avatar cybertailor avatar daniejstriata avatar dependabot[bot] avatar dundee avatar edwardbetts avatar egeoz avatar electricrcaircraftguy avatar fabaff avatar felixonmars avatar inglor avatar jeremy-neville avatar jrwren avatar kadogo avatar mcoret avatar mnapoli avatar ouuan avatar petasittek avatar phanirithvij avatar ramgp avatar rare-magma avatar rashil2000 avatar sitiom avatar sjuxax avatar zhangsean avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gdu's Issues

snap - version detail

Hi,

I'm not sure which version is installed with snap. Should -v not print 5.3 instead of development?

When I run:

→ gdu -v
Version:	 development
Built time:	 
Built user:
→ snap info gdu-disk-usage-analyzer
name:      gdu-disk-usage-analyzer
summary:   Disk usage analyzer with console interface written in Go.
publisher: Daniel Milde
store-url: https://snapcraft.io/gdu-disk-usage-analyzer
contact:   [email protected]
license:   unset
description: |
  Pretty fast disk usage analyzer written in Go. Inspired by ncdu, godu and df.
commands:
  - gdu-disk-usage-analyzer.gdu
snap-id:      v6mWlpSzqaEXy6Vhxhn9wQcMJ9LhrOZy
tracking:     latest/stable
refresh-date: today at 09:22 SAST
channels:
  latest/stable:    v5.3.0+git1.5aa6128 2021-07-20 (692) 1MB -
  latest/candidate: ↑                                        
  latest/beta:      ↑                                        
  latest/edge:      v5.3.0+git5.375c39d 2021-07-21 (705) 1MB -
installed:          v5.3.0+git1.5aa6128            (692) 1MB -

Keep the selected item when exiting a directory

Feature Request

Keep the selected item when exiting a directory.

Example

File structure:

.
├── a
└── b
    └── bar

Command: gdu .

Keyboard operations: jlh

Expected selected item: b

Selected item with gdu v3.0.0: a

GDU not ignoring directory

Hi

I can't seem to get gdu to ignore a directory. It still shows it as scanning.

gdu --version
Version:         v4.8.0
Built time:      Mon Mar  8 09:36:18 PM CET 2021
Built user:      dundee

Ubuntu 20.04.2 LTS

I have multiple directories that I want to scan inside /mnt/backups/minio but I want to exclude /mnt/backups/minio/dirC

/mnt/backups/minio
    dirA
    dirB
    dirC
    dirD
    dirE

I have tried:

cd /mnt/backups/minio
gdu /mnt/backups/minio -i /mnt/backups/minio/dirC
gdu /mnt/backups/minio -i /mnt/backups/minio/dirC/
gdu /mnt/backups/minio -i "/mnt/backups/minio/dirC"
gdu -i /mnt/backups/minio/dirC/
gdu -i /mnt/backups/minio/dirC /mnt/backups/minio
gdu -i "/mnt/backups/minio/dirC" /mnt/backups/minio
gdu -i "dirC" /mnt/backups/minio
gdu --ignore-dirs /mnt/backups/minio/dirC
gdu --ignore-dirs=/mnt/backups/minio/dirC

Probably tried several other combinations too. But every time it is still scanning dirC every time. The main reason for excluding dirC is because it has a lot of hard links which I think gdu is struggling with, but that's a different issue.

Panic when hitting `r` too many times/too often

I've been refreshing a VirtualBox directory size using r while waiting for the snapshot merging to finish and at some point the app crashed. Maybe it was because VirtualBox finished snapshot merging and deleted some files while gdu was doing its calculation?

This is what the window looked like, Below, you'll find the trace in the text form (copy&paste, remove unnecessary spaces):
image

sync.throw(0x555ad4c0f70e, 0x1e)
runtime/panic.go:1103 +0x37 fp=0xc030295778 sp=0xc030295758 pc=0x555ad4a4b637
sync.(*Mutex).unlockSlow(0xc0148d0978, 0xc0ffffffff)
sync/mutex.go:196 +0xde fp=0xc0302957a0 sp=0xc030295778 pc=0x555ad4a669de
sync.(*Mutex).Unlock(...)
sync/mutex.go:190
github.com/dundee/gdu/v4/tui.(*UI).updateProgress(0xc00035a000)
github.com/dundee/gdu/v4/tui/tui.go:336 +0x156 fp=0xc0302957d8 sp=0xc0302957a0 pc=0x555ad4b95376
runtime.goexit()
runtime/asm_amd64.s:1371 +0x1 fp=0xc0302957e0 sp=0xc0302957d8 pc=0x555ad4a4fe41
created by github.com/dundee/gdu/v4/tui.(*UI).AnalyzePath
github.com/dundee/gdu/v4/tui/actions.go:71 +0x79b

goroutine 167019 [running]:
runtime.throw(0x555ad4c0f70e, 0x1e)
runtime/panic.go:1117 +0x74 fp=0xc030296758 sp=0xc030296728 pc=0x555ad4a1a0b4
sync.throw(0x555ad4c0f70e, 0x1e)
runtime/panic.go:1103 +0x37 fp=0xc030296778 sp=0xc030296758 pc=0x555ad4a4b637
sync.(*Mutex).unlockSlow(0xc014972170, 0xc0ffffffff)
sync/mutex.go:196 +0xde fp=0xc0302967a0 sp=0xc030296778 pc=0x555ad4a669de
sync.(*Mutex).Unlock(...)
sync/mutex.go:190
github.com/dundee/gdu/v4/tui.(*UI).updateProgress(0xc00035a000)
github.com/dundee/gdu/v4/tui/tui.go:336 +0x156 fp=0xc0302967d8 sp=0xc0302967a0 pc=0x555ad4b95376
runtime.goexit()
runtime/asm_amd64.s:1371 +0x1 fp=0xc0302967e0 sp=0xc0302967d8 pc=0x555ad4a4fe41
created by github.com/dundee/gdu/v4/tui.(*UI).AnalyzePath
github.com/dundee/gdu/v4/tui/actions.go:71 +0x79b

goroutine 167013 [running]:
runtime.throw(0x555ad4c0f70e, 0x1e)
runtime/panic.go:1117 +0x74 fp=0xc00004cf58 sp=0xc00004cf28 pc=0x555ad4a1a0b4
sync.throw(0x555ad4c0f70e, 0x1e)
runtime/panic.go:1103 +0x37 fp=0xc00004cf78 sp=0xc00004cf58 pc=0x555ad4a4b637
sync.(*Mutex).unlockSlow(0xc0148b23b0, 0xc0ffffffff)
sync/mutex.go:196 +0xde fp=0xc00004cfa0 sp=0xc00004cf78 pc=0x555ad4a669de
sync.(*Mutex).Unlock(...)
sync/mutex.go:190
github.com/dundee/gdu/v4/tui.(*UI).updateProgress(0xc00035a000)
github.com/dundee/gdu/v4/tui/tui.go:336 +0x156 fp=0xc00004cfd8 sp=0xc00004cfa0 pc=0x555ad4b95376
runtime.goexit()
runtime/asm_amd64.s:1371 +0x1 fp=0xc00004cfe0 sp=0xc00004cfd8 pc=0x555ad4a4fe41
created by github.com/dundee/gdu/v4/tui.(*UI).AnalyzePath
github.com/dundee/gdu/v4/tui/actions.go:71 +0x79b

Option to ignore hidden dirs

Just as the title suggests, can an option be provided to ignore hidden dirs? I tried

$ gdu -i /home/name/.[a-zA-Z]*
Error: accepts at most 1 arg(s), received 138

It did not work.

zfs filesystems are missed due to check for /dev

The following code prevents the detection of zfs mounts as potential "devices" to be scanned.

        file, err := os.Open("/proc/mounts")
        if err != nil {
                log.Fatal(err)
        }
        defer file.Close()

        scanner := bufio.NewScanner(file)
        for scanner.Scan() {
                line := scanner.Text()
                if line[0:4] == "/dev" {

Thanks,

Tom

Handle permission error when deleting files

Now, gdu panics on deleting file permission errors. It will be better if it shows a warning that says permission error, and optionally there could be a dialog to ask for root permission.

panic
panic: unlinkat /path/to/deleted/file: permission denied [recovered]
        panic: unlinkat /path/to/deleted/file: permission denied

goroutine 1 [running]:
github.com/rivo/tview.(*Application).Run.func1(0xc000462000)
        github.com/rivo/[email protected]/application.go:243 +0x87
panic(0x55a9954edfc0, 0xc000062390)
        runtime/panic.go:969 +0x1b9
github.com/dundee/gdu/tui.(*UI).deleteSelected(0xc00045c000)
        github.com/dundee/gdu/tui/tui.go:372 +0x16c
github.com/dundee/gdu/tui.(*UI).confirmDeletion.func1(0x0, 0x55a99534f462, 0x3)
        github.com/dundee/gdu/tui/tui.go:356 +0x3b
github.com/rivo/tview.(*Modal).AddButtons.func1.1()
        github.com/rivo/[email protected]/modal.go:104 +0x55
github.com/rivo/tview.(*Button).InputHandler.func1(0xc0000af240, 0xc000044060)
        github.com/rivo/[email protected]/button.go:129 +0x74
github.com/rivo/tview.(*Box).WrapInputHandler.func1(0xc0000af240, 0xc000044060)
        github.com/rivo/[email protected]/box.go:158 +0x62
github.com/rivo/tview.(*Form).InputHandler.func1(0xc0000af240, 0xc000044060)
        github.com/rivo/[email protected]/form.go:678 +0xee
github.com/rivo/tview.(*Box).WrapInputHandler.func1(0xc0000af240, 0xc000044060)
        github.com/rivo/[email protected]/box.go:158 +0x62
github.com/rivo/tview.(*Frame).InputHandler.func1(0xc0000af240, 0xc000044060)
        github.com/rivo/[email protected]/frame.go:187 +0x8d
github.com/rivo/tview.(*Box).WrapInputHandler.func1(0xc0000af240, 0xc000044060)
        github.com/rivo/[email protected]/box.go:158 +0x62
github.com/rivo/tview.(*Modal).InputHandler.func1(0xc0000af240, 0xc000044060)
        github.com/rivo/[email protected]/modal.go:196 +0x7f
github.com/rivo/tview.(*Box).WrapInputHandler.func1(0xc0000af240, 0xc000044060)
        github.com/rivo/[email protected]/box.go:158 +0x62
github.com/rivo/tview.(*Pages).InputHandler.func1(0xc0000af240, 0xc000044060)
        github.com/rivo/[email protected]/pages.go:309 +0xb5
github.com/rivo/tview.(*Box).WrapInputHandler.func1(0xc0000af240, 0xc000044060)
        github.com/rivo/[email protected]/box.go:158 +0x62
github.com/rivo/tview.(*Application).Run(0xc000462000, 0x0, 0x0)
        github.com/rivo/[email protected]/application.go:330 +0x6c2
github.com/dundee/gdu/tui.(*UI).StartUILoop(...)
        github.com/dundee/gdu/tui/tui.go:219
github.com/dundee/gdu/cmd.Run(0xc000098e10, 0xc000096b80, 0x1, 0x1, 0x1, 0x55a99552e8a0, 0xc0000b8008, 0xc00013fc00)
        github.com/dundee/gdu/cmd/run.go:107 +0x265
main.main.func1(0xc0001302c0, 0xc000096b80, 0x1, 0x1)
        github.com/dundee/gdu/main.go:26 +0xa7
github.com/spf13/cobra.(*Command).execute(0xc0001302c0, 0xc0000ae030, 0x1, 0x1, 0xc0001302c0, 0xc0000ae030)
        github.com/spf13/[email protected]/command.go:854 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001302c0, 0xc000098e3d, 0x55a995351c08, 0xb)
        github.com/spf13/[email protected]/command.go:958 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:895
main.main()
        github.com/dundee/gdu/main.go:40 +0x4b6

Use the current directory when there's no argument

I'd like gdu to behave like gdu .

About the current behavior, there are two possible options:

  1. This behavior can be toggled in the config.
  2. The current behavior when there's no argument can be moved to a command-line option.

Scan shouldn't traverse mounts

Just try selecting a volume that has an NFS mount on it, it traverses the network devices when scanning. Any mounts should probably excluded (maybe listed listed as a separate top-level device).

(It does seem quite a bit faster than ncdu though. Good job!)

snap - can't easily access all drives

Hi,

I package ncdu for snap and I see that gdu has the same issue on snap. I can't access all the system's drives. As example, my test system has this config

/dev/mapper/vgmint-root /               ext4    errors=remount-ro 0       1
/dev/mapper/sda		/Data		ext4	defaults	  0    	  0

When I run gdu from /Data I get the same error as in ncdu.
In /Data:
image

If I do want to interrogate /Data or any drive mounted to the system (not a USB) I need to browse to /var/lib/snapd/hostfs
image

Would it make sense to make gdu aware if it is running from snap and if so to use the path above as root?

[request] - Add SHA256 hashes to releases

Hi!

Is there any chance that you can update your CCI automation to also build a simple text file w/ the sha256 hashes of each release artifact? Ideally, in the same format as the Prometheus node exporter

E.g.:

3919266f1dbad5f7e5ce7b4207057fc253a8322f570607cc0f3e73f4a53338e3  node_exporter-1.1.2.darwin-amd64.tar.gz
5b0195e203dedd3a8973cd1894a55097554a4af6d8f4f0614c2c67d6670ea8ae  node_exporter-1.1.2.linux-386.tar.gz
<...>

Having the hash for each artifact makes it much easier to automatically fetch / verify binaries in various automation / system build processes.

"Version: development" when built from AUR

A possible solution:

  1. Use git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g' to get the version number. I'm not sure how to do this in Go, though.
  2. Show only vX.Y.Z if the result is vX.Y.Z.r0.gxxxxxxx, otherwise show the whole result.
  3. You need to provide a source with a part of the .git directory. You can refer to this.

Another possible solution: Make releases on another branch, where the version numbers are hardcoded.

However, I think it's good to have the commit hash in the version info of the development version.

Linuxbrew install of 5.2.0 fails

Not sure if this is the right place to report this issue, but when I try to install or upgrade to 5.2.0 I get:

brew install -f gdu
==> Downloading https://ghcr.io/v2/linuxbrew/core/gdu/manifests/5.2.0
curl: (22) The requested URL returned error: 404                              

Error: Failed to download resource "gdu_bottle_manifest"
Download failed: https://ghcr.io/v2/linuxbrew/core/gdu/manifests/5.2.0

Up until version 5.1.1 I didn't have any problems installing.

Error in installation command

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

throws

root@b0de4d6ceb55:/# gdu
gdu: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by gdu)

Feature: Empty instead of delete a useful directory.

Feature: Empty instead of delete a useful directory.

Some useful directories have a lot of large files, e.g. logs.
I usually empty the logs directory but don't delete it, becuse the application uses the logs directory all the time, delete the logs directory may cause application errors.

If this feature is acceptable, I will push a PR for this.

Cannot move around after exiting help view and keybindings suggestion

Hi! I imagine this is very much still in testing, but I tried your package from the AUR and noticed that:

  • after exiting the newly added help panel one cannot move around anymore; i.e. navigation is broken.
  • since you implemented some vi-like bindings, such as j, k, g and G; you could also use h and l as alternatives to Enter and the /.. button to navigate up and down folders.

arm64 architecture is missing for snap install

On a rasp pi 4 with arm64 architecture it is not possible to install gdu because only armhf builds are provided. Please provide arm64 builds as well :-)

Thank you very much in advance!

cannot find package "github.com/dundee/gdu/v4" in any of: goroot/gopath

Getting the following error

go get -u github.com/dundee/gdu/v4
package github.com/dundee/gdu/v4: cannot find package "github.com/dundee/gdu/v4" in any of:
        /usr/lib/go-1.13/src/github.com/dundee/gdu/v4 (from $GOROOT)
        /home/horseinthesky/go/src/github.com/dundee/gdu/v4 (from $GOPATH)

Is it something I should do in my env?

combined options (sometimes) don't work

The following command uses colorized output:

$ gdu -c -o gdu.out

The following command (after selecting "/") scans/shows an nfs-mounted directory below /mnt/.hostname

$ gdu -d -x

(while a loop-mounted ISO image at /mnt/cdrom is ignored as expected)

Using "-i" flag causes "runtime error"

Whenever I try to add an ignored directory, gdu fails with:

runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x5a17a2]

With some output dumped below the "Scanning..." window:

goroutine 1646 [running]:                                                                                                                                                                                                    
github.com/dundee/gdu/v4/analyze.getFlag(0x0, 0x0, 0x1)                                                                                                                                             
github.com/dundee/gdu/v4/analyze/dir.go:167 +0x22                                                                                      
github.com/dundee/gdu/v4/analyze.(*ParallelAnalyzer).processDir(0xc0000c25c0, 0xc0009efbe0, 0xe, 0x0)                                                                                                                                                                                        
github.com/dundee/gdu/v4/analyze/dir.go:128 +0x48c                                                                                                                                     
github.com/dundee/gdu/v4/analyze.(*ParallelAnalyzer).processDir.func1(0xc0000c25c0, 0xc0009efbe0, 0xe, 0xc0008540c0, 0xc0009ef960)   
github.com/dundee/gdu/v4/analyze/dir.go:114 +0x5d                                                                                                                                                       
created by github.com/dundee/gdu/v4/analyze.(*ParallelAnalyzer).processDir                                                                             
github.com/dundee/gdu/v4/analyze/dir.go:112 +0x3fb

Executed command:

# ran as sudo
/home/linuxbrew/.linuxbrew/bin/gdu -i /media/alex/Jumbo

If I add the directory where it failed to the list of ignored directories, it fails at other random places, including files in the home folder.

Environment:

Linux Mint 19
gdu version: v4.8.0

Test seems to fail depending on host filesystem

TestFlags() seems to fail depending on what filesystem the repository is checked out to. When doing make test from the repo on an ext4 volume, all tests pass. On the other hand, on a btrfs volume, I get a failure:

    dir_test.go:82: 
                Error Trace:    dir_test.go:82
                Error:          Not equal: 
                                expected: 0
                                actual  : 4096
                Test:           TestFlags
--- FAIL: TestFlags (0.00s)

(this is in both cases with go 1.16.5 on NixOS 21.05, Linux 5.10.37)

This particular test also fails on Hydra, the NixOS build server, with yet different output: https://hydra.nixos.org/build/145014299/nixlog/1

simple file viewer for text files

Sometimes it is very useful to be able to simply look into a text file while browsing through the files and directories, please add a very basic file viewer :-)

Man page

Nothing comes up for man gdu. I'm guessing this is because one hasn't been written, though it's also possibly a packaging error on my distro.

the instruction of installing on Ubuntu is out of date?

add the ppa repo described in readme, failed to load the repo,

$ sudo add-apt-repository ppa:daniel-milde/gdu
 PPA for Gdu and its dependencies
 More info: https://launchpad.net/~daniel-milde/+archive/ubuntu/gdu
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                                 
Get:3 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]                                               
Hit:4 https://download.docker.com/linux/ubuntu bionic InRelease                                                                              
Hit:5 https://deb.nodesource.com/node_12.x bionic InRelease                                                                                  
Hit:6 http://security.ubuntu.com/ubuntu bionic-security InRelease                                                                            
Ign:7 http://ppa.launchpad.net/daniel-milde/gdu/ubuntu bionic InRelease  
Err:8 http://ppa.launchpad.net/daniel-milde/gdu/ubuntu bionic Release         
  404  Not Found [IP: 91.189.95.85 80]
Reading package lists... Done                      
E: The repository 'http://ppa.launchpad.net/daniel-milde/gdu/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Ubuntu info,

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Feature: Quickly view the head or tail of the selected file

Quickly view the head or tail of the selected file, it's helpful to confirm if the file is deletable.

Suggestion:
The key h mapping for quickly view the head of the selected file.
The key t mapping for quickly view the tail of the selected file.

go build command not working

here is my output:

go get -u github.com/dundee/gdu/v4/cmd/gdu
package github.com/dundee/gdu/v4/cmd/gdu: cannot find package "github.com/dundee/gdu/v4/cmd/gdu" in any of:
        /usr/local/Cellar/go/1.13.6/libexec/src/github.com/dundee/gdu/v4/cmd/gdu (from $GOROOT)
        /Users/myuser/.local/src/github.com/dundee/gdu/v4/cmd/gdu (from $GOPATH)

I have tested both on Mac and Linux.

support for not counting mounts

Hi, I tried to use gdu with "/" on my system that has many many many snaps mounted (approximately 316 I think), and each "snap" revision is mounted from a snap file located in /var/lib/snapd/snaps/... onto a directory like /snap/{name}/{number}. This resulted in gdu counting the disk usage of /snap/something/2 and /snap/something/3, etc. and ending up taking a long time and totaling to be over twice the actual size of the hard-disk. I wonder if gdu could inspect /proc/self/mountinfo or just the mountnpoint command, etc. to determine if a directory is a mount from somewhere else and ignore that for the purposes of calculating disk usage.

Otherwise I found this to be a really cool application, thanks for building it!

delete /

It is possible to delete /

go in the program in /root and delete ../

Now your system is fucked up... und you too 🗡️

Sharing another benchmark for nnn

I was referring to the benchmark section and decided to run it on my personal system. I have a SSD drive (stats are du:91.562G free:19.316G files:358098).

I got the the following results at cold boot with gdu and nnn:

$ time gdu-linux-amd64 /
gdu-linux-amd64 /  2.24s user 2.48s system 149% cpu 3.153 total  
$ time nnn -T d /
nnn -T d /  0.17s user 4.06s system 36% cpu 11.504 total

Considering the CPU usage difference also I see the user+system time is comparable: gdu 4.72s, nnn 4.23s.

ATM I am not sure why the benchmarks vary so much so wanted to share this.

"canning" in konsole/gnome-terminal

The title of the progress bar is "canning" in konsole and gnome-terminal, but it works well ("Scanning") in xterm.

gdu version: v1.6.0

Screeshots

konsole

图片

gnome-terminal

图片

xterm

图片

Apt package?

Is there an APT version, or a PPA? (for debian/ubuntu)

brew install fails when coreutils is already installed

On my macOS system that has the coreutils formula already installed:

$  brew install gdu
==> Downloading https://ghcr.io/v2/homebrew/core/gdu/manifests/4.10.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gdu/blobs/sha256:9af37b330b0d64a2cc96927f4bd9b005a2c492f8bd084c0a1df531e7b1f003c2
==> Downloading from https://pkg-containers-az.githubusercontent.com/ghcr1/blobs/sha256:9af37b330b0d64a2cc96927f4bd9b005a2c492f8bd084c0a1df531e7b1f003c2?se=2021-04-08T22%3A45%3A00Z&sig=pmNS716JpYgRzbYu9TTTG9o9f94Nx
######################################################################## 100.0%
Error: Cannot install gdu because conflicting formulae are installed.
  coreutils: because both install `gdu` binaries

Please `brew unlink coreutils` before continuing.

Unlinking removes a formula's symlinks from /usr/local. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side effects in the
resulting software.

In coreutils, they link du to gdu to indicate that it's "GNU du". Personally I'm OK with unlinking coreutils, but this could be surprising to many users.

One suggestion could be to provide a non-conflicting binary as an option (like go-gdu or something?)... Not sure what the best fix is.

And, maybe there's no fix possible - but I just wanted to provide some new-user feedback 😉

gdu version of `go get` is very simple

Just like this post #31 (comment)

Now I tried to update my gdu to the latest commit, so I use go get -u github.com/dundee/gdu again, but the gdu in my PATH which is ~/.go/bin/gdu is very simple as above link has listed and

>> gdu -v
Version:         development
>> gdu -h
Usage of gdu:
  -ignore string
        Absolute paths to ignore (separated by comma) (default "/proc,/dev,/sys,/run")
  -log-file string
        Path to a logfile (default "/dev/null")
  -v    Prints version

I tried to delete all gdu file and directories in my ~/.go which is my GOPATH and go get -u xxx again, or redefine my GOPATH to another directory like ~/go and go get -u xxx again, but all the gdu are the same simple one.

So is this go get or the code itself wrong?

'v' key show content bug

QQ截图20210509182049
QQ截图20210509181649

When I entering the second level directory, push 'v' key the show the content, and then I push the 'left' key. Now, what ever I push the 'v' key or 'q' key, I could not do anything but push CTRL + 'C' to quit the software.

enter doesn't do the same as l/right

I have certain directories where enter works as expected, but l and right enter the directory without showing any files(not even /..)
I'm not yet sure what's so special or different about these directories so I can't really tell you how to reproduce it.
So if you have any ideas or want me to test something, just tell me :)

Save and restore to file

From ncdu manpages:

       Since scanning a large directory may take a while, you can scan a directory and export the results for
       later viewing:

         ncdu -1xo- / | gzip >export.gz
         # ...some time later:
         zcat export.gz | ncdu -f-

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.