The disk surfaces are coated with a metalic oxide similar to that used
on cassette music tapes or video tapes; data is magnetically recorded
on these surfaces much the same way as on cassette or video tapes.
The actual recording and "play-back" is done through a "read-write"
head. Each surface has its own "read-write" head attached to a shared
"access comb". When the disk drive is operating, the disk is constantly
rotating; without moving the read-write heads, a circular path where
data can be recorded or played-back passes under each head; this
circular path is called a "track". The collection of tracks which
can be thus accessed without moving the access comb (one track from
each surface) is called a "cylinder". By moving the access comb in
or out (towards or away from the spindle), the Disk IO Controller can
store or recall data stored on different cylinders.
The Disk IO Controller copies blocks of data between main memory
and the disk surface. These blocks of data are (generally) only a
fraction of what could be stored on one track; each track is therefore
divided up into smaller storage areas called "sectors", where each
sector is large enough to hold one of these "blocks" of data.
In order to perform disk IO, the processor must supply the Disk
Controller with these three values (cylinder, surface, and sector numbers) plus a command (either "Read" or "Write") and the address of an area in memory to/from which the data block is to be copied.
In order to determine where files start on a disk, each disk contains
a table (at a fixed physical location on the disk). This table is
typically called a Directory or VTOC (Volume Table Of Contents).
The Directory (or VTOC) contains (among other values) a list of names
for all files stored on the disk and, for each file, its starting
location in physical units (or something that can be easily translated
into physical units: cylinder, surface, sector).
No two files on the same disk are allowed to have the same name;
otherwise, the Operating System would not be able to tell which
location should be used when a duplicated file name was supplied.
Therefore, attempting to Open an Output file with a name already on
the disk will cause a run-time error.
Conversely, attempting to Open an Input file with a name which is
not in the Directory will also cause a run-time error.
The size of the group of sectors assigned for a file is called
the "allocation unit" size for the disk. A disk drive can only assign
space for files as complete allocation units. If a sector contains
512 bytes and the allocation unit is 2 sectors, then a file with only
1 data byte will still use up 512x2 = 1024 bytes of disk space; in fact
any file with between 1 and 1024 (inclusive) data bytes will use the
same amount of space; a file with 1025 (to 2048) bytes will use 2
allocation units and so on.
The VTOC/directory contains a list of names of files stored on
the disk and for each its starting location in terms of physical disk
units (cylinder, surface, and sector numbers). Typically, a
VTOC/directory entry may contain other information such as the file
size, when the file was created, and file "attributes". File
"Attributes" may indicate such things as that the file is to be
"Read Only" i.e. it can not be erase or overwritten.
With Contiguous Space Allocation, if a programmer does not pre-request
enough space, a run-time error will occur when the file runs out of
space; if the programmer asks for too much space, a run-time error
may occur because a big enough contiguous block may not exist.
In addition, requesting more space than is needed wastes space on the
disk which could be used by other files; in some systems, it is possible
to ask for too much space and then give back whatever is not used
after the file has been created, but this will only work if the file
never "grows" or has data added to it and it does not get around
the problem of finding an empty block as large as the initial request.
Assuming that the IBM mainframe disk uses "sectors" for disk storage
(which it does not) and assuming our earlier example with a block of
9 contiguous unused sectors and another block of 8 unused sectors
and no other unused space: A request for
This is the system used for disk storage by MS-DOS. The "Chain"
table is called the disk's File Allocation Table (or FAT).
Each FAT entry is either a 12-bit or 16-bit value (depending upon
the size of the disk).
MS-DOS terminology uses the term "cluster" instead of "allocation unit".
File space clusters are normally 2 sectors of 512 bytes (although
there is some variation with different disk types).
The "Boot" occupied the first sector (side 0, track 0, sector 1).
This "Boot" record will be described in more detail later.
There were 2 copies of the FAT incase one got damaged in some way. Each
copy of the FAT occupied 2 sectors. Therefore the FAT copies used
surface 0, track 1, sectors 2 to 5.
The Boot sector could be viewed as an "allocation block" (or "cluster")
number 0; and the FAT's and Directory as "allocation block" number 1;
therefore file space begins with "allocation block" number 2.
The Directory was 7 sectors long (where each sector was 512 bytes
in length). Each directory entry is 32 bytes long (as described below)
and therefore there were 112 entries in a 5.25" DSDD directory
(7x512 = 32x112). This provided a limit to the maximum number of
files/directories that could be stored in the "root" directory.
The pointer value for cluster 0 is not a real pointer;
instead this value is used to specify the disk type using a
"Media Descriptor" value. The Media Descriptor for a 5.25" DSDD
is 0FDh (for a 5.25" HD or a 3.5" 720K it's 0F9h(!???), etc.)
The pointer value for cluster 1 is always FFFh.
SAMPLE FAT
(First few entries only) 5.25" DSDD Diskette
The disk subsystem is controlled by a "Disk IO Controller" board
(in a microcomputer system) or by a "Disk Channel IO Processor"
(on a mainframe computer system). The differences between these two are
not significant at this point and we will treat them as being identical.
Actually, use of the term "sector" implies that fixed sized
storage area is used for all blocks of data stored on the disk;
this is not true for some mainframe disk storage systems which
use variable sized "physical blocks".
Physical I/O Information Requirements
Requirements
Translation of Logical Data Storage Requirements
Notice that if FILE.B were now deleted there would be 17 sectors of
unused space, but not enough "contiguous" space to create a file of
more than 9 sectors using "Contiguous Space Allocation".

SPACE=(SECTOR,10,2)
would fail; | |
primary-----------+ +----------secondary
SPACE=(SECTOR,5,5)
could handle a file up to 10 sectors;
and
SPACE=(SECTOR,8,4)
could handle a file up to 16 sectors.

This disk used 2 surfaces (0 and 1), with 40 tracks (0 to 39) on each
surface and 9 sectors (1 to 9) of 512-bytes on each track.
Major Components of Boot Sector
offset contents
0000h
E9 xx xx or EB xx 90 (JMP to bootstrap code)
0003h
OEM name and version (8 bytes)
000Bh
bytes per sector (2 bytes)
000Dh
sectors per allocation unit (1 byte)
000Eh
reserved sectors, starting at 0 (2 bytes)
0010h
number of copies of FAT (1 byte)
0011h
number of root directory entries (2 bytes)
-- if <4087 12-bit FAT entries
-- otherwise 16-bit FAT entries
0013h
number of sectors in (logical) drive (2 bytes)
0015h
media descriptor byte
-- 0F0h: 3.5" DSHD (18 sectors/track)
-- 0F8h: fixed disk
-- 0F9h: 5.25" DSHD (15 sectors/track)
-- ---- 3.5" DSDD (9 sectors/track)
-- 0FCh: 5.25" SS (9 sectors/track)
-- 0FDh: 5.25" DS (9 sectors/track)
-- ---- 8" SSSD (DOS 2+)
-- 0FEh: 5.25" SS (8 sectors/track)
-- ---- 8" SSSD (DOS 1)
-- ---- 8" DSDD
-- 0FFh: 5.25" DS (8 sectors/track)
0016h
number of sectors per FAT (2 bytes)
0018h
sectors per track (2 bytes)
001Ah
number of heads (2 bytes)
001Ch
number of hidden sectors (4 bytes)
0020h
sectors in logical volume (DOS 4+; size>32MB) (4 bytes)
0024h
physical drive number (1 byte)
0025h
reserved/unused
0026h
29h ("extended boot signature")
0027h
volume ID (4 bytes)
002Bh
volume label (11 bytes)
0036h
unused/reserved (8 bytes)
003Eh
bootstrap code
MS-DOS Directory Structure
Each directory entry is a 32 (20h) byte record.

The Attribute Flag byte has the form:
For example, a file with an Attribute Flag byte of 23h
(00100011b) would be a "Read-Only", "Hidden" file which had been
created or changed since the last backup
(i.e. needed to be "Archived").

WARNING: The IBM PC stores multi-byte values backwards to
what you might expect; so for example a 4-byte size of 1A E2 04 00
must be read as 0004E21Ah.
Sample FAT Structure
The File Allocation Table for a 5.25" DSDD diskette is composed of
12-bit entries. The method used for fitting 12-bit values into
8-bit bytes is somewhat awkward for humans but works nicely for
the processor; two 12-bit cluster number pointers are fit into three
8-bit bytes. Pointers for clusters 0 and 1 are stored together in 3
bytes; pointers for clusters 2 and 3 are stored together in the next
3 bytes; and so on. Remember, the earlier "Warning" that values stored
in bytes are stored backwards to what people normally expect; so a 3
byte value of 2B 70 0C should be read as 0C702Bh. Splitting this into
two 12-bit values we get 0C7h and 02Bh; the 0C7h would go with the
higher numbered cluster and the 02Bh would go with the lower number
cluster of the pair.
Certain pointer values are not used as real pointers to clusters
but are reserved with special meanings:
FD F0 FF 03 40 00 05 60 00 07 80 00 09 A0 00 FF 0F 00
pointers for +------+ +------+ +------+ +------+ +------+ +------+
clusters: 0 & 1 2 & 3 4 & 5 6 & 7 8 & 9 10 & 11
The clusters 2&3 pointers split up to give:
i.e. cluster 2 is part of a file in which cluster 3 is the next
cluster and cluster 4 is the cluster after that.
Cluster 10 is the last cluster of the file; and cluster 11 is unused.