muesli / duf

Disk Usage/Free Utility - a better 'df' alternative
Other
12.86k stars 403 forks source link

Wildcard for excluding filesystems (TimeMachine) #106

Closed luckman212 closed 2 years ago

luckman212 commented 3 years ago

duf 0.6.0 from Homebrew

duf produces voluminous output on my system, due to a lot of filesystems mapped by TimeMachine → SMB share on my NAS:

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 17 local devices                                                                                                                                                                  │
├───────────────────────────────────────────────────────┬────────┬─────────┬────────┬───────────────────────────────┬───────┬───────────────────────────────────────────────────────┤
│ MOUNTED ON                                            │   SIZE │    USED │  AVAIL │              USE%             │ TYPE  │ FILESYSTEM                                            │
├───────────────────────────────────────────────────────┼────────┼─────────┼────────┼───────────────────────────────┼───────┼───────────────────────────────────────────────────────┤
│ /                                                     │ 931.5G │   14.0G │ 232.3G │ [....................]   1.5% │ apfs  │ /dev/disk1s5s1                                        │
│ /System/Volumes/Data                                  │ 931.5G │  683.1G │ 232.3G │ [##############......]  73.3% │ apfs  │ /dev/disk1s1                                          │
│ /System/Volumes/Preboot                               │ 931.5G │  348.2M │ 232.3G │ [....................]   0.0% │ apfs  │ /dev/disk1s2                                          │
│ /System/Volumes/Update                                │ 931.5G │ 1004.0K │ 232.3G │ [....................]   0.0% │ apfs  │ /dev/disk1s6                                          │
│ /System/Volumes/VM                                    │ 931.5G │    1.0G │ 232.3G │ [....................]   0.1% │ apfs  │ /dev/disk1s4                                          │
│ /Volumes/.timemachine/95A20C74-B2D8-4BF2-B753-966BA63 │   3.8T │  259.2G │   3.5T │ [#...................]   6.7% │ apfs  │ com.apple.TimeMachine.2021-02-02-070031.backup@/dev/d │
│ 23011/2021-02-02-070031.backup                        │        │         │        │                               │       │ isk4s1                                                │
│ /Volumes/.timemachine/95A20C74-B2D8-4BF2-B753-966BA63 │   3.8T │  266.9G │   3.5T │ [#...................]   6.9% │ apfs  │ com.apple.TimeMachine.2021-02-03-060550.backup@/dev/d │
│ 23011/2021-02-03-060550.backup                        │        │         │        │                               │       │ isk4s1                                                │
│ /Volumes/.timemachine/95A20C74-B2D8-4BF2-B753-966BA63 │   3.8T │  270.9G │   3.5T │ [#...................]   7.0% │ apfs  │ com.apple.TimeMachine.2021-02-04-042746.backup@/dev/d │
│ 23011/2021-02-04-042746.backup                        │        │         │        │                               │       │ isk4s1                                                │
│ /Volumes/.timemachine/95A20C74-B2D8-4BF2-B753-966BA63 │   3.8T │  270.6G │   3.5T │ [#...................]   7.0% │ apfs  │ com.apple.TimeMachine.2021-02-04-063743.backup@/dev/d │
│ 23011/2021-02-04-063743.backup                        │        │         │        │                               │       │ isk4s1                                                │
│ /Volumes/.timemachine/95A20C74-B2D8-4BF2-B753-966BA63 │   3.8T │  272.8G │   3.5T │ [#...................]   7.0% │ apfs  │ com.apple.TimeMachine.2021-02-04-211925.backup@/dev/d │
│ 23011/2021-02-04-211925.backup                        │        │         │        │                               │       │ isk4s1                                                │
│ /Volumes/.timemachine/95A20C74-B2D8-4BF2-B753-966BA63 │   3.8T │  272.8G │   3.5T │ [#...................]   7.0% │ apfs  │ com.apple.TimeMachine.2021-02-04-232354.backup@/dev/d │
│ 23011/2021-02-04-232354.backup                        │        │         │        │                               │       │ isk4s1                                                │
│ /Volumes/.timemachine/95A20C74-B2D8-4BF2-B753-966BA63 │   3.8T │  273.3G │   3.5T │ [#...................]   7.0% │ apfs  │ com.apple.TimeMachine.2021-02-05-012747.backup@/dev/d │
│ 23011/2021-02-05-012747.backup                        │        │         │        │                               │       │ isk4s1                                                │
│ /Volumes/.timemachine/95A20C74-B2D8-4BF2-B753-966BA63 │   3.8T │  273.5G │   3.5T │ [#...................]   7.0% │ apfs  │ com.apple.TimeMachine.2021-02-05-054028.backup@/dev/d │
│ 23011/2021-02-05-054028.backup                        │        │         │        │                               │       │ isk4s1                                                │
│ /Volumes/.timemachine/nas2._smb._tcp.local./D283BA05- │   4.0T │  274.2G │   3.7T │ [#...................]   6.7% │ smbfs │ //luke@nas2._smb._tcp.local./TimeMachine              │
│ 2364-4C54-B0D4-D0133C60A859/TimeMachine               │        │         │        │                               │       │                                                       │
│ /Volumes/Backups of mini                              │   3.8T │  273.4G │   3.5T │ [#...................]   7.0% │ apfs  │ /dev/disk4s1                                          │
│ /Volumes/Recovery                                     │ 931.5G │  585.3M │ 232.3G │ [....................]   0.1% │ apfs  │ /dev/disk1s3                                          │
│ /Volumes/storage                                      │  10.0T │    4.4T │   5.6T │ [########............]  43.9% │ smbfs │ //luke@nas2._smb._tcp.local/storage                   │
╰───────────────────────────────────────────────────────┴────────┴─────────┴────────┴───────────────────────────────┴───────┴───────────────────────────────────────────────────────╯

I tried various incarnations of -hide, -hide-fs, -only-fs etc but nothing I did worked to exclude those *.timemachine mounts. Is there any way to do this? The fs names are dynamic due to the snapshot nature of the system, so specifying them explicitly isn't really an option.

petecooper commented 3 years ago

See https://github.com/muesli/duf/issues/101 and https://github.com/muesli/duf/pull/107 which may address this.

luckman212 commented 3 years ago

I built the adrien/HideShow_mountPoint branch from source and tested this. It works (thanks) but doesn't support wildcards, so still doesn't really address the original issue.

A syntax like

duf -hide-mp '/Volumes/.timemachine*'

or

duf -only-mp '/System/Volumes/*'

would be ideal.

IGLOU-EU commented 3 years ago

The latest build fix your request @luckman212 ?

luckman212 commented 3 years ago

I haven't had a chance to try it yet! Trying now.

luckman212 commented 3 years ago

@IGLOU-EU I built freshly from master.

So duf --hide-mp '*time*' does work (all /Volumes/.timemachine/xxx... are hidden).

But I also tried duf --hide-mp '/Volumes/.time*' which does not work (nothing is hidden).

Is this expected?

IGLOU-EU commented 3 years ago

Nop ... this is not expected !

I can't reproduce this bug with the latest version of the code For me duf -only-mp '*run*' working like expected

Can you give me the result of duf -h


EDIT: duf --hide-mp '*time*' = all /Volumes/.timemachine/xxx... are hidden. Expected duf --hide-mp '/Volumes/.time*' = nothing is hidden. Not expected

luckman212 commented 3 years ago
$ duf -h
Usage of duf:
  -all
        include pseudo, duplicate, inaccessible file systems
  -hide string
        hide specific devices, separated with commas:
        local, network, fuse, special, loops, binds
  -hide-fs string
        hide specific filesystems, separated with commas
  -hide-mp string
        hide specific mount points, separated with commas (supports wildcards)
  -inodes
        list inode information instead of block usage
  -json
        output all devices in JSON format
  -only string
        show only specific devices, separated with commas:
        local, network, fuse, special, loops, binds
  -only-fs string
        only specific filesystems, separated with commas
  -only-mp string
        only specific mount points, separated with commas (supports wildcards)
  -output string
        output fields: mountpoint, size, used, avail, usage, inodes, inodes_used, inodes_avail, inodes_usage, type, filesystem
  -sort string
        sort output by: mountpoint, size, used, avail, usage, inodes, inodes_used, inodes_avail, inodes_usage, type, filesystem (default "mountpoint")
  -style string
        style: unicode, ascii (default "unicode")
  -theme string
        color themes: dark, light (default "dark")
  -version
        display version
  -warnings
        output all warnings to STDERR
  -width uint
        max output width
muesli commented 2 years ago

I can't seem to reproduce this with v0.7.0 anymore. Has this been fixed in go-wildcard, @IGLOU-EU?

IGLOU-EU commented 2 years ago

I have made a mistake in my last reply @muesli ...

go-wildcard doesn't support the dot like pattern matching. It only supports wildcard(*) and interrogation mark(?), the latter works like the classical dot(.).

But I can add it 🤔

muesli commented 2 years ago

go-wildcard doesn't support the dot like pattern matching. It only supports wildcard(*) and interrogation mark(?), the latter works like the classical dot(.).

That's fine, the dot . shouldn't be considered a wildcard. It is however part of the directory name, and that seems to work just fine from what I can tell, e.g.: duf --hide-mp '/Volumes/.time*' correctly hides the mount paths within /Volumes/.timemachine.

muesli commented 2 years ago

Closing this one as I believe this is working as expected now!

fuchsg commented 7 months ago

I hope, I may reopen this one as there still seems to be a problem on MacOS when the MP name contains capitalized letters. I have built from source and I can hide my TimeMachine MPs like so:

❯ duf --hide-mp '/dev, *com*'
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 7 local devices                                                                                            │
├─────────────────────────┬────────┬────────┬───────┬───────────────────────────────┬───────┬────────────────┤
│ MOUNTED ON              │   SIZE │   USED │ AVAIL │              USE%             │ TYPE  │ FILESYSTEM     │
├─────────────────────────┼────────┼────────┼───────┼───────────────────────────────┼───────┼────────────────┤
│ /                       │ 465.6G │ 423.1G │ 42.5G │ [##################..]  90.9% │ apfs  │ /dev/disk1s5s1 │
│ /System/Volumes/Data    │ 465.6G │ 423.1G │ 42.5G │ [##################..]  90.9% │ apfs  │ /dev/disk1s1   │
│ /System/Volumes/Preboot │ 465.6G │ 423.1G │ 42.5G │ [##################..]  90.9% │ apfs  │ /dev/disk1s2   │
│ /System/Volumes/Update  │ 465.6G │ 423.1G │ 42.5G │ [##################..]  90.9% │ apfs  │ /dev/disk1s6   │
│ /System/Volumes/VM      │ 465.6G │ 423.1G │ 42.5G │ [##################..]  90.9% │ apfs  │ /dev/disk1s4   │
│ /Volumes/Crucial X8     │   3.6T │ 899.8G │  2.8T │ [####................]  24.2% │ apfs  │ /dev/disk3s2   │
│ /Volumes/SDCard 64      │  59.4G │  26.0G │ 33.5G │ [########............]  43.7% │ exfat │ /dev/disk4s1   │
╰─────────────────────────┴────────┴────────┴───────┴───────────────────────────────┴───────┴────────────────╯
Note that I cannot use pattern `*TimeMachine*` or `*timemachine*` as both patterns won't hide the MPs. However, `*com*` and `*apple*`, respectively, are working.

But if I want to hide the /System MPs, using /System/* or *System* still yields all MP as shown above. Nothing is hidden.

❯ duf --hide-mp '/dev, *com*, *System*'
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 7 local devices                                                                                            │
├─────────────────────────┬────────┬────────┬───────┬───────────────────────────────┬───────┬────────────────┤
│ MOUNTED ON              │   SIZE │   USED │ AVAIL │              USE%             │ TYPE  │ FILESYSTEM     │
├─────────────────────────┼────────┼────────┼───────┼───────────────────────────────┼───────┼────────────────┤
│ /                       │ 465.6G │ 423.1G │ 42.5G │ [##################..]  90.9% │ apfs  │ /dev/disk1s5s1 │
│ /System/Volumes/Data    │ 465.6G │ 423.1G │ 42.5G │ [##################..]  90.9% │ apfs  │ /dev/disk1s1   │
│ /System/Volumes/Preboot │ 465.6G │ 423.1G │ 42.5G │ [##################..]  90.9% │ apfs  │ /dev/disk1s2   │
│ /System/Volumes/Update  │ 465.6G │ 423.1G │ 42.5G │ [##################..]  90.9% │ apfs  │ /dev/disk1s6   │
│ /System/Volumes/VM      │ 465.6G │ 423.1G │ 42.5G │ [##################..]  90.9% │ apfs  │ /dev/disk1s4   │
│ /Volumes/Crucial X8     │   3.6T │ 899.8G │  2.8T │ [####................]  24.2% │ apfs  │ /dev/disk3s2   │
│ /Volumes/SDCard 64      │  59.4G │  26.0G │ 33.5G │ [########............]  43.7% │ exfat │ /dev/disk4s1   │
╰─────────────────────────┴────────┴────────┴───────┴───────────────────────────────┴───────┴────────────────╯

What works is to use *ystem* like so:

❯ duf --hide-mp '/dev, *com*, *ystem*'
╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 3 local devices                                                                                        │
├─────────────────────┬────────┬────────┬───────┬───────────────────────────────┬───────┬────────────────┤
│ MOUNTED ON          │   SIZE │   USED │ AVAIL │              USE%             │ TYPE  │ FILESYSTEM     │
├─────────────────────┼────────┼────────┼───────┼───────────────────────────────┼───────┼────────────────┤
│ /                   │ 465.6G │ 423.1G │ 42.5G │ [##################..]  90.9% │ apfs  │ /dev/disk1s5s1 │
│ /Volumes/Crucial X8 │   3.6T │ 899.8G │  2.8T │ [####................]  24.2% │ apfs  │ /dev/disk3s2   │
│ /Volumes/SDCard 64  │  59.4G │  26.0G │ 33.5G │ [########............]  43.7% │ exfat │ /dev/disk4s1   │
╰─────────────────────┴────────┴────────┴───────┴───────────────────────────────┴───────┴────────────────╯

Also see #274. There may be a fix in PR #245.