ADVERTISEMENT
ADVERTISEMENT

File Allocation Table (FAT) in Operating System

Operating System | File Allocation Table (FAT): In this tutorial, we are going to learn about the File Allocation Table (FAT), Versions of FAT, How FAT Works, The FAT family, etc.
Submitted by IncludeHelp, on November 23, 2020

The File Allocation Table (FAT) file system is a basic file system that was initially intended for small discs and simple folder structures. A file system developed by Microsoft for MS-DOS, the File Allocation Table (FAT) was the primary file system for user versions of Microsoft Windows up to and including Windows Me.

The FAT file system is relatively uncomplicated, and nearly all current personal computer operating systems support it. This ubiquity makes it an ideal format for floppy discs and solid-state memory cards, and a convenient way to share information (a dual boot environment) between disparate operating systems installed on the same machine.

The most popular implementations have a significant downside in that directory fragments appear to be dispersed over the entire media as files are removed and new files are written to the media making reading and writing a slow operation. One solution to this is defragmentation, but it is always a lengthy procedure in itself and must be carried out periodically to keep the FAT file system clean.

The FAT file system is named after its organization process, the table of file allocation, which resides at the beginning of the volume. Two copies of the table are held to protect the volume, in case one gets harmed. Furthermore, it is important to store the file allocation tables and the root folder in a fixed location so that the files required to start the system can be correctly located. Clusters are assigned to a volume formatted by the FAT file system. The size of the default cluster is determined by the volume size. The cluster number must fit into 16 bits for the FAT file system and be a power of 2.

A File Allocation Table (FAT) is a hard drive file system that originally used 12 or 16 bits for each cluster entry into the file allocation table. The operating system (OS) uses it for handling files on hard drives and other computer systems. It is also often used on digital cameras, handheld devices, and flash memory. It is used to store information about files and prolong the existence of a hard drive.

A process known as seeking is required by most hard drives; this is the actual physical searching and positioning of the drive's read/write head. The FAT file system was designed to decrease the number of searches and thereby minimize the wear and tear of the hard disc.

The FAT was designed to support subdirectories and hard drives. The previous FAT12 had 12-bit cluster addresses with up to 4078 clusters; up to 4084 UNIX clusters were enabled. The more powerful FAT16 increased to 16-bit cluster address, enabling up to 65,517 clusters per volume, 512-byte 32-MB space clusters, and had a larger file system; it was 2,048 bytes with the four sectors.

Versions of FAT

There are 3 versions of FAT: FAT-12, FAT-16, and FAT-32. These numbers apply to the number of available cluster-defining bits.

FAT-12 is used for the floppy disc we are looking at, and so is limited to 212 or roughly 4096 clusters. (Since 000h and 001h are not used and FF0h to FFFh are reserved or used for other purposes, the number is less than this, leaving 002h to FEFh (2 to 4079) as the range of potential clusters. )

There are 4 sectors in a cluster (the minimum size that can be allocated.)
A sector is 2048 bytes, which is 512 bytes a cluster.

Fat-12 therefore has a maximum of 4078 clusters * 2048 bytes/cluster = 8 Megabytes = 8

There are 80 tracks on a standard 1.4 Mbyte PC floppy disc, containing 18 sectors, which may hold 720 Kbytes (80 x 18 x 512 bytes) of data on each side.

The TRUTH of our disc structure is here. Since support for 1.4 Megabytes is only required, this disc appears to have a cluster = 1 Area.

How FAT Works?

The way FAT functions are that it maintains a list of all the files at the beginning of the drive, and it points to the clusters that hold the files to point to the files. The key cluster rule is that there should be no more than 1 file per cluster; otherwise, pointing to that cluster will cause issues, as it would point to two files at once and perform read/write operations, causing Windows to crash. The cluster size will vary, depending on the size and FAT version of the partition. Also, bear in mind that the FAT, which is the record of each file and where it can be found, is reserved for a portion of the partition. Depending on the size of the partition and the clusters, this will vary in size.

The FAT family

The number of bits used in the FAT for cluster addresses are FAT12, FAT16, FAT32.

1) FAT12

For cluster addresses, FAT12 used 12-bit entries; some values were reserved to mark the end of a cluster chain, to mark unusable disc areas, or for other purposes, so the maximum number of clusters was limited to 4078. Two 12-bit FAT entries used three consecutive 8-bit bytes on the disc to save disc space, which involved manipulation to unpack the 12-bit values.

2) FAT16

The original FAT16 form (with less than 65536 sectors) had a 0x04 partition type. To deal with discs larger than this to mean 65536 or more sectors, type 0x06 was introduced. In addition to this the disc driver has also been extended to cope with over 65535 sectors.

3) FAT32

Microsoft developed a new version of the file system, FAT32, to address the volume size constraint of FAT16 while at the same time allowing DOS real-mode code to manage the format, which allowed an expanded number of possible clusters but was able to reuse much of the existing code, so that the traditional memory footprint was increased by less than 5 KiB under DOS. 32-bit numbers are represented by cluster values, of which 28 bits are used to keep the cluster number.

FAT32 File System

FAT32 is a File Allocation Table (FAT) file system derivative that supports drives with more than 2GB of capacity. Since more than 65,526 clusters can contain FAT32 drives, smaller clusters are used than on large FAT16 drives. This approach results in a more efficient allocation of space on the drive of the FAT32.

File Allocation Table (FAT) in OS (1)

4GB minus 2 bytes is the largest file available for a FAT32 drive.

Inside the file allocation table, the FAT32 file system contains four bytes per cluster. Notice that in the FAT32 file allocation table, the high 4 bits of 32-bit values are reserved and do not form part of the cluster number.

Creating a File System for FAT

There are four separate parts of a FAT file system, each as a structure in the FAT partition. The four pieces are:

Boot Sector: This is also referred to as the reserved sector; the first portion of the disc is placed. It includes: the boot loader code required by the OS to start a PC device, the partition table known as the Master Boot Record (MRB) that describes how the drive is organised, and the BIOS Parameter Block (BPB) that describes the data storage volume physical outline.

FAT Region: This region usually contains two copies of the redundancy check file allocation table and determines how the clusters are allocated.

Data region: This is where the data from the directory and current files are stored. The bulk of the partition is used up.

Root Directory Region: This region is a directory table which contains directory and file information. It is used for but not with other FAT file systems but with FAT16 and FAT12. It has a fixed maximum size which when formed, is configured. In the data field, FAT32 typically stores the root directory so that it can be extended if appropriate.

File Allocation Table (FAT) in OS (2)

File system data structures are generated by high-level formatting

  • Boot Sector
  • Allocation of clusters
    • Table for File Allocation (FAT)
    • In the Master File Table (MFT) for NTFS, o $Bitmap
  • Exact information depends on the operating system.
  • Root Directory

Advantages

  1. Use the entire block of the disc for data.
  2. Not all the successive blocks lost are triggered by a bad disc block.
  3. While it is not too fast, random access is given.
  4. In any file operation, only FAT must be traversed.

Disadvantages

  1. A FAT entry is required for each Disk block.
  2. Depending on the number of FAT entries, the FAT size can be very high.
  3. It is possible to reduce the number of FAT entries by increasing the block size, but internal fragmentation would also increase.
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.