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

Calling disk.Partitions(false) produces different list on Linux to "df" #1617

Open
tomqwpl opened this issue Mar 28, 2024 · 1 comment
Open

Comments

@tomqwpl
Copy link

tomqwpl commented Mar 28, 2024

This is actually prompted by this use within Hashicorp Nomad.

This is for the Linux platform.

Calling "Partitions" reads /proc/1/mountinfo and then correlates the filesystem type to what is returned from /proc/filesystem. Things that are marked as "nodev" in that file are not considered.

This is not what df is doing though.

My test environment here is a docker image. df shows:

 df
Filesystem      1K-blocks       Used Available Use% Mounted on
overlay        1055762868  393449744 608609652  40% /
tmpfs               65536          0     65536   0% /dev
tmpfs            16354108          0  16354108   0% /sys/fs/cgroup
shm                 65536         32     65504   1% /dev/shm
C:\            1999902716 1389904944 609997772  70% /home
/dev/sdd       1055762868  393449744 608609652  40% /etc/hosts
tmpfs            16354108       8320  16345788   1% /run

This is what I would class as the expected behaviour

Output from calling "partitions(false)" (printing filesystem and mountpoint):

ext4 /etc/resolv.conf
ext4 /etc/hostname
ext4 /etc/hosts

This is what I would class as the current behaviour

The contents of /proc/filesystems shows:

nodev   overlay
nodev   tmpfs

So whatever filtering df does by default is different to what gopsutil does.

This isn't just in docker environment, I've also got test environments in WSL and standard Linux VM and I equally get different results.

@shirou
Copy link
Owner

shirou commented Mar 31, 2024

I'm sorry, but could you please describe the Current behavior and Expected behavior according to the Issue Template?

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

No branches or pull requests

2 participants