7

While browsing online materials about the FAT file system, I occasionally came across mentions of ‘logically-sectored FAT’. This was apparently some kind of special mode of formatting a hard drive, where the file system structures were laid out pretending that the sector size is larger than it actually is, to bypass size limitations of early versions of MS-DOS. Just for one example, in Andries Brouwer’s listing of partition type IDs, there are even partition type IDs listed as claimed for such specially-formatted partitions.

How did this scheme work? What did it take to have such a setup on your system?

5
  • 1
    Mentions like this one? Commented Mar 1, 2023 at 10:47
  • 1
    For example. I am asking because this seems to be some kind of unofficial hack, and I don’t recall this feature mentioned in any official MS-DOS documentation. (Though I have not been looking too hard.) Commented Mar 1, 2023 at 11:08
  • Isn't that just the fairly common approach of allocating disk space in units larger than the physical sector size? No change in low-level disk formatting, just the file system structures.
    – dave
    Commented Mar 1, 2023 at 13:18
  • Sure, you can define a ‘sector’ used by the file system as a larger unit than the physical sector size, but the BIOS disk interrupt services will still use 512-byte sectors, and I wonder how that mismatch was handled. Commented Mar 1, 2023 at 13:24
  • @user3840170 BIOS does not care about any filing system. Also, if a drive has a different physical sector size is used, it's the job of that drives's BIOS to convert. After all, disk-BIOS is an add on, specific to its drive.
    – Raffzahn
    Commented Mar 2, 2023 at 12:29

2 Answers 2

3

TL;DR: It's all about the Interface.

DOS prior to version 3.31 used a 16 bit sector number to communicate with the disk driver, thus the maximum sector number was 65536. With 512 byte sectors that adds up to 32 MiB - rather large for 1980.

DOS 3.31 introduced an extension to interface (and BIOS Parameter Block) increasing the sector number field to 32 bit, allowing 2 TB when using 512 byte sectors (*1).


DOS always maintained a strictly logical device interface and did not (and still does not) imply a certain sector size. The sector size can be anywhere between 1 and 65525 bytes. It is defined by a 16 bit value at Offset 0Bh within the BIOS Parameter Block (*2). For all practical means only power of two values between 32 and 32768 are useful and only values between 128 and 8192 do work with (most) DOS versions (*3).

With a block size of 512, as IBM selected for its first hard disk, the maximum number of 65536 sectors will limit the logical disk size to 32 MiB. To support drives larger than 32 MiB vendors could either

  • present it as multiple logical drives (*4) or
  • use a larger logical sector size.

While the first would limit the use of truly large files, the late would come at cost of more waste - the usual trade of between size of management unit vs. useful data.

Of course, using larger sectors will also mean DOS needs to reserve more buffer space of the limited main memory - not cool with 640 KiB or less total RAM.

Those sectors are named 'logical' as they are not necessary the same size than the physical sector. If not, it was the task of the vendor specific device driver to block and deblock sectors.

In fact, larger disks were often still using 512 byte sectors on disk level, so all that number juggling was just to get around the interface limitation - much like with later INT 13h games.


*1 - In fact, all of this does sound a lot like the more recent discussion of 4 KiB block sizes to increase physical drive capacity and thruput.

*2 - Before 2.0 those values where fixed tied to the media descriptor. IBM for example used values of 128 and 1024 some 8" disks.

*3 - Microsoft's official FAT paper (fatgen103.pdf) does only name sizes of 512 to 4096 bytes as valid for MS-DOS (p.9). In contrast MS' own KB entry Q75131 mentions 128 bytes for media type FE and FD.The paper seems to have been created in hindsight with less than perfect knowledge, containing several errors (explanation of the 10ms time value at 0Dh is for example complete nonsense).

*4 - Using the partitioning scheme introduced with DOS 2.0 (MBR) - or before DOS 2.0 using some vendor specific scheme implemented in their driver.

