LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   problem in determine partition size from number of blocks shown in fdisk command (https://www.linuxquestions.org/questions/linux-newbie-8/problem-in-determine-partition-size-from-number-of-blocks-shown-in-fdisk-command-4175442789/)

alieblice 12-24-2012 07:57 AM

problem in determine partition size from number of blocks shown in fdisk command
 
Hi
i have problem in converting blocks to understandable size like mg or gigabyte.
i calculate my partition size by this formula :
Code:

(NumBlocks*1000)/1000000 will yield Megabytes
but i get nearly half of the size ? my swap partition is 2097 megabyte .
Code:

$ echo '(1024000*1000)/(1000000)' | bc
1024


secretservgy 12-24-2012 08:02 AM

Are you using these conversion factors?

Code:

2048 blocks = 1,048,576 bytes = 1MB

2,097,152 blocks = 1,073,741,824 bytes = 1GB


alieblice 12-24-2012 08:14 AM

Quote:

Originally Posted by secretservgy (Post 4856061)
Are you using these conversion factors?

Code:

2048 blocks = 1,048,576 bytes = 1MB

2,097,152 blocks = 1,073,741,824 bytes = 1GB


i don't know i found out that on google.
i think i confused.
i have partition with 1024000 blocks . how should i change it to megabyte ?

secretservgy 12-24-2012 08:23 AM

Well according to that conversion, blocks/2048=MB and blocks/2097152=GB

But that only gives you 500MB...?

Also, block size isn't always universal, it can be defined OraFAQ Forum

DB_BLOCK_SIZE

secretservgy 12-24-2012 08:29 AM

Deleted.

rknichols 12-24-2012 10:35 AM

Quote:

Originally Posted by secretservgy (Post 4856061)
Are you using these conversion factors?

Code:

2048 blocks = 1,048,576 bytes = 1MB

2,097,152 blocks = 1,073,741,824 bytes = 1GB


The term "block" can mean different things in different places. In fdisk, a block is 1024 bytes.

(EDIT: It's a carryover from the days when the file system block size was almost always 1024 bytes, which is seldom the case with today's huge disk drives.)

alieblice 12-24-2012 11:46 AM

thanks every body . problem solved .
I was thinking that block size have same size in every place .
so if i want to calculate my ubuntu partitions size in megabyte which have 41992192 blocks i can use this formula only in a case that your blocks have size of 1024 byte
(Number-Of-Blocks * 1024)/1000000 = 43000 megabyte
1 megabyte is 1000000 byte .
simply do this in terminal :

Code:

$ echo "(41992192*1024)/1000000"|bc
43000



All times are GMT -5. The time now is 07:10 AM.