

                        DOS 4.0 Large File Support


        I was curious about the way DOS 4.0 allocates and locates
        data on large fixed-disks. During my research I found several
        interesting points.

        I had heard that the File Allocation Table (FAT) entries
        were now 32 bits long. This did not turn out to be the
        case. The entries are still 16 bits. The space allocated
        to the FAT did increase to 64K.

        One thing that changed is the Master Boot Record Partition
        Table. This is what ROM BIOS reads to find the
        "Bootable Partition" on the fixed-disk. The "System Indicator
        Byte" is now 06H which was "Reserved for future use" in earlier
        versions of DOS. The System Indicator Byte is used to determine
        the way the fixed disk is partitioned.
        After talking with one of the developers that
        helped write FDISK for DOS 4.0, I found out that the 06H
        indicates one of two things. If the primary partition is
        greater than 32MB or if the primary partition extends past
        the 32MB boundary 06H is used as the system indicator so
        earlier DOS versions will not try to read the disk.
        This is necessary because earlier versions of DOS are not
        capable of accessing disks larger that 32MB. Earlier versions
        of DOS use one word (16 bits) to access logical sectors.

        The next thing that changed is the Boot Record. Programs
        that use the Boot Record to calculate disk access must be
        able to read the DOS 4.0 Boot Record to work properly.
        In the earlier versions of DOS at offset 13H of
        the Boot Record was a word (2 bytes) that indicated how
        many sectors were on the fixed-disk. When DOS 4.0
        FDISK is executed, it calculates the total number of sectors.
        If that number is greater than FFFFH (64K), a zero is placed
        at offset 13H of the Boot Record. The total number of sectors
        is placed in a double-word (4 bytes) at offset 20H of the
        Boot Record. Programs that do not know this think that there
        is only one sector on the fixed disk (zero based). So, all of
        their calculation for finding the FAT and Root Directory are
        wrong. Newer versions of this type of program should know how
        to read the additional information in the Boot Record.

        One other important thing that changed is the cluster size.
        A cluster is the way DOS allocates space on the disk.
        ROM BIOS (Interrupt 13H) accesses space on the disk in sectors
        which consist of 512 bytes each. With DOS 4.0 we now have
        "variable cluster size". When a fixed disk is between
        32MB and 128MB the cluster size is four sectors per cluster.
        As the size of the fixed disk increases so does the
        cluster size up to a maximum of 128 sectors per cluster.


        Here is why:
                     1 sector = 512 bytes

                     FFFFH = 64K (65536) clusters possible in 16 bit FAT

                     4 sectors per cluster = 2048 bytes per cluster

                     2048 * 65536 = 134217728 bytes (128MB)

                                    or

                     128 sector per cluster = 65536 bytes per cluster

                     65536 * 65536 =  4294967296 (4096MB)

        As the size of the disk increases the cluster size must increase
        since the 16 bit FAT entries are constant.

        The important thing to remember is that if you have very large
        files on a very large disk you will realize the advantage of
        having one large "C" drive. But, if you have several small files
        you should partition your very large drive into several 32MB
        drives.
        Here is why:

                        Suppose you had a 130MB fixed-disk.
                        The cluster size would be eight
                        sectors per cluster.
                        8 * 512 = 4096 bytes (4K)

                        The smallest unit DOS can allocate
                        on the disk is a cluster.

                        A file of 4000000 bytes would use
                        most of the space allotted.

                        A file of 1096 bytes would waste
                        3000 bytes of disk space.
                        The same file on a 32MB disk would
                        waste only 952 bytes.





        Now let's discuss these 32 bit entries we've heard about
        for accessing the fixed-disk.

        These entries come from the DOS 4.0 Absolute Disk Read
        and Disk Write Services (Interrupt 25H and 26H).

        DOS views the disk as logical sectors from 0 to a
        maximum of FFFFFFFFH (4294967296). By the way, that means
        DOS 4.0 has a maximum fixed-disk size of
        (512 bytes per sector * 4294967296) 2199023255552 bytes
        (2GB).
        WOW!

        When a program requests a sector it gives DOS 4.0 a
        logical sector number 32 bits long. DOS 4.0 converts
        the number to give the program the sector it requested.

        It is curious to note that DOS 4.0 has the capacity
        to access much larger disks than the current
        implementation of 128 sector per cluster maximum.

        I hope this clears up some of the questions about
        the way DOS 4.0 accesses the fixed disk.                               


                                              Wyn Easton
                                              IBM Marketing Support Rep.

                                                  