                         FYI

(Note: The origin of this information may be internal or external
to Novell.  Novell makes every effort within its means to verify
this information.  However, the information provided in this
document is FOR YOUR INFORMATION only.  Novell makes no explicit or
implied claims to the validity of this information.)


          TITLE: Selecting FDISK Partition Sizes
   DOCUMENT ID#: FYI-M-1207
           DATE: 08SEPT92
        PRODUCT: DR DOS
PRODUCT VERSION: 6
    SUPPLEMENTS: FYI-M-1208 

     
Important!
This Technical Bulletin describes the calculations necessary in
order to FDISK a hard drive with a specific cluster size. The
information contained in this document is intended for advanced
users and is not supported by Novell. 

The FDISK utility can erase all data on a physical drive and
backups of any existing data are strongly recommended before using
FDISK. 

The hard drive used as an example is a 405MB SCSI with 48 heads, 17
sectors per track and 1024 cylinders. 2KB clusters with a 16 bit
FAT are the target because this allows the maximum partition size
in MegaBytes with the smallest possible cluster. The cluster size
is kept as small as possible because this will be the smallest
amount of disk space, in bytes, that will be used for any file
(even zero byte files). This example assumes that the entire disk
will be utilized for DOS media. 

Conventions:
This document uses several mathematical formulas. To avoid
confusion, the dash/minus character "-" is only used for math
functions. Instead of using typical X or Y variables this document
will use variable names. Only one word for each variable will be
used. If a variable name would normally consist of more the one
word the words will be connected with underscores "_" to tie them
to a single name. An example would be the variable "sector size"
which is used in this document as "sector_size".

Mathematical operators used:
+    addition
-    subtraction
/    division
*    multiplication
<    less than
~=   approximately equal to
=    equal to

Definitions:
Hard Disk "Heads":  The number of heads for your hard disk. 

Sector:             A portion (or radial sector) of a track.

Track:              All sectors in a given track under a single
                    hard disk head.

Cylinder:           All sectors in a given track under all of the
                    hard disk heads. All "tracks" within the
                    cylinder are parallel to the hard disk's 
                    center of rotation. DOS supports a maximum of
                    1024 cylinders per physical hard disk.

Partition:          A collection of cylinders used by an Operating
                    System as it's file system.  By convention, all
                    partitions start on cylinder boundaries.

