fdisk (cylinders and blocks)

Understanding Fdisk -l

cylinders and blocks 

[root@velocity-lab ~]# fdisk    -l /dev/sda
Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders,
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b5efb
		    (blocks=1024 bytes)
                          (cylinders)                    (kb)
  Device   Boot        Start         End      		Blocks   	Id  System
/dev/sda1    *           1            33      		262144   	83  Linux
/dev/sda2                33           1339    		10485760   	83  Linux
/dev/sda3                1339         1600     		2097152   	82  Linux swap / Solaris
/dev/sda4                1600         10444    		71040000    	5  Extended
/dev/sda5                1600         10444    		71037952   	8e  Linux LVM

actually the hard drive size i allocated was 80 GB but above it shows /dev/sda: 85.9 GB

fdisk calculates space as 1000 bytes=Kb, 1000 Kb=Mb and 1000mb=GB instead of 1024

so if we have to calculate the space manually then using above information:

heads * sectors * 512 * cylinders

255*63*512*no of cylinders

255 * 63 * 512 * 10443=85896599040 bytes

85896599040/1024=83883397.5 kb

83883397.5/1024=81917.4mb

81917/1024=79.997gb

approx    80Gb

/dev/sda1    *           1            33      		262144   	83  Linux

From above , /dev/sda1  is 262144 bocks

this means block=1024 bytes

so, it is actually 262144 KB

now in MB it would be 262144/1024= 256mb, if you want to convert it to GB then 256/1024=0.25 GB

therefore /dev/sda1 is 256 MB

Now, lets suppose we want  to convert GB to cylinders,

/dev/sda3         1339         1600        2097152      	82  Linux swap / Solaris

from above we have /dev/sda3  2097152 blocks or 2097152kb or 2048mb or 2gb

to convert it to cylinder we need to    use this formula

cylinder=bytes/heads * sectors * 512

= 2gb/255 * 63 * 512

= 2 *1024 * 1024 * 1024 /255 *63 *512

=2147483648/8225280

cylinders=261.08

/dev/sda3            1339        1600                       2097152                82  Linux swap / Solaris

1600 – 1339 = 261 cylinders.

 

[Note: 1024 bytes = 1 KB

1024 KB = 1 MB

1024 MB = 1 GB ]

 

Leave a Reply