2
  • 1
    The fatgen103.pdf from Microsoft says only values of 512,1024,2048 and 4096 are supported, and that many FAT implementations from other vendors may be hardwired to work with only 512-byte sectors.
    – Justme
    Commented Mar 1, 2023 at 20:10
  • 2
    @Justme you're comment is about the bytes per sector field? If yes, note that the paper is from ~2000 and not necessary covering all MS-DOS version. there was quite some variation up to 3.31. 128 bytes for example has been used with 8" floppy drives. I do think I remember 8192 being used as well, but let me add a footnote - and thanks for remembering about the document.
    – Raffzahn
    Commented Mar 1, 2023 at 21:15
1

The IBM BIOS itself never defines a default sector size, it just happens that in DOS the default IBM format with physical sector size of 512 is used for floppies.

Accessing hard disks through the BIOS was not possible until an add-on hard drive with add-on BIOS was inserted into the system, and it used a fixed sector size of 512 bytes, so the BIOS interface for e.g. later IDE hard drives can't be changed as the sector size of 512 bytes is defined by IDE hardware.

Other floppy formats than 512 bytes per sector were used so BIOS and DOS needed to be compatible with different sector sizes.

All DOS IO to a DOS disk partition is done using logical sectors access which start from 0, so the partition can physically start anywhere on the drive.

When the DOS logical disk IO only supported 65536 sectors, it limits the drive size with 512 byte sectors to 32MB, so it is possible that some interfaces could have used larger hardware sector size because of this.

But it might have been a relatively short lived extension, as DOS 4 expanded the interfaces to support accessing more than 65536 sectors.

And still, if the drivers support it, you could just partition a large physical drive into multiple logical partitions with less than 65536 sectors per partition, and still have 512 byte sectors.

The extension made it possible to still use 512 byte physical sector size for larger drives, and the logical sector number matches the physical sector number even for drives larger than 65536 sectors.

Edit: Some vendors did in fact have a System BIOS or DOS BIOS which combined several 512-byte physical disk sectors into single larger DOS logical sector. So indeed some adaptation layer presented a standard 512-byte sector hard disk as a logical disk with larger logical sectors for DOS.

5
  • 2
    What part of this explains what is ‘logically-sectored FAT’? Commented Mar 1, 2023 at 17:22
  • The part where DOS accesses each partition starting from logical sector 0 even if the partitions start on any arbitrary physical sector on disk? FAT always uses logical sectors, mapped to disk physical sectors. For floppies, the logical sector 0 will also be physical sector 0. But logical and physical sector sizes must match, or at least the physical sector size presented to DOS. It would be extremely difficult to translate between different sector sizes - for example 4K sector IDE/SSD drives still present you access with 512 byte logical sectors and handles the 4k physical size interally.
    – Justme
    Commented Mar 1, 2023 at 17:43
  • I would think the compatibility hack would be for a driver to use each 4KB sector of a drive to hold 512 bytes, effectively treating a newer drive that can't write less than 512 bytes at a time as though it were an older drive 1/8 the size.
    – supercat
    Commented Mar 1, 2023 at 18:20
  • @supercat ATA standard says otherwise. Even if sectors are physically 4k on drive, the 512 byte sector size is emulated by each 4k physical sector containing 8 logical sectors of 512 bytes. Which is why there was much fuss about re-aligning partitions so that e.g 4k clusters get aligned on 4k physical sectors on a drive which uses legacy sector size emulation.
    – Justme
    Commented Mar 1, 2023 at 18:42
  • 1
    @Justme: I'd thought there was a push to recognize the existence of drives which didn't emulate 512-byte sectors. though maybe someone recognized that having a drive hold a small cache of individual sector writes, and consolidate read-modify-write sequences when older cache entries get displaced by newer ones. Personally, I think it's a major shame that there hasn't yet been a drive interface standard which behaves more like NFS, letting the drive translate file-based access requests to physical locations, without adding a useless FAT layer in between.
    – supercat
    Commented Mar 1, 2023 at 19:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .