Show HN:理解 FAT16 —— 一个交互式文件系统解释器
Show HN: Understanding FAT16 – an interactive filesystem explainer

原始链接: https://fat16.asciitweezers.com/

文件系统在幕后将磁盘的原始字节组织成文件和文件夹。FAT 于 1977 年诞生,并随着存储容量的增长而演变为 FAT12、FAT16、FAT32 和 exFAT。早期版本被设计得极为简单,甚至可被微小的软盘引导程序读取,并因此在各操作系统中得到广泛支持。微软后来随着 Windows XP 将个人电脑迁移到 NTFS,但 FAT32 仍因可移动介质和跨平台使用而持续存在。FAT32 支持大容量卷,但单个文件限制为 4 GB;exFAT 后来提高了这些限制。本文重点介绍 FAT16B,即 1987 年的标准版 FAT16。

Hacker News 的一篇“Show HN”帖子介绍了一个 FAT16 文件系统的交互式解释器,由 giant_fern 制作,以满足童年时对磁盘碎片整理的好奇心。网站文字较多,但包含用于编辑、读取文件、检查字节以及最终手动磁盘碎片整理小游戏的交互元素。作者邀请指正、反馈和历史背景。一条评论回忆了怀旧的 Amiga/FAT DOS 体验和改变首个引导代码指针的引导病毒,指出 FAT 备份很有用。
相关文章

原文

The filesystem, in its omnipresence, is mostly invisible. "What the hell is water?", as the fish asks. The short answer is that it's a subtle, understated jewel.

Computer storage hardware has no concept of files or folders - there are only (billions and billions of) bytes. The filesystem is a set of algorithms that track and manage which bytes belong to which files, like a table of contents that maps out which pages belong to which chapters of a book.

A filesystem normally takes over most or all of the disk and gatekeeps all access. In day-to-day use, we are happy to let that happen, because in return we get to have files and folders1 Yay! Files and folders! We love organizing our files hierarchically! without having to worry at all about the Tetris problem of how files should be arranged on disk.

The original version of FAT was created in 1977, and followed by FAT12 in 1980 as part of 86-DOS, which would later be acquired by Microsoft. This was an era where most personal computers didn't have internal storage, and most software ran from floppy disks which had capacities in the hundreds of kilobytes. The filesystem and its own data structures needed to be simple and compact to make the most of that limited space.

For software that booted from a floppy, the tiny, 448-byte bootloader program would need to contain enough logic to navigate the filesystem and load the rest of the program. So it's safe to say that the FAT filesystem was originally designed to be so simple that a 448-byte program can at least read it2 In general, this is not a good heuristic for whether something seems simple to a human layperson..

As hard drives became more common and grew to be tens of megabytes in size, the design of FAT12 hit its limits and so FAT16 was introduced in 1984 as a conceptually similar but extended version. It would later be succeeded by FAT32 in 1996 as hard drives kept getting bigger3 Just keep making the FAT bigger! Another decade can't hurt us!.

By this time, even competing operating systems like Mac OS, Linux, BeOS, Amiga and Acorn had some level of FAT support, making it possible to transfer files back and forth over floppy4 From what I'm told, this was still a risky process, and putting a DOS-formatted floppy into a Mac or vice versa always carried the possibility of losing all your data. Floppies in particular had a deeper level of possible incompatibility: how the binary data itself was encoded into magnetic fluxes. So having a filesystem driver isn't enough - you also need to have a mutually compatible disk controller. This is why tools like Greaseweazle are so useful for archival.. In their dominance, Microsoft never bothered to support the filesystems of their competitors.

With the introduction of Windows XP in 2001, most PCs adopted NTFS, a different Microsoft filesystem with a much more modern and sophisticated design. But FAT32 stuck around in various memory cards, USB sticks, and whatever other drives needed cross-OS write support5 When Apple adopted Intel CPUs, it became possible to dual boot Windows and Mac on the same computer. To make it easier to pass files back and forth between the two OSes, one strategy was to keep the Windows partition formatted as FAT32, or else to carve out a shared FAT32 partition that both OSes would access.. If you were writing digital camera firmware in the early 2000s, FAT32 was the easy, definitely correct choice. Filesystems are high stakes - if there's a bug in your implementation, you corrupt people's data. So if you find yourself implementing one from scratch (and without an AI assistant or even Stack Overflow), you will reach for the simple, high-capacity and ubiquitous option.

Although FAT32 supported large total volume sizes even by the standards of the era, typically up to 2 TB, any individual file couldn't be more than 4 GB, a ceiling that remained unchanged from FAT16. So there is one final successor version, exFAT, released in 2006, which bumps all the limits one last time. Still, FAT32 is both so old and so close to good enough that it probably remains the most ubiquitous.

But let's rewind to that transitional period between floppies and hard drives, and get comfortable with FAT16.

As a historical note, there were several patches and updates to FAT16 over the years. We'll focus on the version known as FAT16B from 1987, which became the standard, along with a few minor additions.

联系我们 contact @ memedata.com