Daftar Blog Saya

Kamis, 15 Maret 2012

FAT16

Specifications

FAT16 File System


FAT16 was introduced by MS-DOS in 1981 (very long time now). Initially, the system is designed to manage files on the floppy drive and changed several times so it is used tomanage files on my hard drive. The advantage is the FAT16 file system is compatiblealmost any Operating System be it Windows 95/98/Me, OS / 2, Linux and even Unix. But behind the biggest problem of FAT16 is having the capacity of a fixed number of clustersin a partition, so the larger the hard drive the size of the cluster will be greater, meaning that no matter how small the file still will take 32KB of disk. Another bad thing is FAT16does not support compression, encryption and access control in a partition.

Basic Structure

The FAT16 file system structure contains the following regions:

The first sector (boot sector) contain information which is used to calculate the sizes and locations of the other regions. The boot sector also contain code to boot the operating system installed on the volume. The data region is split up into logical blocks called clusters. Each of these clusters has an accompanying entry in the FAT region. The cluster specific entry can either contain a value of the next cluster which contain data from the file, or a so called End-of-file value which means that there are no more clusters which contain data from the file. The root directory and its sub-directories contain filename, dates, attribute flags and starting cluster information about the filesystem objects.

Boot Sector

The first sector in the reserved region is the boot sector. Though this sector is typical 512 bytes in can be longer depending on the media. The boot sector typical start with a 3 byte jump instruction to where the bootstrap code is stored, followed by an 8 byte long string set by the creating operating system. This is followed by the BIOS Parameter Block, and then by an Extended BIOS Parameter Block. Finally the boot sector contain boot code and a signature.


BIOS Parameter Block

The BIOS Parameter Block contains basic information about the overall structure of the FAT file system. That is information such as sector and cluster size, location information of FAT copies, the root directory size etc..

Bytes Per Sector

This value is the number of bytes in each physical sector. The allowed values are: 512, 1024, 2048 or 4096 bytes. A lot of code outthere are assuming 512 bytes per sectors, so any other values can give compatibility problems.

Sectors Per Cluster

This is the number of sectors per cluster. The allowed values are: 1, 2, 4, 8, 16, 32 or 128. But de-facto is that most combinations of 'BytesPerCluster' * 'SectorsPerCluster' which gives a total value over 32 Kb per cluster, are not supported on many system.

Reserved Sectors

Since the reserved region always contain the boot sector a zero value in this field is not allowed. The usual setting of this value is 1. The value is used to calculate the location for the first sector containing the FAT.

Number of FAT copies

This is the number of FAT copies in the file system. The recommended value is 2 (and then have two FAT copies), but other values are validm though they may not be supported on some system. The usage of two copies are to prevent data loss if one or part of one FAT copy is corrupted.

Root Entries Count

This value contain the number of entries in the root directory. Its recommended that the number of entries is an even multiple of the BytesPerSector values. The recommended value for FAT16 volumes is 512 entries (compatibility reasons).

Small Number of Sectors

This field states the total number of sectors in the volume. That includes the number of sectors occupied by the four regions which the FAT16 file system consist of. For FAT16 volumes that use less than 65536 sectors this field is used. The File System Id in the MBR is then 04h. For FAT16 volumes that use more the 65535 sectors thelarge number of sectors field is used and this one should be set to 0h.

Media Descriptor

These are the possible media descriptors values in the FAT boot sector. 


Sectors Per FAT

This is the number of sectors occupied by one copy of the FAT.

Sectors Per Track

This value is used when the volume is on a media which have a geometry, that is when the LBA number is broken down into a Cylinder-Head-Sector address. This field represents the multiple of the max. Head and Sector value used when the volume was formatted. The field itself is used to check if the LBA to CHS translation has changed, since the formatting. And for calculating the correct Cylinder, Head and Sector values for the translation algorithm.

Number of Heads

This value is used when the volume is on a media which have a geometry, that is when the LBA number is broken down into a Cylinder-Head-Sector address. This field represents the Head value used when the volume was formatted. The field itself is used to check if the LBA to CHS translation has changed, since the formatting. And for calculating the correct Cylinder, Head and Sector values for the translation algorithm.

Hidden Sectors

When the volume is on a media that is partitioned, this value contains the number of sectors preceeding the first sector of the volume.

Large Number of Sectors

This field states the total number of sectors in the volume. That includes the number of sectors occupied by the four regions which the FAT16 file system consist of. For FAT16 volumes that use more than 65535 sectors this field is used. The File System Id in the MBR is then 06h. For FAT16 volumes that use less than 65536 sectors the  small number of sectorsi eld is used and this one should be set to 0h.

Extended BIOS Parameter Block

The Extended BIOS Parameter Block contains information that is only used in the FAT16 file system.

Drive Number

This is the int 13h drive number of the drive. The value 00h is used for the first floppy drive and the value 80h is used for the first harddrive. MS-DOS's bootstrap uses this value to find the correct drive.

Reserved

Reserved byte. It was original used to store the cylinder on which the boot sector is located. But Windows NT uses this byte to store two flags. The lowest bit would indicates that a check disk should be run at boot time, and the second lowest flag indicates that a surface scan should be run.

Extended Boot Signature

If this byte contain a value of 29h it indicates that the following three fields are available.

Volume Serial Number

This value is a 32 bit random number, which, combined with the volume label, makes is possible to track removable media and check if the correct one is inserted.

Volume Label

This 11 byte long string should match the volume label entry in the root directory. If no such entry is available this field should contain the string 'NO NAME ' (11 bytes long string). When updating the volume label, both, this field and the entry in the root directory should be updated.

File System Type

This 8 byte long string should be used for informational display only. Thats because its sometime incorrectly set. The field should contain the string 'FAT16 ' (8 bytes long string).

Bootstrap Code

The bootstrap code is different between operating system and versions which are intended to be loaded of this FAT16 volume. The responsability of the bootstrap code is to continue the boot sequence. If ex. MS-DOS is installed the bootstrap code will locate the file IO.SYS in the file system, load part of it into memory and then jump to a specific entrypoint in IO.SYS. What the bootstrap code does is vary between operating system.

Boot Sector Signature

The word at offset 1FEh should contain the signature AA55h. This will indicate to the BIOS that the sector is executable. The signature is also used by other applications when validating that the correct sector has been loaded. No matter what the Bytes Per Sector value is this signature should always be at offset 1FEh.

Tidak ada komentar:

Posting Komentar