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

possible size conversion issue #17

Closed
daniejstriata opened this issue Oct 1, 2021 · 15 comments
Closed

possible size conversion issue #17

daniejstriata opened this issue Oct 1, 2021 · 15 comments

Comments

@daniejstriata
Copy link

daniejstriata commented Oct 1, 2021

Hi,

using LFS 1.0.0. When I compare this output to that from df and df -h the output from lfs seems wrong. total size is not 13G and the used from df is 8.5G but 9.1G on LFS.

┌──┬─────┬──────────────┬────┬────┬────┬─────────┬─────┬────┬──────────────────┐
│id│ dev │  filesystem  │disk│type│used│  use%   │avail│size│mount point       │
├──┼─────┼──────────────┼────┼────┼────┼─────────┼─────┼────┼──────────────────┤
│38│259:8│/dev/nvme0n1p1│SSD │xfs │9.1G│71% ███▌ │ 3.8G│13G │/                 │
│43│259:4│/dev/nvme5n1  │SSD │xfs │127M│ 1%      │  12G│12G │/var/local1       │
│44│259:6│/dev/nvme7n1  │SSD │xfs │106M│ 1%      │  11G│11G │/var/store1       │
│46│259:0│/dev/nvme1n1  │SSD │xfs │7.4G│77% ███▉ │ 2.3G│9.7G│/usr/local/Store  │
│45│259:1│/dev/nvme2n1  │SSD │xfs │518M│16% ▊    │ 2.7G│3.2G│/var/log          │
│47│259:5│/dev/nvme6n1  │SSD │xfs │306M│14% ▊    │ 1.8G│2.1G│/tmp              │
│42│259:2│/dev/nvme4n1  │SSD │xfs │ 36M│ 3% ▏    │ 1.0G│1.1G│/home             │
└──┴─────┴──────────────┴────┴────┴────┴─────────┴─────┴────┴──────────────────┘
→ df | grep /$
/dev/nvme0n1p1  12570604 8865848   3704756  71% /

→ df -h | grep /$
/dev/nvme0n1p1   12G  8.5G  3.6G  71% /
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        7.8G     0  7.8G   0% /dev
tmpfs           7.8G   12K  7.8G   1% /dev/shm
tmpfs           7.8G  900K  7.8G   1% /run
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/nvme0n1p1   12G  8.5G  3.6G  71% /
/dev/nvme1n1    9.0G  6.9G  2.2G  77% /usr/local/Store
/dev/nvme7n1     10G  101M  9.9G   1% /var/store1
/dev/nvme5n1     11G  122M   11G   2% /var/local1
/dev/nvme4n1   1014M   35M  980M   4% /home
/dev/nvme6n1    2.0G  292M  1.8G  15% /tmp
/dev/nvme2n1    3.0G  489M  2.6G  16% /var/log
tmpfs           1.6G     0  1.6G   0% /run/user/0
tmpfs           1.6G     0  1.6G   0% /run/user/1002
@Canop
Copy link
Owner

Canop commented Oct 1, 2021

To compare with lfs, don't use df -h (which uses the old 1024 based unit) but df -H which uses the ISO 1000 based unit.

@daniejstriata
Copy link
Author

AWS EC2 shows their sizes as GiB. Then to use the json output I have to do conversions in any case. Will it be possible to add a switch to print out the sizes differently as an option please?

@Canop
Copy link
Owner

Canop commented Oct 1, 2021

Will it be possible to add a switch to print out the sizes differently as an option please?

You mean when you output as JSON ?

@Canop
Copy link
Owner

Canop commented Oct 1, 2021

In JSON I could even output the two values, there's no real cost.

@daniejstriata
Copy link
Author

daniejstriata commented Oct 1, 2021

Can the switch be available for regular use and json output?

I had a look at df again. I've always used df -h. Interesting that df -h and df -H both prints G or M without distinction. I'm using EC2 which uses GiB and ideally the sizes from EC2 should match the sizes from the host without needing to convert in between.

I had a search on their mailing list and found this:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47023#16
Found this statements from LA Walsh

Side rant:
 Using decimal prefixes with a binary unit (1B=2**3 bits)
 defeats the purpose of using a common multiplier for metric.
 Since computers use base-2, similar prefixes should be used.
 Just because the disk-industry bought and paid for the
 ruling to use base-10 doesn't mean that memory comes in
 units of 1-million, 1-billion or 1-trillion bytes or
 that disk space is organized in decimal units.

I mailed the group and asked if they could print GB and GiB accordingly.

@Canop
Copy link
Owner

Canop commented Oct 1, 2021

I won't personally go and have a fight with the old guys still arguing that base-2 makes sense for units...

If you want to avoid ambiguity when reading the JSON, just multiply blocks by bsize, the result will be in bytes. df can output in bytes too.

@daniejstriata
Copy link
Author

daniejstriata commented Oct 7, 2021

@Canop Will it be still be possible to update file-size to do both conventions and incorporate those choices in lfs? The info from LFS is great but as soon as the info leaves the box other processes don't use ISO. As example the technicians here would ideally share the print from LFS as it is so neat and tidy in hangouts when busy troubleshooting but then infrastructure sees different sizes in AWS causing a small bit of confusion.

@Canop
Copy link
Owner

Canop commented Oct 7, 2021

There could be a launch argument, yes, and then the label of the column would be different.

@Canop
Copy link
Owner

Canop commented Oct 7, 2021

Maybe --unit SI (default) and --unit binary.

@daniejstriata
Copy link
Author

That can work.

@Canop Canop closed this as completed in 2ff92c3 Oct 7, 2021
@Canop
Copy link
Owner

Canop commented Oct 7, 2021

Not yet released but testable from master.

Not sure whether I'll keep the ugly "i" everywhere.

image

@daniejstriata
Copy link
Author

daniejstriata commented Oct 7, 2021

The GNU coreutils guys seems to have decided to only print the G for ISO and Binary back when a terminal screen's real-estate was limited. I'd print the "i".

@Canop
Copy link
Owner

Canop commented Oct 8, 2021

I noticed you were concerned with alignment too.
So... a subtle change...
image

@daniejstriata
Copy link
Author

Is this a before and after screenshot? The headers use different words between the 2 commands you ran. free vs available and used vs use. Used and Free seems correct.

@Canop
Copy link
Owner

Canop commented Oct 8, 2021

That was the "subtle change" (not completely decided): when units is "binary", picking different words so that the alignment is better (you have one more character usually with the 'i').

EDIT: This would only add confusion, reverting to const labels.

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