Page 1 of 1
Why are all FAT disks bootable, even if they're not?
Posted: Thu Jun 13, 2013 2:07 am
by linguofreak
I've noticed that pretty much all FAT volumes, whether they're supposed to be bootable or not, and no matter whether they were formatted with Microsoft's tools or someone else's, contain a boot signature and a dummy bootstrap that prints a message to the effect of "Non-system disk or disk error, yada yada". This strikes me as incredibly broken:
First of all, why was this even implemented in the first place? The BIOS has its own perfectly good mechanism for checking to see if a disk is bootable, so why do FAT volumes *lie* to that mechanism and then print their own "this disk isn't bootable" message? And if a FAT volume happens to be early in the boot order, any actually bootable volumes behind it are prevented from booting.
Secondly, what's the point in the words "or disk error" on FAT disks formatted by Microsoft tools? The message is part of the boot sector, so it doesn't get printed if there's a disk error reading the boot sector, and the bootstrap doesn't make any attempt to read further sectors (or, at least, I assume it doesn't, given that it prints that message, waits for a keystroke, and reboots). So what opportunity is there for a disk error to have occurred if you're seeing that message?
And then there's the question as to why third party tools (such as mkdosfs on Linux) duplicate the behavior. Does Microsoft software check for boot signatures on FAT volumes and assume that a volume isn't FAT if it doesn't have a boot signature?
Re: Why are all FAT disks bootable, even if they're not?
Posted: Thu Jun 13, 2013 2:56 am
by BMW
Is the message something like "Disk error. Please remove any bootable media and restart"? I think that happened to me a while ago when I had a flash drive plugged in when trying to boot my external HD.
Re: Why are all FAT disks bootable, even if they're not?
Posted: Thu Jun 13, 2013 4:15 am
by sortie
It's probably some compatibility stuff that is needed to work with some systems.
Re: Why are all FAT disks bootable, even if they're not?
Posted: Thu Jun 13, 2013 6:40 am
by AJ
Hi,
My guess that it is probably just an anachronism. Remember that when floppy drives were first in use, you would either have no hard disk, or the boot order would be set up so that the floppy was attempted first, followed by the hard disk. The BIOS did not read the floppy disk and look for a boot signature before trying other devices, it would simply fail to boot if a unbootable floppy disk was present.
Cheers,
Adam
Re: Why are all FAT disks bootable, even if they're not?
Posted: Thu Jun 13, 2013 2:28 pm
by Yoda
linguofreak wrote:First of all, why was this even implemented in the first place? The BIOS has its own perfectly good mechanism for checking to see if a disk is bootable...
No, you are wrong.
First, there is no mechanism to detect if the disk is bootable. The only thing the BIOS checks is 0AA55h signature at the position 510-511. But, the same signature is the part of FAT filesystems also, according to MS documentation.
Second, boot code depends on type of OS stored on that disk, so it is up to OS to determine what to do with the boot code, whether to write real boot or to write dummy.
Third, good boot code is able to detect that the disk in fact doesn't have an OS and can pass control to other drives in boot chain.
linguofreak wrote:Secondly, what's the point in the words "or disk error" on FAT disks formatted by Microsoft tools?
To answer this question it is needed to inspect MS' code. As far as I remember, this is just a common error message forced by the lack of space in boot code.
linguofreak wrote:And then there's the question as to why third party tools (such as mkdosfs on Linux) duplicate the behavior.
And what they should do? Boot an OS? Which OS? The only reasonable action they can do is just to throw error message. And, if they are not too dumb, pass control back to BIOS to boot from next drive.
linguofreak wrote:Does Microsoft software check for boot signatures on FAT volumes and assume that a volume isn't FAT if it doesn't have a boot signature?
Yes, according to an official MS documentation, legal FAT volume has to have this signature.
Re: Why are all FAT disks bootable, even if they're not?
Posted: Fri Jun 14, 2013 8:38 am
by egos
This occurs only to floppies/super floppies. So just remove such device to boot from other device.
Usually formatting tools write boot loader into boot record as a first-stage part of OS in which they work. Of course OS cannot be loaded from device right after formatting, but it can be loaded from this device later.
OS boot loader can not pass control to other devices in BIOS boot sequence (int 18h) because OS-independent boot loader (MBR) should carry out this function. OS boot loader can consider this situation as an ineradicable error which happened during OS loading. It's good behaviour, I think.
Re: Why are all FAT disks bootable, even if they're not?
Posted: Fri Jun 14, 2013 11:52 am
by linguofreak
Yoda wrote:linguofreak wrote:First of all, why was this even implemented in the first place? The BIOS has its own perfectly good mechanism for checking to see if a disk is bootable...
No, you are wrong.
First, there is no mechanism to detect if the disk is bootable.
Not to determine if it actually contains code that will boot an OS, no. But the BIOS provides a mechanism for disk tools to signal to the BIOS that a disk is bootable, namely by placing 0xAA55 at the end of the first sector. Software that writes 0xAA55 at this position is responsible for making sure that the disk contains boot code.
The only thing the BIOS checks is 0AA55h signature at the position 510-511. But, the same signature is the part of FAT filesystems also, according to MS documentation.
And this is exactly my question: Why did MS write the FAT specification so as to force compliant disk tools to abuse the BIOS's interface for determining if a disk is bootable by signaling that a disk is bootable whether it is or not?
Second, boot code depends on type of OS stored on that disk, so it is up to OS to determine what to do with the boot code, whether to write real boot or to write dummy.
No, it is up to the OS or formatting tool to write boot code and a boot signature if the disk is to be bootable, or to write neither if the disk is not to be bootable.
Third, good boot code is able to detect that the disk in fact doesn't have an OS and can pass control to other drives in boot chain.
Except that if a disk doesn't contain an OS, neither boot code nor a boot signature should be written to it in the first place, so that the BIOS can look for a boot signature, see that there isn't one, and automatically go to the next drive in the boot chain.
linguofreak wrote:Secondly, what's the point in the words "or disk error" on FAT disks formatted by Microsoft tools?
To answer this question it is needed to inspect MS' code. As far as I remember, this is just a common error message forced by the lack of space in boot code.
But by omitting "or disk error", they'd save space. I'm asking why "Non-system disk or disk error" is printed rather than just "Non-system disk". A disk error would prevent the message from being displayed in the first place, and so there's no reason to include the words "or disk error" in that message.
linguofreak wrote:And then there's the question as to why third party tools (such as mkdosfs on Linux) duplicate the behavior.
And what they should do? Boot an OS? Which OS? The only reasonable action they can do is just to throw error message. And, if they are not too dumb, pass control back to BIOS to boot from next drive.
What they should do is *not put 0xAA55 at the end of the boot sector on non-bootable disks if they can at all avoid it*. Now, given your quote below, they can't avoid it, and so this particular question is answered. Of course, the question as to why Microsoft abuses the boot signature interface remains.
linguofreak wrote:Does Microsoft software check for boot signatures on FAT volumes and assume that a volume isn't FAT if it doesn't have a boot signature?
Yes, according to an official MS documentation, legal FAT volume has to have this signature.
Re: Why are all FAT disks bootable, even if they're not?
Posted: Fri Jun 14, 2013 12:59 pm
by AJ
Hi,
linguofreak wrote:
But by omitting "or disk error", they'd save space. I'm asking why "Non-system disk or disk error" is printed rather than just "Non-system disk". A disk error would prevent the message from being displayed in the first place, and so there's no reason to include the words "or disk error" in that message.
Perhaps because they use the same string whether it's a non-system disk or whether the boot sector is unable to perform subsequent reads? They probably also just stick the same string there whether or not the disk was formatted with the /sys option. I wouldn't get too concerned about it...
Cheers,
Adam
Re: Why are all FAT disks bootable, even if they're not?
Posted: Fri Jun 14, 2013 1:38 pm
by egos
linguofreak wrote:But by omitting "or disk error", they'd save space. I'm asking why "Non-system disk or disk error" is printed rather than just "Non-system disk". A disk error would prevent the message from being displayed in the first place, and so there's no reason to include the words "or disk error" in that message.
??? In old MS boot loaders was used one error message for both basic error types. In Win95 already were used two error messages: "Invalid system disk", "Disk I/O error". In modern MS boot loaders we can see same thing: "... is missing", "Disk error" (or "A disk read error occurred" for NTFS). Even there is one specific error message for NTFS: "... is compressed". I always considered two error kinds: "logical errors" that are inherently not errors but they make a boot process unsuccessful (system file not found, not enough memory for loading system files and so on), and "physical errors" (disk read error, file system error and so on). So in my stage 1 boot loaders are used two error messages: "Disk boot failure", "Disk error".
Re: Why are all FAT disks bootable, even if they're not?
Posted: Sat Jun 15, 2013 10:41 pm
by Owen
When FAT was designed, all it was designed for were floppy disks for DOS.
The "Non system disk" part of the error comes from disks without DOS on them.
The "or disk error" presumably comes in case you had your DOS disk in A: and a data disk in B:, and because of a disk error on A: the BIOS fell through to B:. The error was to make things less confusing.
Re: Why are all FAT disks bootable, even if they're not?
Posted: Tue Jun 18, 2013 3:05 pm
by technix
At least if you format the disk with MS-DOS, it dropped its bootloader there. The message you have seen is a fail message of that bootloader since the required files are missing.
You can try drop two COM files as msdos.sys and io.sys and you will know - you can drop a 2nd-stage (COM format) there that sets up 32-bit protected mode, and load your ELF 3rd-stage.
Re: Why are all FAT disks bootable, even if they're not?
Posted: Fri Jun 28, 2013 12:32 pm
by AbstractYouShudNow
Perhaps the MS bootsector just looks for some second-stage bootloader on some hard disk in the system, and prints this message if it's not found.
IMO having one error message for all cases is for gaining space: one "Non-system disk or disk error" is smaller than "No Operating System on this disk" plus "A disk error occured". I've already seen OS's that had even more useless messages (one just displayed "KERNEL.MNT ?" if it didn't find its kernel file). What's important is that boot code is very restricted in both space and abilities, and such big companies want to focus on other things...