Primary Partition:  Under DOS, this is the Active Partition (where
                    DOS's system files are located).

Extended Partition: Under DOS, in order to reserve space on the
                    hard disk as owned by DOS and therefore
                    unavailable to any other operating system, 
                    DOS creates an Extended Partition within which
                    Logical Partitions can be created.

Logical Partition:  Under DOS, each Logical Partition resides
                    within the Extended Partition. There should be
                    at least one Logical Partition in the Extended
                    Partition.

Constants:
HD Head Count: 48 (30h)   This number is drive specific. In the
               sample hard disk, this is a translated value.
               Translation is a method that enables a disk with
               more than 1024 cylinders to be supported by DOS. 

Sectors/Track: 17 (11h )   This number is drive specific, but
               typically 17.

Sector Size:   512 bytes   Usually a constant, but if varied, this
               value must be a power of 2.

Cylinder Count:1023   DOS and most other software have this upper
               limit. Remember that this value is zero relative, so
               1023 means 1024 total cylinders.

FAT Sizes:     12 bit fats  4096-18 reserved values = 4078 entries
               16 bit fats 65536-18 reserved values = 65518 entries
               (binary 1000000000000 = decimal 4096)

Cluster Sizes: 2KB clusters 4 sectors per cluster (512 bytes each
               sector)
               4KB clusters   8 sectors per cluster
               8KB clusters   16 sectors per cluster
               16KB clusters  32 sectors per cluster

Maximum DOS Partition Sizes:
To determine the capacity of a drive multiply the FAT_SIZE with the
CUSTER_SIZE. This will be the size in Bytes. To get the size in
MegaBytes divide twice by 1024 and 3 times to get GigaBytes.

8MB = 12 bit FATs * 2KB Clusters  = (((4077 * 2048) / 1024) / 1024)

16MB= 12 bit FATs * 4KB Clusters  = (((4077 * 4096) / 1024) / 1024)

32MB= 12 bit FATs * 8KB Clusters  = (((4077 * 8192) / 1024) / 1024)

128MB= 16 bit FATs * 2KB Clusters  = (((65517 * 2048) / 1024) /  
       1024)

256MB= 16 bit FATs * 4KB Clusters  = (((65517 * 4096) / 1024) /   
       1024)

512MB= 16 bit FATs * 8KB Clusters  = (((65517 * 8192) / 1024) /   
       1024)

1GB = 16 bit FATs * 16KB Clusters = (((65517 * 16384) / 1024) /   
      1024 / 1024)

2GB = 16 bit FATs * 32KB Clusters = (((65517 * 32768) / 1024) /   
      1024 / 1024)

Cluster sizes are a direct result of the size of the partition. 
For example, requesting a partition size of 101M will result in a
partition with 16 bit FATs and a cluster size of 2KB,  just as a 12
bit FAT with 8KB clusters will be limited to 32MB.  The reason for
support of 12 bit FATs is backward compatibility with versions of
DOS prior to 3.0. 

Recommended Example of Logical Partition Layout:
To get 2KB clusters, the partition needs to be greater than 32MB
but less than 128MB. The example drive is 405MB. 4 Partitions of
101MB each will achieve the target cluster size.

32MB < Primary Part. 1 < 128MB (101MB  16 bit FATs with 2KB
Clusters)

32MB < Logical Part. 2 < 128MB (101MB  16 bit FATs with 2KB
Clusters)

32MB < Logical Part. 3 < 128MB (101MB  16 bit FATs with 2KB
Clusters)

32MB < Logical Part. 4 < 128MB (101MB  16 bit FATs with 2KB
Clusters)

Using FDISK to Create the Example Partitions:
Assuming that the hard disk is empty of partitions, create the
following partitions using FDISK.  Here are the necessary variables
and formulas for performing this task: 

divisor  = number_of_heads * number_sectors_per_track * sector_size
partition_size = size_of_partition_in_bytes / divisor
max_cylinders   = 1023  

In our example of 48 heads, 17 sectors and 512 byte sector size,
the divisor would be:
divisor = 48 * 17 * 512 = 417,792

partition_size =  101MB / divisor = 101 * 1024 * 1024 / 417,792 = 
 253.49 ~= 254

The reason for multiplying by 1024 twice is because the partition
size is in Bytes not MegaBytes. Round up any fractional amount.

max_cylinders = 1023 (or the maximum cylinder count for the sample
hard disk. FDISK will show you this value.)

Below is what is needed to create a disk with a 101MB primary
partition and 3 logical drives of 101MB each in 1 extended
partition. (This equates to having 4 drive letters - C: D: E: F:) 

1) Primary Partition with a Cylinder Range of (0,254).
Starting Cylinder = 0
Ending Cylinder = 254 (partition_size calculated above)

2) Create an Extended Partition with a Cylinder Range of (255,    
   1023).
Starting Cylinder = 255 (Ending Cylinder from step 1 + 1)
Ending Cylinder  = 1023 (max_cylinders)

3) Create a Logical Partition with a Cylinder Range of (255, 511).
Starting Cylinder = 255 (Same as the Starting Cylinder for the    
   Extended Partition in step 2.)
Ending Cylinder  = 511 (Starting Cylinder + partition_size)

4) Create a Logical Partition with a Cylinder Range of (512, 766).
Starting Cylinder = 512 (Ending Cylinder from step 3 + 1)
Ending Cylinder  = 766 (Starting Cylinder + partition_size)

5) Create a Logical Partition with a Cylinder Range of (767, 1023).
Starting Cylinder = 767 (Ending Cylinder of step 3 + 1)
Ending Cylinder  = 1023 (Starting Cylinder + partition_size)