Saturday, January 17, 2009

Estimating Number of cylinders for a partition based on size estimate

Disk Basics
1.Track: The circular track on a disk
2.Geometric Sector: the Sector made by two radii intersecting all the tracks in the disk from the centre of the disk.
3.Track Sector: The intersection of two geometric radii on the same track which is a part of the geometirc sector is called a track sector.
4. Size of sector:- The size of sector for magnetic disks is 512 bytes and for optical media is normally 2048 bytes.
5. Clusters :- A collection of geometric sectors make a cluster for a filesystem. The cluster may not be comprised of continous sectors. The cluster size defines the least amount of size defined by the filesystem while creating the file.

The basic info while starting fdisk to partition a hard drive may be given in the manner shown below:-
64 heads,32 sectors
Which means there are 32 platters and each platter has a head on top and bottom,therefore, 64 heads and each platter(single side) contributes 32 sectors to a cylinder.
A cylinder is formed by taking one sector on each platter (above and below).
Total no of sectors in a cylinder= No of sectors contributing to a cylinder in the platter * No of platters
32 * 32 * 2= 2048 sectors
We have multiplied by 2 as platter has sectors both above and below.
Another statement in Fdisk is “capacity is cylinders of 2048 X 512 bytes
The above statement indicates that each sector can store 512 bytes. This can also be called as block size and each cylinder contains 2048 sectors. Therefore, each cylinder can store 2048* 512=1048576 bytes

Partition of the drive is done in cylinders . Fdisk also reports that the total no. of cylinders available is 8682. Therefore, if we want swap space of 128 MB, the number of cylinders required would be :-
128 * 1024*1024/1048576=128 cylinders.
Out of 8682 cylinders, 128 would be kept for swap, therefore, for root we have 8682-128=8554 cylinders

Therefore, for a disk with SGI label, The picture before root and swap partitions are created would be :-
Partition # Start End Description
9 0 1 SGI volhdr
11 0 8682 SGI volume

Now, we create partition # 1 (root) and Partition No 2 (swap) using 8554 cylinders and 128 cylinders respectively

Partition # Start End Description
9 0 1 SGI volhdr
11 0 8682 SGI volume
1 2 8554 Linux
2 8555 8682 Swap

No comments: