0

my very short and basic question is how boot sector gets written in the first sector of disk. I mean who is responsible for it. The next question is why io.sys and msdo.sys are 11 characters long with no dot (".") sign in between them.

godmahakal
  • 57
  • 3
  • 1
    You're responsible for writing it to a device you want to boot from. You can use a tool like `dd`. [Using dd in order to save and restore a boot sector?](https://unix.stackexchange.com/q/252509) – Peter Cordes Aug 19 '20 at 03:46
  • The blank-padded 8-byte basename and 3-byte extension without an explicit dot is the FAT FS's way of storing short filenames in the directory entry. Because the loader only works with the raw directory entries, no higher level abstractions, this form of filename is used. – ecm Aug 19 '20 at 04:33
  • [Filesystem on Loop Device not Recognized by Linux when Bootloader is Written to it](https://stackoverflow.com/questions/57154972/filesystem-on-loop-device-not-recognized-by-linux-when-bootloader-is-written-to/57162207#57162207) also describes how to install a boot sector loader. As to who is responsible, in DOS it was either the `format` or `sys` program. More recently, whatever installer sets up an OS generally writes the required loaders too. – ecm Aug 19 '20 at 04:37

1 Answers1

3

I mean who is responsible for it.

On a real floppy disk:

Under MS-DOS the program which formats the floppy disk (the format program): All floppy disks formatted by MS-DOS initially contain a boot sector that allows booting MS-DOS (or Windows 9x).

However, in later MS-DOS versions, the "sys" tool (copying io.sys and msdos.sys to the disk) wrote the boot sector to the floppy disk anyway to ensure that the correct boot sector is installed; in some earlier MS-DOS versions the "sys" tool seemed to rely on the fact that the disk already contained a correct boot sector.

Other operating systems (for example self-written operating systems) use special boot sectors; in this case the boot sector must be written later on. For example using a program or tool that is delivered together with the operating system.

Early Linux versions (for example) came with a tool named "rawrite.exe" that allowed writing a boot disk image (or a boot sector) when MS-DOS or Windows was already installed on the computer.

The next question is why io.sys and msdos.sys are 11 characters long with no dot (".") sign in between them.

On FAT-formatted floppy disks, all files (with exception of the special directory names "." and "..") are stored this way:

A file has a name of up to 8 characters, optionally followed by a dot followed by up to 3 characters.

On the disk, the name is always stored as exactly 8 characters followed by exactly 3 characters with no dot in between. The two parts are filled with space characters if the are not long enough.

Examples:

File name         Stored as
"TestFile.TxT"    "TESTFILETXT"
"test.py"         "TEST    PY "
"Hello"           "HELLO      "

Note...

... that MS-DOS only supported upper-case file names and it did not support file names that did not match the "up to 8 characters + up to 3 characters" scheme.

Trying to store a file named "StackOverflow.html" would have resulted in storing a file named "STACKOVE.HTM".

Windows internally still uses this "8.3" scheme, however, it additionally stores a "long" file name visible to the user for each file.

If you store a file named "StackOverflow.html" to a FAT-formatted disk, the file will actually be named "STACKO~1.HTM" (8 + 3 characters) and Windows stores some additional information that the file is also named "StackOverflow.html". So every file has two names!

However, the "long" file name is more difficult to read from the disk than the "8.3" file name. So if you know the "8.3" file name of a file (which is always stored as exactly 11 bytes on the disk), you will not search the disk for the "long" name.

Martin Rosenau
  • 17,897
  • 3
  • 19
  • 38