1
$\begingroup$

I am going through the following series of lectures on OS development .

http://www.brokenthorn.com/Resources/

In the fourth tutorial , I came across the term " OEM" parameter block that stores the windows MBR and the Boot-record information whose soul purpose is to describe the file system on the disk .

And then on moving to the following tutorial ,by taking the authors promise to explain about it at a later opportune point , I came across the term "FAT" file system . And I could see that there were few terms in the parameter block like "bpbNumberofFATS" and "bpbsectorsperFAT" . "FAT" stands for "File Allocation Table" and it is a again a "filesystem" .

This got me confused as "OEM" parameter block is used to describe the filesystem on a disk . And if "FAT" itself is a file system , then that means and surely there are other file systems ,which could have been on that disk . Why will the "OEM" block predefine the file system in terms of "FAT".

On reading a bit about other file systems , I came across statements like "FAT was written by .." . And it further piqued me to ask , what does it mean to write a filesystem ?

So , basically I am confused about :

  1. What exactly is a filesystem ? (Is it a kind of coordinate system to provide information about the storage of the contents of the file ?)

  2. How is a file system written ?

    1. There are a lots of other file systems , OEM is used to describe the file system on a disk , so why OEM has parameters concerned about FAT's ? And who sets the filesystem of a disk and how ?
$\endgroup$
2
$\begingroup$

The MBR refers to the format used by (many but not all, and slowly being replaced by GPT) disk to identity partitions. A partition is simply a contiguous range of blocks on the disk. A partition is often used to store data, in the form of files and directories. But of course a disk knows nothing about files and directories. A file system is a system that controls how your data is stored on the disk. A file system is really two things:

  • it specifies how the data is organized and accessed (directories, files, links, permissions, encryption, ...): this is the logical aspect
  • it specifies how this data is encoded on the disk: this is physical aspect

There exists many file systems: FAT, exFAT, NTFS, ext, btrfs, HFS, XFS, ISO 9660 and others. FAT is a file system invented by Microsoft. What this means is that they designed the logical and physical aspects of it, and they applied and were granted a few patents on it. They also wrote the Windows driver for FAT, but note that anyone can do that (assuming the file system is properly documented and ignoring royalties issues) and indeed linux and MacOS have their own driver which follows Windows's specification.

Now as I explained a file system specifies how the data is encoded on the disk and FAT is not exception. The first sector of a FAT partition (also known as the boot sector, or super block) is what is described in the link you gave: is starts with 3 bytes for a jump instruction and is followed by the BIOS/OEM Parameter Block (which has a different format on FAT12, FAT16 and FAT32). This OEM block is specific to FAT and does not exist on other file systems. Other file systems use a different format. I might add that calling this the OEM/BIOS block was very unfortunate because it really has little to do with BIOS or OEM, but that was the name Microsoft came up with. It should really be called the FAT Parameter Block.

To finish, designing a good file system is hard because they are many trade-offs to make. FAT is simple and relatively robust, but sucks at about everything else if I may say. Sadly it is also the only file system that all OSes support and so is the de facto standard for interoperability.

$\endgroup$
  • $\begingroup$ So , how off would it be to say that it is a kind of coordinate system for files ? On what basis do we compare the technical efficiency of different file systems ? $\endgroup$ – Amigorust Burrough Jan 21 '18 at 17:27
  • $\begingroup$ I would say it is a correct description at the high-level for simple file systems. But file systems can provide a number of other functionalities, such as transactions, encryption, reliability against crash/error, snapshots, copy-on-write, and so on, that make this analogy not quite right. Comparing the efficiency of different file systems is not trivial because of various trade-offs. Some want fast FS, some want reliable FS (in case of crash or errors), some want snapshopts. $\endgroup$ – Amaury Pouly Jan 21 '18 at 17:38
  • $\begingroup$ Here is an example of benchmark for file systems: phoronix.com/… mostly focused on speed. $\endgroup$ – Amaury Pouly Jan 21 '18 at 17:44
  • $\begingroup$ What makes a file system faster as compared to other ? Will it be a kind of reasoning that makes operations like sorting in a heap or B-tree faster as compared to the operation in an array ? $\endgroup$ – Amigorust Burrough Jan 21 '18 at 17:51
  • $\begingroup$ There are many reasons. Some are structural: if the file systems uses some clever structure on disk like B-trees, then some operations are faster. But there are other factors: some file systems will work better on rotating disks, some better on SSD, some better on raw NAND. The quality of the driver and the operating system is crucial as well. Also the I/O pattern is extremely important. There is no simple answer. $\endgroup$ – Amaury Pouly Jan 21 '18 at 18:23
2
$\begingroup$

OEM Parameter block

The OEM block not only stores data about the filesystem, it also contains information about the physical hard drive geometry, or about how files are laid out on your hard drive or SSD. This was used by older BIOSes to determine how a hard drive was set up from the manufacturer. As a good primer for explaining hard drive geometry, I can suggest this chapter on pcguide.com , and this one

Important geometry parameters I can see are:

  • bpbBytesPerSector: Which describes the sector size. This is basically the smallest unit of data that anything can write to the drive. It's usually 512 bytes, but newer large drives may use 1024 byte or larger sectors.
  • bpbSectorsPerCluster: Which indicates how large a cluster is in # of sectors. A cluster is the smallest unit of data the filesystem can manage
  • bpbSectorsPerTrack: The number of sectors per physical track on a hard drive

This method is, however an obsolete method of determining the size of a hard drive. Since the late 90s, Logical Block Addressing has taken over, which in itself is basically a direct method of counting and mappping every sector or block on a hard drive or SSD. However BIOSes and modern OSes still use it for legacy purposes.

To answer your Question # 3, FAT is the very first filesystem written for IBM-compatible PCs. This is likely a throwback to FAT 12 and 16 and earlier implementations of the OEM parameter block specification. As with many other HDD-related quirks in the IBM/x86 family it's likely that it's been left there for legacy purposes. Earlier FAT implementations (and fat12, still) could only write a single partition to a disk. Also, FAT partitions usually contain 2 allocation tables, the main table and a backup table for integrity and error-correction purposes.

What is a filesystem?

Basically a means of getting disorganized data assigned into a system that can be understood by us, as well as the computer. Your assumption of it being a "coordinate system" for files is not inaccurate.

A very basic filesystem has to do the following:

  • Map a given file to a set of sectors/clusters
  • Provide a way to distinguish one file from the next (eg. start and end address)
  • Provide a way for the user to locate needed data (eg. by a filename)
  • Provide a way for the rest of the hardware and software to easily understand how data is to be read and written according to hardware and OS rules (abstraction layer, API, or what you prefer to call it nowadays)
  • Provide a way to protect data and indicate that a given section of the HDD/SSD is occupied and other basic information or limitations (eg. write protect bit, file size, file attributes)
  • Provide a way to remap data, so that the medium is used most effeciently

Optionally a file system also provides extra aids for improving reliability (by saving important data in multiple places or providing error correction mechanisms), speed (eg. by using search indexes), security (encryption, permissions) or user experience (Sorting files by using folders or providing easy access by using shortcut files or symbolic links)

It is very important to know, for all intents and purposes, that the way your file manager shows you the files is NOT the way the data is actually laid out on the drive. An effecient filesystem has to be able to remap data. For more on that, I suggest you read up on this very informative chapter

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.