Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

df plugin working with multiple mounts of the same device #1611

Open
mjt0k opened this issue Feb 23, 2024 · 0 comments
Open

df plugin working with multiple mounts of the same device #1611

mjt0k opened this issue Feb 23, 2024 · 0 comments

Comments

@mjt0k
Copy link

mjt0k commented Feb 23, 2024

Description
When the same device is mounted multiple times (this is typical, for example, for a btrfs filesystem with multiple subvolumes, when one volume is mounted as root fs, another as /home, yet another as /opt, etc, also typical for bind mounts and in other cases), the df plugin will generate statistics for the last mount returned by df. While usually, it is best to use the first mount of the filesystem.

This is because df will include output for every mount point, the device which is mounted is the key - so all such mounts uses the same key, and the mountpoint is the label, - only the last label is used, each time the same device in df output is seen, overriding info for this key.

To Reproduce
It is enough just to bind-mount something, for example:

mkdir -p /mnt/tst && mount --bind / /mnt/tst

After this, statistics for root fs (/) will be gone, instead, stats for /mnt/tst will be shown.

Additional context
In most cases, the first mount should be used instead of the last. So, locally, I modified df plugin to reverse output of df, including tac into the pipe:

  df $dfopts 2>/dev/null | tac |

This fixes the issue for me. An alternative is to exclude all "wrong" mounts in the config, which is not productive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant