LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-14-2012, 10:29 AM   #1
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 158

Rep: Reputation: 3
What unit/size are Blocks measured in using fdisk?


Hello All,

Just had a simple question that I'm sure someone here will know...

When you run "fdisk -l" how can you get the sizes of the different partitions by looking at each partition's "Blocks" column..?

Code:
For Example:
$> fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          15      120456   83  Linux
/dev/sda2              16         277     2104515   82  Linux swap / Solaris
/dev/sda3             278        5221    39712680   8e  Linux LVM
I see the "Units" thing at the top but I really don't get it.. Does it mean that each "one" block is equal to 512 bytes?

If anyone could lend a hand that would be great.

Thanks in Advance,
Matt
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-14-2012, 11:04 AM   #2
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
This may help you
http://en.wikipedia.org/wiki/Cylinde...s_and_clusters
http://www.linuxquestions.org/questi...disk-l-765730/

Last edited by EDDY1; 02-14-2012 at 11:12 AM.
 
2 members found this post helpful.
Old 02-14-2012, 11:22 AM   #3
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 158

Original Poster
Rep: Reputation: 3
Hey Eddy1, thanks for the reply.

So if I understand this correctly I could use this equations below to get GB, MB, KB, and Bytes:

(NumBlocks*1024) will yield Bytes
(NumBlocks*1024)/2^10 will yield KiloBytes
(NumBlocks*1024)/2^20 will yield MegaBytes
(NumBlocks*1024)/2^30 will yield GigaBytes

So using the values from fdisk I would get the following:

Code:
  (120456*1024)/2^30 = 0.114875793
 (2104515*1024)/2^30 = 2.007021904
(39712680*1024)/2^30 = 37.872962952
                      --------------
               TOTAL = 39.99 GB
The total seems right... Thanks for you help!

EDITED:
Added other formulas to calculate KBs and Bytes...


Thanks Again,
Matt

Last edited by mrm5102; 02-14-2012 at 01:01 PM.
 
Old 02-14-2012, 11:25 AM   #4
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
You're welcome
I didn't understand it myself until searching for the answer to your post so, Thank you!

Last edited by EDDY1; 02-14-2012 at 11:28 AM.
 
  


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
reserved-blocks-percentage not changing drive size lindylex Linux - Hardware 9 01-16-2010 06:03 PM
Quotas: Use size instead of blocks? kenneho Linux - Server 2 08-19-2009 03:35 AM
Is there a way to partition with fdisk and specify size in MB? Thaidog Linux - General 3 03-19-2009 06:30 AM
C program for copying file in size of 1k blocks bhandu Linux - General 2 06-11-2007 08:01 AM
Fdisk To Se-size carlosinfl Linux - General 2 02-25-2007 03:21 PM


All times are GMT -5. The time now is 01:02 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