什么是FAT?

File allocation table is a table for describing the allocation status of the clusters (the basic units of logical storage on a hard disk) in the file system and the link relationship between the file contents. You can simply say it is a table in which the file is located.

It is a vital part of the FAT file system, and it is also very important for the use of the hard disk. If the file allocation table is lost, the data on the hard disk cannot be located and cannot be used.

When a new file is written to the hard disk, the file is stored in one or more clusters that are not necessarily adjacent to each other; they may be fairly widely distributed across the disk. The operating system creates a FAT entry for the new file, recording the location of each
cluster and its order. When you read a file, the operating system reassembles the file from these clusters and places it as the entire file where you want to read it.

文件分配表是描述文件系统中簇(硬盘逻辑存储的基本单位)的分配状态和文件内容之间的链接关系的表。您可以简单地说它是描述文件所在位置的表。

它是FAT文件系统的重要组成部分,对硬盘的使用也非常重要。如果文件分配表丢失,则硬盘上的数据无法定位,无法使用

当有新文件写入硬盘时,文件存储在一个或多个不一定相邻的簇中;它们可能相当广泛地分布在整个磁盘上。操作系统为新文件创建一个 FAT 条目,记录每个簇的位置及其顺序。当您读取文件时,操作系统会从这些簇中重新组合文件,并将其作为整个文件放置在您要读取的位置。

那么你就可以看出FAT文件系统是以其组织方式命名的——文件分配表。它是微软在 1977 年发明的用于磁盘管理的文件系统,在 NTFS 发布之前,它被用作 Windows 中的默认文件系统。

FAT系统说明

The FAT file system roughly divides the space of the logical disk into four parts, which are boot sector, file allocation table area, root directory area and data area.

在这里插入图片描述
引导扇区:也称为保留扇区,位于第一部分。 它包括:操作系统启动计算机所需的引导加载程序代码、描述驱动器组织方式的主引导记录 (mbr) 的分区表以及描述驱动器物理轮廓的 BIOS 参数块 (BPB)。 数据存储量。

FAT 区:这部分通常包含文件分配表的两份副本,用于冗余检查和指定如何分配簇。

根目录区:该区是一个包含目录和文件信息的目录表。 它仅适用于 FAT12 和 FAT16。 它具有固定的最大大小并在创建时进行配置。 FAT32 通常将根目录存储在数据区中,因此可以根据需要进行扩展。

数据区:这是存储目录数据和现有文件的地方。 它占据了磁盘上的大部分分区。

文件分配表的类型

The general types of file system (FAT12, FAT16 or FAT32) are
determined by the width of the cluster entries in the FAT.

我们提到文件分配表是一个集群列表,用于显示存储数据的位置。 文件系统的一般类型(FAT12、FAT16 或 FAT32)由 FAT 中簇条目的宽度决定。

FAT12 (12-bit File Allocation Table)

The first version of the FAT file system is FAT12 which is the oldest type of FAT that uses a 12 bit file allocation table entry. It was introduced in 1980. FAT12 supports up to 16 MB of partition size using a 4 KB cluster, or 32 MB using an 8 KB cluster, the max file is limited by the partition size. It is almost never used at all since it is too small.

FAT 文件系统的第一个版本是 FAT12,它是最古老的 FAT 类型,它使用 12 位文件分配表条目。 它是在 1980 年推出的。FAT12 使用 4 KB 集群支持最多 16 MB 的分区大小,或使用 8 KB 集群支持 32 MB,最大文件受分区大小限制。 它几乎从未使用过,因为它太小了。

FAT16 (16-bit File Allocation Table)

The second implementation of FAT was FAT16, which introduced the 16-bit file allocation table entry for the first time in 1984.

Depending on the operating system and cluster size used, the FAT16 formatted drive can have a maximum drive size of 2 GB to 16 GB, the latter one which is only available in Windows NT 4 with a 256 KB cluster.

The file size on the FAT16 drive is up to 4 GB when Large File Support is enabled, or 2 GB if not. However, basically no one is using it now, because no one has a partition as small as 4GB.

FAT 的第二个实现是 FAT16,它在 1984 年首次引入了 16 位文件分配表条目。

根据所使用的操作系统和簇大小,FAT16 格式的驱动器的最大驱动器大小为 2 GB 到 16 GB,后者仅在具有 256 KB 簇的 Windows NT 4 中可用。

启用大文件支持时,FAT16 驱动器上的文件大小最大为 4 GB,否则为 2 GB。 不过现在基本没人用了,因为没人有4GB这么小的分区。

FAT32 (32-bit File Allocation Table)

FAT32 is the latest version of the FAT file system which was introduced in 1996. Now you say FAT often means FAT32. It supports max partition size up to 2 TB or even as large as 16 TB with 64 KB clusters. But in fact, you can only set it up to 32GB in Windows Disk Management.

The biggest single file size on FAT32 is 4 GB, that’s why you will fail if you create a file larger than 4GB in FAT32.

In summary, the FAT file system is considered to have limited performance because it is not complicated, so it is supported by almost all personal computer operating systems. Its good compatibility makes it an ideal floppy and memory card file system, as well as for data exchange in different operating systems.

However, FAT has a serious drawback: when writing new data after deleting a file, FAT does not organize the file into a complete fragment and then writes it. After long-term use, the file data will be gradually dispersed, and the reading and writing speed will be slowed down. Defragmentation is a workaround, but it must be reorganized frequently to maintain the validity of the FAT file system.

FAT32 是 FAT 文件系统的最新版本,于 1996 年推出。现在你说 FAT 通常意味着 FAT32。它支持高达 2 TB 的最大分区大小,甚至高达 16 TB 的 64 KB 集群。但实际上,您只能在 Windows 磁盘管理中将其设置为 32GB。

FAT32 上的最大单个文件大小为 4 GB,这就是为什么在 FAT32 中创建大于 4GB 的文件会失败的原因

综上所述,FAT文件系统被认为性能有限,因为它并不复杂,所以几乎所有的个人计算机操作系统都支持它。其良好的兼容性使其成为理想的软盘和存储卡文件系统,以及用于不同操作系统中的数据交换。

但是,FAT有一个严重的缺点:在删除文件后写入新数据时,FAT不会将文件组织成一个完整的片段然后再写入。长期使用后,文件数据会逐渐分散,读写速度会变慢。碎片整理是一种解决方法,但必须经常对其进行重组以保持 FAT 文件系统的有效性。

总结

  • 区分FAT表和FAT系统,FAT表只是FAT系统的一部分
  • FAT系统会形成磁盘碎片

参考

File Allocation Table (FAT): What Is It? (Its Types & More)

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