LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-24-2012, 08:57 AM   #1
alieblice
Member
 
Registered: Jul 2011
Posts: 80

Rep: Reputation: Disabled
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
 
Old 12-24-2012, 09:02 AM   #2
secretservgy
Member
 
Registered: Jul 2006
Location: New York, USA
Distribution: kUbuntu 12.04.1 LTS, Debian, Whiite-Linux
Posts: 50

Rep: Reputation: 19
Are you using these conversion factors?

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

2,097,152 blocks = 1,073,741,824 bytes = 1GB
 
Old 12-24-2012, 09:14 AM   #3
alieblice
Member
 
Registered: Jul 2011
Posts: 80

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by secretservgy View Post
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 ?
 
Old 12-24-2012, 09:23 AM   #4
secretservgy
Member
 
Registered: Jul 2006
Location: New York, USA
Distribution: kUbuntu 12.04.1 LTS, Debian, Whiite-Linux
Posts: 50

Rep: Reputation: 19
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
 
Old 12-24-2012, 09:29 AM   #5
secretservgy
Member
 
Registered: Jul 2006
Location: New York, USA
Distribution: kUbuntu 12.04.1 LTS, Debian, Whiite-Linux
Posts: 50

Rep: Reputation: 19
Deleted.
 
Old 12-24-2012, 11:35 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,959

Rep: Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268
Quote:
Originally Posted by secretservgy View Post
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.)

Last edited by rknichols; 12-24-2012 at 11:42 AM. Reason: add comment
 
1 members found this post helpful.
Old 12-24-2012, 12:46 PM   #7
alieblice
Member
 
Registered: Jul 2011
Posts: 80

Original Poster
Rep: Reputation: Disabled
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to determine number of blocks of a logical volume Iyyappan Linux - Server 7 04-27-2012 01:58 AM
[SOLVED] What unit/size are Blocks measured in using fdisk? mrm5102 Linux - Newbie 3 02-14-2012 11:25 AM
How to determine number of blocks for a partition rcmonroig Linux - Newbie 1 07-01-2010 06:27 AM
Is there a way to partition with fdisk and specify size in MB? Thaidog Linux - General 3 03-19-2009 06:30 AM
fdisk partition size differs from mounted partition size jimieee Linux - General 3 10-15-2003 04:10 AM


All times are GMT -5. The time now is 08:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration