home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / cdir100.zip / CDIR.DOC next >
Text File  |  1995-06-26  |  10KB  |  175 lines

  1.                               ClusterDir v1.00
  2.  
  3.  Why the FAT file system is inefficient
  4.  -------------------------------------
  5.  
  6.   Did you know that DOS lies to you each time you type the "DIR"  command?
  7.   It's true, well, sort of. You see, DOS reports a files length as the the
  8.   number  of  bytes in that specific file,  not by the amount of space the
  9.   file takes up on disk.  "Wait a minute,"  you say,  "How can  this  be?"
  10.   "Isn't the amount of bytes in a file the amount of space that file takes
  11.   up on a disk?"  The answer is, no.  No no no.  Allow me to explain.  DOS
  12.   uses  a file system called the FAT (File Allocation Table)  file system.
  13.   The FAT file system has been in use since the days  of  360k  diskettes,
  14.   and  it  was  ideal back then.  Then again,  having two big black floppy
  15.   disks on the front of your PC look pretty spiffy back then.  These  days
  16.   when  a one gigabyte hard disk is standard on new systems,  the FAT file
  17.   system seems totally prehistoric.  The problem with the FAT file  system
  18.   (well, one of it's many problems)  is that it stores files in allocation
  19.   units called clusters.  Clusters are equally divided  portions  of  your
  20.   hard  disk,  used to store files.  The cluster size of a given partition
  21.   depends on it's size. By multiplying the number of bytes per sector on a
  22.   given  partition  by  it's  sectors  per  cluster  we can determine it's
  23.   cluster size.  The below table shows cluster sizes  as  they  relate  to
  24.   various partition sizes.
  25.  
  26.                   Volume Size         Cluster Size
  27.                   -------------       ------------
  28.                   16MB  - 128MB       2048  bytes
  29.                   128MB - 256MB       4096  bytes
  30.                   256MB - 512MB       8192  bytes
  31.                   512MB - 1GB         16384 bytes
  32.                   1GB   - 2GB         32768 bytes
  33.                   2GB   - 4GB         65536 bytes
  34.  
  35.   For  a  file  to  be  stored on a FAT system it must (at the very least)
  36.   reside within one cluster. So if you have a 550MB partition your cluster
  37.   size is 16384 bytes.  Every file on that partition will take up at least
  38.   16384 bytes. DOS will report a one byte file as taking up only one byte,
  39.   when  in  reality  that  one byte file takes up 16384 bytes of hard disk
  40.   real estate. Those extra 16383 bytes are what is referred to as "Cluster
  41.   Overhang."  What  happens  when  a  file  size is over the length of one
  42.   cluster?  Well it is padded out to fit within cluster boundaries.  So  a
  43.   18,411 byte file on a system with a 8192 (8k)  cluster size will take up
  44.   a total of 24,576 bytes (three clusters.)
  45.  
  46.   Realizing this fact you may see now why disk space seems  to  go  a  lot
  47.   quicker than it seems it should.  The problem becomes very apparent on a
  48.   system with a large cluster size and many small files.  Each small  file
  49.   is  padded  out  to  fit within cluster confines and the result is a lot
  50.   wasted disk space.  On a system with many large files,  cluster overhang
  51.   is  less  apparent,  but it is still there.  It is rare to find a system
  52.   with a large ratio of large files.  It is extremely rare to find a  disk
  53.   that would benefit from the FAT file system.
  54.  
  55.   Is there any way out?  If you wish to continue running DOS/Windows there
  56.   are a few of solutions.  The best,  but far from most convenient  method
  57.   would be to reformat your disk to accommodate a smaller cluster size. If
  58.   you have a one gigabyte  disk  partitioned  to  one  big  partition  the
  59.   cluster size is 32768 bytes (32k)  -  which is an insane waste of space.
  60.   If you were to format that disk into two  500  megabyte  partitions  the
  61.   cluster  size  would  drop way down to 8192 bytes,  thus saving a lot of
  62.   wasted disk space.  Another solution (which I do not recommend to  loved
  63.   ones) is to install Stacker, by Stac Electronics.  Stacker uses it's own
  64.   file system for compressed drives. These drives, while FAT compatible do
  65.   not fall prey to cluster overhang. If you are looking to add drive space
  66.   via software compression and luck is on your side,  Stacker is a  viable
  67.   option,  if  not,  I  wouldn't  recommend  it.  Yet  another solution is
  68.   switching to either OS/2,  which can use the HPFS (High Performance File
  69.   System)  or  Windows/NT which can use both the NTFS (New Technology File
  70.   System)  and the HPFS file system.  What do these files system buy  you?
  71.   Under NTFS, cluster size is restricted to 4096 bytes,  no matter how big
  72.   the partition.  The HPFS file system allocates disk space  in  512  byte
  73.   sectors,  no matter how big the drive.  The space saved on a large drive
  74.   formatted with either of these two file systems is substantial.  "Wait!"
  75.   You  say,  "What about the new VFAT file system which ships with Windows
  76.   '95?" No go. The VFAT file system is simply the FAT file system, updated
  77.   to  handle  long  file  names.  Sans  the  boneheaded  8.3  file  naming
  78.   convention,  VFAT inherits all of FAT's shortcomings,  including cluster
  79.   overhang.
  80.  
  81.  Using The Program
  82.  -----------------
  83.  
  84.   ClusterDir (CDIR.EXE)  is a simple directory utility.  It is by no means
  85.   meant to be a "DIR"  replacement.  The principle use of CDIR is to get a
  86.   good  look  at  how  much space is being wasted on your hard disk due to
  87.   cluster overhang.  The use of CDIR is very simple,  just type "CDIR"  at
  88.   the  DOS  prompt  for  a  listing  of  the  current  directory.  You can
  89.   optionally supply an alternative path name to get a listing  in  another
  90.   directory on the current drive or on another disk. CDIR's output is much
  91.   the same as that of DOS with  the  exception  of  the  "true  size"  and
  92.   attribute fields.
  93.  
  94.   An example.
  95.  
  96.  ...
  97.  
  98.  C:\>CDIR C:\DOS\*.TXT
  99.  
  100.  Reported Cluster Size for Drive C is 8,192 bytes
  101.  Directory of C:\DOS\*.TXT
  102.  
  103.  COUNTRY  TXT      15,920      16,384     5-31-94  6:22a .....A
  104.  DRVSPACE TXT      41,512      49,152     5-31-94  6:22a .....A
  105.  NETWORKS TXT      17,465      24,576     5-31-94  6:22a .....A
  106.  README   TXT      60,646      65,536     5-31-94  6:22a .....A
  107.       4 files       135,543 bytes used
  108.                     155,648 bytes used (actual)
  109.                      20,105 bytes wasted (14.83%)
  110.                 193,683,456 bytes free
  111.  ...
  112.  
  113.    The  heading  of  the output lists the cluster size of the partition the
  114.    directory is done on as reported by DOS and the wildcard  and  directory
  115.    the listing is being done on...
  116.  
  117. ---
  118.     Reported Cluster Size for Drive C is 8,192 bytes
  119.     Directory of \DOS\*.TXT
  120. ---
  121.  
  122.     The body of the output is much the same as the DOS "DIR" command...
  123.  
  124.   Filename  Extension  Size      True size    Date    Time  Attribute
  125. ---   |      |           |          |          |        |      |
  126.     README   TXT      60,646      65,536     5-31-94  6:22a .....A
  127. ---
  128.  
  129.   The filename, extension, size, date,  and time fields are the same as in
  130.   DIR's output.  The true size field is the actual amount  of  disk  space
  131.   that  file  resides  in.  The  attribute  field  contains  the the first
  132.   letter(s) of the listed files attributes:  Attribute, Read-only, Hidden,
  133.   System, Directory, or Volume-label.
  134.  
  135.   The  tail  of the output contains the total amount of files listed,  how
  136.   many bytes used are reported by DOS,  how many bytes are actually  being
  137.   used  (including cluster overhang),  the amount of disk space wasted due
  138.   to cluster overhang and the percentage of disk  space  wasted,  and  the
  139.   free amount of disk space on the drive the drive being queried.
  140.  
  141. ---
  142.      4 files       135,543 bytes used
  143.                    155,648 bytes used (actual)
  144.                     20,105 bytes wasted (14.83%)
  145.                193,683,456 bytes free
  146. ---
  147.  
  148.  Conclusion
  149.  ----------
  150.  
  151.   CDIR  is  a  utility I put together after purchasing a 1.1 gigabyte hard
  152.   disk and sizing it to two 550 meg  partitions.  I  soon  found  out  the
  153.   troubles of a 16k cluster size.  After reading an article in PC-Magazine
  154.   Vol. 14 No.  12 by Jeff Prosise, _Drive Size vs.  Storage Efficiency_, I
  155.   coded CDIR to get a more atomic view of the cluster overhang shortcoming
  156.   of the FAT file system than the listed utility,  "CHKDRIVE".  I  suggest
  157.   you  also check out CHKDRIVE,  the source code to this program is listed
  158.   in the above mentioned article.  The utility can also be downloaded  via
  159.   anonymous FTP at ftp.pcmag.ziff.com. CHKDRIVE will scan your entire disk
  160.   and compute the amount of space  wasted  on  the  entire  drive  due  to
  161.   cluster overhang and FAT entries. It will also show how much space could
  162.   be saved by re-sizing your partitions.  Another  interesting  utility  I
  163.   have found is called "WASTED."  WASTED is similar to CHKDRIVE in that it
  164.   computes the total wasted space on  a  drive,  however  WASTED  is  much
  165.   quicker.  WASTED  can be found at any SimTel site in the /msdos/diskutil
  166.   directory.
  167.  
  168.   CDIR  is  not  meant  to  be  a  DIR  replacement.  It  has  no  sorting
  169.   capabilities, nor any command line options like the DIR command. It does
  170.   a pretty raw directory,  listing all  files  specified  no  matter  what
  171.   attribute.  None-the-less it does what it was meant to do and is in it's
  172.   own right very useful.  There is no fee for use, so go ahead and use it.
  173.   Any   comments/flames   can   be   directed   via   internet   email  to
  174.   hraiser@cloud9.net or http:\\cloud9\net\~hraiser via the World Wide Web.
  175.