2

I read a single-line explanation of FAT#2 from Peter Abel's book IBM PC Assembly Language and Programming.

It says:

Although FAT2 is still maintained, its use has never been implemented.

Wikipedia says:

The FAT Region.

This typically contains two copies (may vary) of the File Allocation Table for the sake of redundancy checking, although rarely used, even by disk repair utilities.

I could think of two strong reasons to use it

  1. All FAT system has one (unless one disables it)
  2. It's built-in

I realize that FAT is a very old file system, but why has FAT#2 never and rarely been implemented?

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
Jee Seok Yoon
  • 4,716
  • 9
  • 32
  • 47
  • 3
    Sounds like nonsense, a file system that was never actually used is easy to maintain. Do yourself a favor and read the amazon.com reviews before you invest time in a book. "If i ever met Peter Abel in a bar, i would buy a drink just to throw it in his face" is not a stellar recommendation :) – Hans Passant May 26 '16 at 15:33
  • @HansPassant Many students including me suggested that to my professor, but stubborn as he is he's been teaching with this book for about 10 years. So... Wikipedia and Abel is wrong about FAT2? – Jee Seok Yoon May 26 '16 at 15:38
  • 4
    @HansPassant : I don't think the reference here is that _FAT2_ is an actual file system, I believe it is in reference to the second FAT (backup) table. I first thought that the OP meant FAT12, but then realized that the primary FAT table is considered FAT1, and the backup it FAT2. I'd say the wording by Abel makes this confusing :(. I might have realized what was going on at first if it had been referred to as FAT#2 (and FAT#1). – Michael Petch May 26 '16 at 16:06
  • 1
    That makes a lot more sense. Splash! – Hans Passant May 26 '16 at 16:12
  • 2
    I'll offer up a reason or two. Back in the days when we used real floppies that had limited capacity it was common to not even bother having the second FAT. It allowed that space to become usable for the file system (root directory). May seem trivial now adays to spare a few extra sectors but when you want to squeeze more out of a disk it was one mechanism. Speed might have been another as writing to a floppy disk did take extra time.. Since the two FAT's were usually on the same region of disk - if FAT#1 became unreadable, FAT#2 was as well. – Michael Petch May 26 '16 at 17:11
  • I did in fact find a copy of Abel's 4th addition of the book, and I can confirm that FAT1 and FAT2 are references to the File Allocation Table #1 and #2. – Michael Petch May 26 '16 at 17:14
  • 4
    I love the 5 star review which says "You too can write a program to add two numbers in only 7 days" – Weather Vane May 26 '16 at 17:14
  • @WeatherVane : haha. they might have had lower expectations back in 2000 when that review was put up lol – Michael Petch May 26 '16 at 17:22
  • 1
    @MichaelPetch Yes, FAT#1 and FAT#2 are on the same region(infact right next to each other). That's probably the biggest reason FAT #2 is rarely used. This might sound trivial, but I wonder if modern OSs use (or at least creates) FAT #2. I'll check that out when I get some time on my hand. – Jee Seok Yoon May 26 '16 at 18:13
  • @JeeSeokYoon Linux mkfs utility for msdos allows you to specify number of FATs (1 or 2). http://linux.die.net/man/8/mkfs.vfat – Michael Petch May 26 '16 at 18:27

1 Answers1

7

Assuming "FAT2" means a second copy of the FAT (File Allocation Table) then the basic problem is that it's of little practical use, but I'm not sure if it's true if its actually never used.

The FAT is a central data structure in the FAT file system, so central that the file system itself is named after it. It's not only a table of which clusters have been allocated or not, it also stores linked lists of the clusters that make up each file. If a single sector in the FAT is damaged, a potentially large number of files could be lost, so someone at some point thought it would be a good idea to have a backup copy of the FAT.

The problem though is if the FAT is corrupt, how do you tell which copy of the FAT is the correct one? This limits the usefulness of the backup copy to cases when reading from the primary FAT results in read errors. So, at least in theory, if when reading a file the OS encountered an error while reading FAT it could try the backup copy.

However physical disk errors aren't the only way the FAT could be corrupt. In particular, disk repair utilities, like chkdsk, weren't really designed to fix file system corruption caused by read errors. They were only meant to fix corruption due to bad data being written to the disk. The most common case would be when the computer was shutdown in the middle of writing to the disk. In that case the file system could easily be an inconsistent state. In particular if the OS was in the middle of updating the FAT it might have updated the primary copy but not the backup copy, or it might have updated backup copy but not the primary copy. There's no way to know which.

I'm not sure if operating systems actually do bother to check the backup FAT after read errors. It's hard to tell, because it rarely makes a difference in practice. Single sector read errors are uncommon on hard disks made in the last 20 years or so, since they remap failing sectors before they go bad. Drives tend to have no disk errors until they fail completely. Even on floppies physical disk errors tend to affect entire tracks, which would wipe out both copies of the FAT.

Looking at the source for the Linux and FreeBSD FAT file system implementations it appears neither tries the backup FAT if reading from the primary FAT fails. I don't know what any of Microsoft's three main implementations (MS-DOS, Windows 95 or Windows NT) do.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112