Configuring FATFS Cache Parameters for the File Server (Windows Embedded CE 6.0)

1/6/2010

You can use the registry to configure the cache parameters for the FAT file system (FATFS) for a File Server. The cache parameters for FATFS are stored in the CacheSize value of type DWORD under the [HKEY_LOCAL_MACHINE\System\StorageManager\FATFS] registry key. The CacheSize value specifies the size of the disk cache in terms of the number of sectors.

The value for CacheSize must be a power of 2 and must be at least 16 sectors.

For example, to calculate the ideal CacheSize value for a 120GB USB Hard Drive, you can perform the following calculation:

CacheSize = (TotalSectors/SectorsPerCluster*FatVersion/8+(BytesPerSector-1))/BytesPerSector

The following list shows a breakdown of each formula value and lists possible values:

  • FatVersion = 12, 16 or 32. For a 120GB disk, this value will be 32.

  • BytesPerSector = 512.

  • ClusterSize = 32K. This value is chosen at disk format time.
    Most drives using FAT32 have the following breakdown of the ClusterSize value:

    Partition Size Cluster Size

    1GB-8GB

    4KB

    8GB-16GB

    8KB

    16GB-32GB

    16KB

    32GB

    32KB

  • TotalSectors = TotalBytes/BytesPerSector = 120*1000*1000*1000/512 = 234375000

    Note

    Manufactures of hard drives use 1000 instead of 1024 to calculate the disk size in gigabytes.

  • SectorsPerCluster = ClusterSize/BytesPerSector = 32768/512 = 64

Therefore, the CacheSize value for a 120GB disk using the above formula would be:

CacheSize = (234375000/64*32/8+511)/512=28612 sectors

The preceding result implies that to ensure optimal performance with a 120 GB hard drive, you need to set the following registry value to signal to the FAT file system to create a 14MB cache in memory for file system operations:

[HKEY_LOCAL_MACHINE\System\StorageManager\FATFS]
  "Flags"=dword:00000004
  "CacheSize"=dword:6FC4

See Also

Concepts

File Server OS Design Development

Other Resources

FAT File System Registry Settings
FAT File System