### Formulas to Calculate Dimensionless Hard Disk Size, and a Real World Application to Extending a UFS Partition

The dimensionless hard disk size is a quantity that gives a measure of hard disk size without any associated physical dimension (i.e. not measured in bytes, kilobytes, ... - just a number.) This quantity manifests itself in many places, such as: in the VMware vmdk disk descriptor file, and when sizing partitions.

**Part 1: Formulas to calculate R (The Dimensionless Hard Disk Size) from Cylinders, Heads, and Sectors; Cylinder Groups, Heads, and Sectors; and Volume Capacity, and Sector Size***In the below;**

*is used for multiply, and*/

*for divide*

__1.1 Variables Used__

R = The Dimensionless Hard Disk Size

C = Cylinders

H = Heads

T = Tracks (and T = C * H)

Cyl = Cylinder Groups (used with Unix File System (UFS))

S = Sectors per Track

B = Sector Size in bytes

V = Volume Size in bytes (i.e. disk max capacity; volume, or partition size)

__1.2 Formulas for R__

R = C * H * S

R = (SUM of Cylinders in all Cylinder Groups) * H * S

R = V / B

__1.3 Formulas for V (obtained from the above)__

V = C * H * S * B

V = R * B

*Important notes:*

*1) R is always a positive integer, as are all the other variables used*

*2) Real world values given for disk capacity may need to be converted into the integer value that best satisfies the requirement for the other variables to be integers*

**Part 2: Real World Application to Extending a UFS Partition**The following "real world" application of the formulas, is inspired by following blog post by Julian Wood - Installing & Maximising the NetApp ONTAP 8.1 Simulator

__2.1 The problem__

We expand a 48 GB VMware vmdk hard disk to 244 GB. The hard disk in question is already partitioned into 4 partitions, and we need to find the new size value for the 4

^{th}partition, to make it use up all the extra usable space that is now available.__2.2 Calculations and Explanation__

Booting into the FreeBSD_LiveFS ISO media, and in fixit mode; the

**fdisk ad0**command is run to view the partitions on the disk in question (ad0.)The output of the fdisk ad0 command provides the following bits of information:

B =

**512**bytes (Sector size)H =

**15**(Heads – numbered from 0 to 14)S =

**63**(Sectors per Track – numbered from 1 to 63)PartitionStartValue =

**4191264**And from the real world disk capacity of the hard disk (Vreal = 244GB) in bytes, we get Rreal:

**Rreal = int( Vreal / B )**

= int( 244*1024*1024*1024 / 512 )

=

**511705088***Note:*

*int( x ) is a function that returns the integer value of x. The int function is included in Windows Calculator on the Scientific view. If you do not have this function then just lose everything after the decimal point.*

The disk is split into cylinders (value unknown), heads (15), and sectors (63.) We cannot find out the number of cylinders (would need to know the amount of cylinders in each cylinder group, and there will be quite a few cylinder groups.) But we know that the max value of R (Rmax) must be an integer divisible by heads (15) multiplied by sectors (63.)

**Rmax = 15*63 * int( Rreal / (15*63) )**

=

**511704270**Finally, to find the new size of partition 4 (Rsize):

**Rsize = Rmax – PartitionStartValue**

**= 507513006**

When we run the

**fdisk -u ad0**command to extend partition 4; when prompted for the value for the new "size," the above figure – 507513006 – is supplied!

__2.3 Summary__

**Rsize = H * S * int{ int( Vreal / B ) / ( H * S ) } - PartitionStartValue**

**Part 3: Appendix – Further Reading**
## Comments

## Post a comment