Why are all FAT disks bootable, even if they're not?
-
- Member
- Posts: 510
- Joined: Wed Mar 09, 2011 3:55 am
Why are all FAT disks bootable, even if they're not?
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?
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?
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.
Currently developing Lithium OS (LiOS).
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
Re: Why are all FAT disks bootable, even if they're not?
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?
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
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?
No, you are wrong.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...
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.
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:Secondly, what's the point in the words "or disk error" on FAT disks formatted by Microsoft tools?
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:And then there's the question as to why third party tools (such as mkdosfs on Linux) duplicate the behavior.
Yes, according to an official MS documentation, legal FAT volume has to have this signature.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?
Re: Why are all FAT disks bootable, even if they're not?
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.
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.
If you have seen bad English in my words, tell me what's wrong, please.
-
- Member
- Posts: 510
- Joined: Wed Mar 09, 2011 3:55 am
Re: Why are all FAT disks bootable, even if they're not?
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.Yoda wrote:No, you are wrong.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...
First, there is no mechanism to detect if the disk is bootable.
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?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.
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.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.
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.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.
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.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:Secondly, what's the point in the words "or disk error" on FAT disks formatted by Microsoft tools?
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.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:And then there's the question as to why third party tools (such as mkdosfs on Linux) duplicate the behavior.
Yes, according to an official MS documentation, legal FAT volume has to have this signature.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?
Re: Why are all FAT disks bootable, even if they're not?
Hi,
Cheers,
Adam
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...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.
Cheers,
Adam
Re: Why are all FAT disks bootable, even if they're not?
??? 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".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.
If you have seen bad English in my words, tell me what's wrong, please.
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Why are all FAT disks bootable, even if they're not?
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.
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?
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.
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.
-
- Member
- Posts: 92
- Joined: Tue Aug 14, 2012 8:51 am
Re: Why are all FAT disks bootable, even if they're not?
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...
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...