This diskette tutorial provides technical information concerning diskettes. The technical information will help explain some of the inner workings of our diskette duplication software.
The tutorial is broken up into the following areas:
Common Diskette Formats
Diskette System Area Layouts
Diskette Track Layout
Common Diskette Formats
Diskettes come in different physical sizes (5 1/4" or 3 1/2") and different capacities. Primarily three things affect the capacity of a diskette. They are:
1. The diskette drive itself. What are its capabilities? Does it have one head for one side of the diskette only or does it have two heads and can access both sides of the diskette?
2. The software used helps to determine capacities. Can the software format the diskette in different capacities?
3. The media itself can be a limiting factor. For example, the metallic particle size and properties means that some diskettes can be formatted and hold data long term at higher densities. An example of this is the 1.2M media that is the same physical size as a 360K media but can be formatted to a much higher capacity.
The most common diskette formats under MS-DOS include 360K, 720K, 1.2M, and 1.44M. Microsofts 1.68M (DMF) diskettes are gaining in popularity and the 2.88M diskettes are available, but have not gained widespread popularity. The 360K and 720K diskettes are:
Size Tracks Sectors/Track Sides Capacity 360K 5.25 40 9 2 368,640 720K 3.50 80 9 2 737,280 1.2M 5.25 80 15 2 1,228,800 1.44M 3.50 80 18 2 1,474,560 1.68M 3.50(DMF) 80 21 2 1,720,320 2,88M 3.50 80 36 2 2,949,120
Obsolete diskette formats include:
Size Tracks Sectors/Track Sides Capacity 160K 5.25 40 8 1 163,840 180K 5.25 40 9 1 184,320 320K 5.25 40 8 2 327,680
1. Rotational speed of a 5 1/4" drive is 300 rpm except for the 1.2M in the 1.2M format. When the 5 1/4" 1.2M drive switches from the 360K mode to the 1.2M mode, it switches to a different head biasing current and switches from 300 rpm to 360 rpm.
2. The 160K format was used primarily in the early 1980s when the PC first came out. The floppy drives were singled sided so the capacity was very small. DOS initially only formatted at 8 sectors per track.
3. About the time double sided floppy drives became affordable, DOS was upgraded to also format at 9 sectors per track. This lead to the 180K, 320K, and 360K formats. You will probably not run across a 5 1/4" floppy formatted using less than 360K format today.
4. The 1.68M format is commonly called DMF. Software can be installed from this format but the DOS operating system doesn't support it well enough for it to be used for normal operations. DMF requires special applications for it to be copied.
Diskette System Area Layouts
A Diskette layout is divided into the system storage area and the data storage area. The system storage area consists of the boot sector, the file allocation table, and the file directory. There will only be one boot sector per diskette, regardless of the size, but the number of sectors required for the remainder of the system area varies, depending on the diskette capacity. The following table depicts the number of sectors required for the system area for the four most common diskette capacities:
B = Boot Sector F = File Allocation Table D = Directory X = Data
360K 720K 1.2M 1.44M
Side Sect Data Side Sect Data Side Sect Data Side Sect Data
1 B 1 B 1 B 1 B 2 F 2 F 2 F 2 F 3 F 3 F 3 F 3 F 4 F 4 F 4 F 4 F S1 5 F S1 5 F 5 F 5 F 6 D 6 F 6 F 6 F 7 D 7 F S1 7 F 7 F 8 D 8 D 8 F 8 F 9 D 9 D 9 F S1 9 F =========== ========== 10 F 10 F 1 D 1 D 11 F 11 F 2 D 2 D 12 F 12 F 3 D 3 D 13 F 13 F 4 X 4 D 14 F 14 F S2 5 X S2 5 D 15 F 15 F 6 X 6 X =========== 16 F 7 X 7 X 1 D 17 F 8 X 8 X 2 D 18 F 9 X 9 X 3 D =========== 4 D 1 F 5 D 2 D 6 D 3 D S2 7 D 4 D 8 D 5 D 9 D 6 D 10 D 7 D 11 D 8 D 12 D S2 9 D 13 D 10 D 14 D 11 D 15 X 12 D =========== 13 D 14 D 15 D 16 X 17 X 18 X ===========
Diskette Track Layout
Layout numbering begins at Track 0, Side 0, Sector 1. In the table below, the first user accessible file is stored immediately following the system area, which is Track 0, Side 1, Sector 4. The file continues through the last sector on Track 0, Side 1, then goes to Track 1, Side 0, Sector 1.
This table depicts the track layout of a double-sided double-density 360K diskette containing an initial file requiring 18 sectors (a filesize between 8705 and 9216 bytes) and additional files requiring 440 sectors. The remaining sectors on the diskette are empty.
Side 0 Side 1
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
00 B F F F F D D D D D D D I I I I I I 01 I I I I I I I I I I I I X X X X X X 02 X X X X X X X X X X X X X X X X X X 03 X X X X X X X X X X X X X X X X X X 04 X X X X X X X X X X X X X X X X X X 05 X X X X X X X X X X X X X X X X X X 06 X X X X X X X X X X X X X X X X X X 07 X X X X X X X X X X X X X X X X X X 08 X X X X X X X X X X X X X X X X X X 09 X X X X X X X X X X X X X X X X X X 10 X X X X X X X X X X X X X X X X X X 11 X X X X X X X X X X X X X X X X X X
12 X X X X X X X X X X X X X X X X X X 13 X X X X X X X X X X X X X X X X X X 14 X X X X X X X X X X X X X X X X X X 15 X X X X X X X X X X X X X X X X X X 16 X X X X X X X X X X X X X X X X X X 17 X X X X X X X X X X X X X X X X X X 18 X X X X X X X X X X X X X X X X X X 19 X X X X X X X X X X X X X X X X X X 20 X X X X X X X X X X X X X X X X X X 21 X X X X X X X X X X X X X X X X X X 22 X X X X X X X X X X X X X X X X X X 23 X X X X X X X X X X X X X X X X X X
24 X X X X X X X X X X X X X X X X X X 25 X X X X X X X X X X X X X X X X X X 26 E E E E E E E E E E E E E E E E E E 27 E E E E E E E E E E E E E E E E E E 28 E E E E E E E E E E E E E E E E E E 29 E E E E E E E E E E E E E E E E E E 30 E E E E E E E E E E E E E E E E E E 31 E E E E E E E E E E E E E E E E E E 32 E E E E E E E E E E E E E E E E E E 33 E E E E E E E E E E E E E E E E E E 34 E E E E E E E E E E E E E E E E E E 35 E E E E E E E E E E E E E E E E E E
36 E E E E E E E E E E E E E E E E E E 37 E E E E E E E E E E E E E E E E E E 38 E E E E E E E E E E E E E E E E E E 39 E E E E E E E E E E E E E E E E E E
B = Boot Sector F = File Allocation Table D = Directory I = Initial File E = Empty Sectors X = Sectors containing data
The very first sector on a disk formatted under MS-DOS is always defined as the boot record. It contains a short program that is automatically loaded into memory when the disk is used to load the MS-DOS operating system after system power-up or reset. This program then instructs the computer where to look on the disk for the files that contain the operating system. Once the files are found, the boot program loads the files into memory and transfers control to the operating system. If the diskette does not contain the operating system, this area contains text that is displayed on the screen informing you that the diskette is not bootable. The boot sector is always defined as the first sector on a diskette regardless of whether the diskette is bootable or a data-only diskette.
The first 3 bytes of the boot record always contain a jump instruction. At boot-up, the jump instruction tells the system to jump past the first part of the record to the boot code. This first part of the boot record contains information about the disk format. Programs can obtain nearly all the information needed to access the disk by examining this information. The disk information contained in the boot record is depicted below:
Offset Size (Bytes) Contents Decimal Hex 0 00 3 Near JMP to boot code 3 03 8 OEM name and version 11 0B 2 Bytes per sector 13 0D 1 Sectors per cluster 14 0E 2 Number of reserved sectors 16 10 1 Number of FAT tables 17 11 2 Number of directory entries 19 13 2 Number of logical sectors 21 15 1 Media descriptor byte 22 16 2 Number of FAT sectors 24 18 2 Sectors per track 26 1A 2 Number of heads 28 1C 2 Number of hidden sectors 30 1E 482 Boot code
The OEM and version part of the boot record usually contains the implementation and version number of the operating system used to create the boot record. For example, if MS-DOS version 6.2 was used to format the disk, this field will contain the information MSDOS6.2. The rest of the items in the boot record down to the boot code are a superset of the BIOS Parameter Block as it existed when the disk was formatted. The last three items (sectors per track, number of heads, and number of hidden sectors) are calculated and inserted in the boot record when the disk is formatted.
How does DOS know what type of diskette it is accessing in your drive? It looks at two things. First, what is your physical drive like? Is it a 5 1/4" or a 3 1/2" drive? The second thing it looks at is the diskette in the drive to read a media identification byte stored in the File Allocation Table (FAT). The current IDs are:
Media Capacity Media ID 160K 0FEH 180K 0FCH 320K 0FFH 360K 0FDH 720K 0F9H 1.2M 0F9H 1.44M 0F0H 1.68M 0F0H 2.88M 0F0H Special: 0F8H is for a fixed disk 0F0H is for other types
The Media IDs listed above help identify the diskette to DOS. Over the years, DOS has been extended to add new identifier bytes as technology improves. Each new jump in disk technology results in higher capacity and the need to identify that new type of diskette to DOS.
The File Allocation Table is used by the operating system to determine the locations on the disk of each part of every file. The FAT is capable of files and parts of files in a random manner so files do not have to be stored in a contiguous manner. A system that requires files to be stored contiguously can keep track of files more easily and can access files more quickly; however, contiguous file storage is less efficient when a file stored between several files is deleted and replaced by a larger file. If the space is not large enough to accommodate the new file, sufficient disk space must be allocated at the end of the file storage. If the disk doesnt contain sufficient space for the file at the end, the disk is considered full. This can cause a significant waste of storage space, especially on the smaller capacity diskettes. Random storage enables a file to be stored in multiple areas on the disk. The FAT is the mechanism for keeping track of a files multiple locations.
Files are referenced by the FAT in terms of clusters. A file always occupies at least one cluster, even if it is only a one byte file. If the file is large enough, it will occupy multiple clusters. A cluster is really an allocation unit. Diskettes use one or two sectors per cluster for storage. The data storage area (the data storage area follows the system area) of a disk is divided into clusters and the entire range of clusters is mapped out by the File Allocation Table.
Cluster numbers begin with cluster 2 to allow quick indexing into the FAT. Cluster entries 0 and 1 are reserved by the operating system. Each cluster on the disk has a corresponding FAT entry. The FAT entry that corresponds to the first cluster of a file contains the number of the next cluster occupied by that file. By looking in the FAT entry corresponding to the next cluster, we find that either the end of the file has been reached or that the entry contains the number of yet another cluster occupied by the file. Thus the FAT entries effectively contain pointers to the clusters occupied by the file and to subsequent FAT entries that corresponds to additional clusters occupied by the file. Because the total number of entries in the FAT sectors exceeds the total number of clusters on the disk, the entire disk can easily be mapped even when the disk capacity has been reached.
The value in FAT entry 0 always indicates the format of the disk. Entry 1 is always set to FFF to act as a filler between entry 0 and entry 2. FAT entries denote one of the following types of information:· The next cluster number of a file · The end-of-file marker (FFF) · An unused cluster (000) · A cluster that marked as reserved or bad (FF7)
FAT entries are really 1.5 bytes each. If we want to look at cluster number two, we also need to look at entry number 3 and retrieve the least significant part of that entry. To decode the information contained in the FAT, use the following formula:
1. Multiply the FAT entry or cluster number by 1.5 bytes. (Multiply by 3, then divide by 2.)
2. Use the result as an offset into the FAT, pointing to the entry that maps the cluster just used. That entry contains the number of the next cluster by the file
3. Load the word (a 2-byte number) located at that offset into a register
4. There are now four hexadecimal digits in the register. Because we need only three digits for a three-digit FAT entry, determine whether the FAT entry number is even or odd.
5. If the entry number is even, keep the low-order three digits in the register by ANDing it with 0FFFh. If the entry number is odd, keep the high-order three digits by shifting the register right four bits with the SHR instruction.
6. If the resulting three digits represent a number from FF8 through FFF, you have reached the end of the file. Otherwise, the three digits represent the number of the next cluster occupied by the file.
Although the physical layout of a diskette begins with Track 0, Side 0, Sector 1, the first logical sector equates to sector 0. All subsequent logical sectors are offsets of 0. Because each FAT entry, according to the results of the preceding formula, always produces a cluster number, the following formula converts a cluster number to a logical sector number.
1. Subtract 2 from the cluster number
2. Multiply the result by the number of sectors used in a cluster, as follows:
a) For 1.2M (5.25) diskettes, multiply by 1
b) For 360K (5.25) diskettes, multiply by 2
c) For 1.44M (3.5) diskettes, multiply by 1
d) For 720K (3.5) diskettes, multiply by 2
3. Add the result to the logical sector number of the beginning of the data storage area
The directory sectors store the directory information for all the files in the root directory of the disk. Directory information for files contained in a subdirectory is stored in the subdirectory file, the entry for which is stored in its parent directory (root or other subdirectory). When you issue the DIR command, the information is obtained from the directory sectors if reading from the root directory or is obtained from the subdirectory file describing the current subdirectory. Each directory entry is 32 bytes long.
Diskette directory composition varies based on the diskette type. They start on different sectors and support a different number of directory entries. A summary of diskette director information follows:
Disk Type Directory Size Root Directory Logical Starting (sectors) Entries Sector (Data) 160K 4 64 9 180K 4 64 9 320K 7 112 12 360K 7 112 12 720K 7 112 14 1.2M 14 224 15 1.44M 14 112 33 1.68M 1 16 8 2.88M 15 240 34
This restriction does not exist for subdirectories. Because the directory entries that correspond to files stored in subdirectories are themselves stored in the subdirectory description file, the number of subdirectory entries are limited only by the amount of disk space available; the subdirectory description file can continue to grow as required.
The information contained in a directory entry is divided into six components. The following depicts the components of a directory entry, the length of each component, and how each is defined:
Offset Length (Bytes) Field 00 11 Name/Extension 11 1 Attribute 12 10 Reserved 22 2 Time 24 2 Date 26 2 Starting cluster 28 4 File Size
The file name and type (extension) consist of 11 bytes, representing the name of the file to which the directory entry corresponds. Each byte contains an ASCII character. Subdirectory names are also treated as files and have their own entries in the directory sectors. A subdirectory name, however, contains information in its directory entry that is slightly different from normal files, namely the file attribute. There are two files in every directory, namely the . and .. files. The . directory entry is a pointer to the current directory and the .. directory entry is a pointer to the parent directory. The following describes the contents of each field of the directory entries for the . and .. directories:
The . (dot) Directory Field Contents Name/Extension 1st Byte = 2E hex (an ASCII period); the rest = binary 00 Attribute Directory flag only (10 hex) Time Time created Date Date created Starting Cluster Cluster number of current directory Size Blank (size is in parents directory entry for this directory)
The .. (dot dot) Directory Field Contents Name/Extension 1st Byte = 2E hex (an ASCII period); the rest = binary 00 Attribute Directory flag only (10 hex) Time Time created Date Date created Starting Cluster Cluster number of parent directory, if parent is NOT the root Size Blank
The attribute byte contains information about the files storage attributes. File attributes indicate how the operating system will treat the file. The following shows the definitions of each attribute and the respective hexadecimal values that can be stored in the attribute byte. Each bit in the byte defines a specific attribute and is set to 1 when the attribute is assigned to the file.
Bit Hex Value Binary Value Definition 7 80 10000000 Not defined 6 40 01000000 Not defined 5 20 00100000 Archive file 4 10 00010000 Subdirectory entry 3 08 00001000 Volume label 2 04 00000100 System file 1 02 00000010 Hidden file (does not show when using DIR) 0 01 00000001 Read-only file (file cannot be deleted)
A starting cluster is a 2-byte, 16-digit binary number that represents the first section of the disk occupied by the file. A cluster is the term applied to the smallest storage allocation unit. Although the disk layout is in terms of sectors and tracks, the operating system stores files in terms of clusters. The starting cluster number is the initial pointer to the files first data sector. Having read this initial pointer in the directory entry, the operating system proceeds to read the remaining pointers to the files data sectors from the File Allocation Table.
A files size is represented by a 4-byte unsigned integer, which allows the file to grow up to 4,294,967,295 bytes - or the capacity of the disk, whichever is smaller. The operating system uses the file size in a files directory entry to determine the exact size of the file. Because a files disk space is allocated in clusters of 512 or 1024 bytes (1 or 2 sectors per cluster), the actual space actually used by the file is usually greater than the value in the directory entry. On disk, the space between the end of the file and the end of the cluster in the file is wasted.
1. Windows 95 uses multiple directory entries to store long filenames on floppy diskettes. The short filename is stored first. Then the long file name is stored in the following directory entries.
2. There is a general tendency for the larger capacity diskettes to hold more directory entries. This is especially visible when looking at the limited capacity 160K and 180K diskettes that were common with DOS v1.0 back in the 1981/1982 timeframe.