fdisk +size{K,M,G} is it 2^N or 10^N? Both ,I think

Reece Arnott <[email protected]>
Newsgroups gmane.org.user-groups.linux.dunedin.general
Message-ID <[email protected]>
I'm tracking down an issue and needed to know the exact number of bytes 
I'm creating a partition with using n fdisk script so I've looked in the 
source code (on my ubuntu 14.04 machine this is done with 'sudo apt-get 
source util-linux' and from looking specifically at the read_int_sx 
function it looks like there is an un-documented feature...

When you create a partition when you have decided where it starts (enter 
to take the default), you are asked for the end which you can give as 
the end or additional sector/cylinder number or set it based on an 
additional size in K, M, or G.

What I wanted to know was was if 1K=1000 or 1024 bytes (10^3 vs 2^10), 
1M=1,000,000 or 1024*1024 bytes (10^6 vs 2^20) etc.
It looks like you can actually give 6 options by including the 
undocumented option of a B as well:
K = 2^10 bytes
M = 2^20 bytes
G = 2^30 bytes
KB = 10^3 bytes
MB = 10^6 bytes
GB = 10^9 bytes

I haven't got a spare machine to play with at the moment (this is a bit 
of research I bought home from work with me) so I don't know if this is 
actually the case but thought I'd share it anyway and assume someone 
will tell me if I've read it wrong.
(the fdisk.c file I was looking at was last modified 18th October 2011 
and the util-linux version is 2.20.1-5.1ubuntu20)

-- 
"Believing men would act in their own interest was not cynicism, it turned out, but sheerest optimism; in reality men do not meet so high a standard."
-- Harry Potter and the Methods of Rationality (Chapter 84)
http://hpmor.com/

Reece Arnott
Dunedin
New Zealand


_______________________________________________
DunLUG mailing list
[email protected]
http://lists.ethernal.org/listinfo/dunlug
DunLUG Wiki - http://dunlug.kallisti.net.nz/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.