inxi - How to display hard disk size information in bytes
littus
Status: New User - Welcome
Joined: 04 Apr 2018
Posts: 2
Reply Quote
Greetings:

Is there a way to have inxi display hard disk size information in bytes instead of GB/MB/KB:

$ inxi -c 0 -D
Drives: HDD Total Size: 1000.2GB (32.3% used)
ID-1: /dev/sda model: Crucial_CT1024MX size: 1000.2GB

I know that I could convert the displayed GB/MB/KB to bytes but it would be much easier to just have inxi display the size in bytes in order to skip the conversion step. I would appreciate any hints

Regards,

Bill
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3882
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
Make sure you're talking about new inxi, the 2.9 and newer version. Which uses GiB KiB TiB MiB

inxi pre 2.9 (latest 2.3.56, inxi-legacy branch, working name binxi) will never get any further updates beyond maybe a bug fix or two over the coming years.

What users want to do with output is up to them. Perl inxi, 2.9.xx -> and following also exports to json or xml.

The basic unit inxi 2.9x uses internally is KiB, because that's also the basic unit that almost all tools use internally, or can be made to use. Also because using Bytes is largely simply extra numbers that don't serve any useful purpose.

inxi pre 2.9 used somewhat inconsistent sizings, sometimes in M (aka MiB, 1024 KiB), sometimes in MB (1000 KB), new inxi is consistent, so you can parse the output however you want.

When working with new inxi, make sure you are always using the latest master branch, or, even better, development branch inxi-perl version (working name pinxi, always equal to or ahead of master branch inxi).

Technically I could add in a switch that basically would force all internal unit to bytes, ie, 1024x [KiB amount) but I honestly can't see how that could be beneficial since you can just do the conversion yourself on output assuming you want this for some output (I can't see any reason why anyone would actually want to see Byte count for a 2 TiB large drive, that's totally unreadable), and if you are parsing the output for other purposes, then there's no difference between you converting the units and me converting the units beyond losing a few rounding bytes here and there.

You'd have to present a very strong argument for why this would be desirable, and, more important, why YOU want it.

I'd further note, inxi passes all its sizings through the same size functions, it's not done per feature, that is, RAM, Processes, Memory, Partitions, Unmounted Partitions, RAID, Disks, etc.

So the real question is why you want it, and if you're even aware of new inxi, which changes everything? Technically I could add in an option switched flag but it's up to you to first demonstrate that you are using new inxi, and second, to give a good reason why you want this.

So given that inxi uses KiB internally, there would be no point in doing fake math on that on my end, and multiplying those values by 1024 to produce Bytes, and you taking KiB and multiplying them by 1024, since internally bytes are not used anywhere in inxi. So the real question is I guess: add a switch to convert all or some output units to KiB.
Back to top
littus
Status: New User - Welcome
Joined: 04 Apr 2018
Posts: 2
Reply Quote
Hi There:

Thank you for the response and the explanation. I was using the old inxi. I was not aware of the new inxi.

I am now using the latest pinxi:

$ pinxi --version
pinxi 2.9.11-01 (2018-04-03)
...
...

I am fine with doing my own conversion from KiB/MiB/GiB/TiB to Bytes.

I like that pinxi is able to export to JSON/XML. :-)

I have noticed one glitch in that pinxi displays that it is writing to JSON data even though XML has been specified as follows:

$ pinxi -c 0 -D --output xml --output-file /var/tmp/foo.xml
Writing json data to: /var/tmp/foo.xml
Data written successfully.

Regards,

Bill
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3882
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
Oh, lol, thank you for spotting that copy/paste bug, I'll get that fixed right away in pinxi. A few days from now that will become inxi 2.9.12

I suspected you might like the json export, or xml.

A things that might seem odd just so you know it:

the json and xml export leave in place key sorters, so you can actually get the data in the right order.

These can be sorted alphanumerically, using the entire key value, like : 001#Card or you can snip out the key prefix (001) and sort it numerically, all keys are 0 padded to 3 digits.

So if you use the json say, you'd loop it and sort by key, then on output, trim off the 0XX# part.

Another oddity I discovered the other day while testing is that it appears that the xml export module I'm using actually sorts by key automatically, this was a very pleasant surprise to discover.

json, by specification, is always randomly sorted, so the only way to get key value pairs in the right order is to use the key sorting.

Just as an aside, one of the very core design features of Perl inxi, the 2.9 and newer version, was 2 features, neither of which were possible in old inxi: 1. export data to json/xml, 2: support optional translation libraries. these both do roughly the same thing internally in terms of using key value pairs for everything, so I had to write new inxi from the ground up with that in mind.
Back to top
Display posts from previous:   

All times are GMT - 8 Hours