Jump to content

On Bootable CD's Floppy Emulation


rloew

Recommended Posts

If you checked out UltraISO you'd notice that is the "friendly name" by which a file system is selected. Currently it doesn't respond to image file loading because I was too tired this morning at 6 so I had to wrap and go to sleep (yeah, bad habit, I know...). But when working, it should just be the friendly correspondent of OEM string.

Sectors are not 'small' or 'large', but the count is 16bit (when sector count doesn't exceed 0xFFFF) or 32bit when it does. So I'd rather modify to 16bit/32bit than use a misleading denomination (which actually made me wonder at first glance what this small/large is all about). Same goes for 'Sectors before' - I kept wondering what that meant until I found documentation that called it as it should: hidden.

Well, as always you are perfectly free to call whatever with whatever name you like. :)

BUT:

  1. OEM string is one thing, BOOT CODE is another and FIle System is yet another, if you like to call the BOOT CODE "File system", it's OK, as long as you say so :rolleyes: .
  2. I wouldn't take Ultraiso as a "reference" for English or proper terms, being itself written by a Chinese guy/gal.
  3. Every tool I remember having seen do use the "Small sectors" and "Large sectors", of course "Sectors 16" and "Sectors 32" are fine as well, you can also call them, respectively, Mickey Mouse and Minnie :w00t:, but that won't help people understanding them easily :whistle: .
  4. just for the record, the "Sectors Before" are actually " "Sectors Before" and are not "hidden" at all since they are OUTSIDE (before ;)) the actual filesystem, but, as said, a number of tools do call them (incorrectly IMHO) "Hidden sectors" so it's allright. :thumbup .

@dencorso

So, 4079 is the number for FAT12?

WHICH one is for FAT 16?

WHAT about number of entries in ROOT?

WHAT about cluster size "strategy"?

jaclaz

Link to comment
Share on other sites


@dencorso

So, 4079 is the number for FAT12?

WHICH one is for FAT 16?

WHAT about number of entries in ROOT?

WHAT about cluster size "strategy"?

Before anything, we're entering a domain where YMMV.

That said, I'm convinced 4079, meaning 4078 addressable clusters plus 1 for the fs is the safest choice for FAT-12.

By the same token (2^16)-18 clusters, plus enough space for the fs. I've never created a FAT-16 by hand, but I remain firm on the idea that -18 is the magic number.

If one follows the Wikipedia, and uses -12 instead of -18, there might be compatibility problems, because not everyone agrees about the allowability of using or not 0xFF0 - 0xFF5. I see no valid reason for courting trouble in this way.

Now, the cluster size strategy, for FAT-12, is that, given a physical device size or having decided on a given image size, one divides it by a random bytes-per-cluster number (not so random as it must be a multiple of 512 and cannot exceed 32 kiB)... and look at the result: if one gets more than 4078 the bytes-per-cluster number is too small. I've not though about this for FAT-16, but I believe a similar line of reasoning must hold for it, too.

As for the number of entries in the root directory, my guess is: (i) it must exist: so giving it just one sector means 16 entries, which is the bare minimum (actually used by MS in the MDF floppy format ), and (ii) the maximum, since BPB-0x11 is a word ( which, in principle, can have values ranging from 0 to 65,535) and directory pages must be sector sized, considering the last multiple of 512 that can be used is 65,024 and each entry 32 bytes, should be a huge 2,032 entries. That means it ranges from 16 to 2,032 entries.

Link to comment
Share on other sites

As for the number of entries in the root directory, my guess is: (i) it must exist: so giving it just one sector means 16 entries, which is the bare minimum (actually used by MS in the MDF floppy format ), and (ii) the maximum, since BPB-0x11 is a word ( which, in principle, can have values ranging from 0 to 65,535) and directory pages must be sector sized, considering the last multiple of 512 that can be used is 65,024 and each entry 32 bytes, should be a huge 2,032 entries. That means it ranges from 16 to 2,032 entries.

Sure :), but "normally" ( "normally" means *normally*, still well in the YMMV range :ph34r:;)) they are, as said, 224 on floppy and 512 on hard disk.

Any reason why you used 272?

I think 4078 is the right max value.

With all due respect for Wikipedia :), I like to have more "specialized" sources for info ;):

http://www.forensicswiki.org/wiki/FAT

(though even there it seems to me there is quite a bit of misinformation)

FAT12

1 0x000 (Free Cluster)

1 0x001 (Reserved Cluster)

4078 0x002 - 0xFEF (Used cluster; value points to next cluster) (as in FEF-2=4079-2=4077+1=4078

7 0xFF0 - 0xFF6 (Reserved values)

1 0xFF7 (Bad cluster)

8 0xFF8 - 0xFFF (Last cluster in file)

---------

4096

FAT16

1 0x0000 (Free Cluster)

1 0x0001 (Reserved Cluster)

65518 0x0002 - 0xFFEF (Used cluster; value points to next cluster)(as in FFEF-2=65519-2=65517+1=65518

7 0xFFF0 - 0xFFF6 (Reserved values)

1 0xFFF7 (Bad cluster)

8 0xFFF8 - 0xFFFF (Last cluster in file)

---------

65536

So, FAT16 should be 65518.

About this:

(not so random as it must be a multiple of 512 and cannot exceed 32 kiB)

I am not so sure, the "old" (but as we have seen for the El-Torito thingy it might be a "perceived" rule, rather than a "real" one ) it had to be a a power of 2, like:

512 = 512*2^0

1024=512*2^1

2048=512*2^2

4096=512*2^3

....

32768=512*2^6

And we also have the non-standard 64 Kb clusters possible on NT/XP (at least for FAT16) ......

http://support.microsoft.com/kb/140365

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

I'm convinced 4079, meaning 4078 addressable clusters plus 1 [cluster] for the fs [= filesystem] is the safest choice for FAT-12.
I think 4078 is the right max value.

Since the filesystem resides outside itself, we're saying the exact same thing. We need 12 sectors for each FAT-12, plus 1 for the boot sector (or PBR) plus (at least) 1 for the root directory. That means 12 +12 + 1 +1 = 26 sectors used by the filesystem (and which cannot be addressed using the filesystem itself), if one is satisfied with just 16 root directory entries. So here, instead of just one, I'd use 7, which would result in a total of 32 sectors for the filesystem, and 112 root directory entries. Or, if I though 112 too little, then use 7 + 32 = 39, just to keep to full clusters, and it would then mean 624 root directory entries. That's my way of doing it. As I said before, here, YMMV.

Any reason why you used 272?

Yes. My 36 MiB image has 1 boot sector and 7 sectors-per-fat, so 1 + 7 + 7 = 15 sectors.

As I decided to have a full cluster outside the filesystem, to contain the filesystem's structures, 32 - 15 = 17 sectors.

Now, (17 sectors * 512 bytes-per-sector) / 32 bytes-per-entry = 272 entries.

Link to comment
Share on other sites

Any reason why you used 272?

Yes. My 36 MiB image has 1 boot sector and 7 sectors-per-fat, so 1 + 7 + 7 = 15 sectors.

As I decided to have a full cluster outside the filesystem, to contain the filesystem's structures, 32 - 15 = 17 sectors.

Now, (17 sectors * 512 bytes-per-sector) / 32 bytes-per-entry = 272 entries.

Nice logic. :thumbup

Basically it "fills up to the brim" the space between the end of FAT table(s) and next "cluster boundary".

I like it. :)

We are going to misunderstand each other if we use different terminology :ph34r:.

To me the filesystem is the WHOLE thing.

You seem like calling "filesystem" what I call "filesystem structures".

I.e. in my view a filesystems spans over the whole volume, and contains:

  1. filesystems structures (including the ROOT entries)
  2. actual directories and files

You will agree that something that resides outside of itself doesn't sound really "right" :angel

jaclaz

P.S.: Version 3 attached:

  • Tentative support for "Root entries optimization" added
  • Set cluster limits to <4079 ;) and <65519

EDIT: Attachment removed see a few posts below for version 04

Edited by jaclaz
Link to comment
Share on other sites

Thank you for the warm welcome, Dencorso! I missed you all too.

Since I got drowned in a sea of documentation following the links kindly posted throughout this topic, I'll be spending a fair amount of time studying the available information before coming up with a usable version of the BootMaker tool. I also intend to make it translatable so it could be used widely even by non-English speaking people, being able to display labels as they see fit (to avoid issues such as hidden vs before).

So if you don't see me posting here, don't think I'm AWOL. ;) Will keep reading new posts.

Link to comment
Share on other sites

We are going to misunderstand each other if we use different terminology :ph34r:.

To me the filesystem is the WHOLE thing.

You seem like calling "filesystem" what I call "filesystem structures".

I.e. in my view a filesystems spans over the whole volume, and contains:

  1. filesystems structures (including the ROOT entries)
  2. actual directories and files

You will agree that something that resides outside of itself doesn't sound really "right" :angel

Well, jaclaz, for the sake of agreement and common terminology I'm willing to accept a filesystem is something that can be divided in two parts:

A (i) System Area and a (ii) Data Area

The System Area comprises the Boot Sector, the FATs and the Root Directory (for FAT-12/16),

while the Data Area comprises the actual files, the sub-directories and (just for FAT-32) the Root Directory.

(adapting what's stated in Section 6.1.4 p. 5 of ECMA-107, where that statement refers to what they call "Flexible Disk Cartridge", a.k.a. floppy disk).

I think this isn't the right place for us to philosophize on the ontological question of what a filesystem actually *is*. :P

That said, I cannot avoid thinking that if one were a file inside the filesystem, the *only* way one can actually access the System Area is by taking the Red Pill. :D

Now, since we've collected some links to standards already in this thread, I'll add some more, just for the record:

MS FAT (FAT-32 Specification): v. 1.03 (2000) and v. 1.02 (1999); ECMA-107 (FAT 12/16) and ECMA-119 (=ISO 9660).

Link to comment
Share on other sites

Just couldn't help it... First alpha of BootMaker is so incomplete it makes me ashamed for ever releasing it. So I put a little bit of elbow grease in it and got to a more acceptable version. Please note it's still in the viewer phase and the File system selector is not yet functional. The Save buttons have been temporarily disabled to avoid any misleading. The Code viewer will eventually become an editor (hopefully); for now it doesn't respond to user input, save for the right side where code can be copied from.

Oh and the acronym was wrong in v0.0.0.1: it's BMF, not BFM. Sorry! :blushing: Now it's fixed. Enjoy!

(and now I'm going to sleep; it's past 6 AM)

BMF 0.0.0.2.exe

Link to comment
Share on other sites

Just couldn't help it... First alpha of BootMaker is so incomplete it makes me ashamed for ever releasing it. So I put a little bit of elbow grease in it and got to a more acceptable version. Please note it's still in the viewer phase and the File system selector is not yet functional. The Save buttons have been temporarily disabled to avoid any misleading. The Code viewer will eventually become an editor (hopefully); for now it doesn't respond to user input, save for the right side where code can be copied from.

Oh and the acronym was wrong in v0.0.0.1: it's BMF, not BFM. Sorry! :blushing: Now it's fixed. Enjoy!

(and now I'm going to sleep; it's past 6 AM)

NICE work! :thumbup.

As said it's a good thing that the Filesystem selector doesn't work, since it will (when it will be finished :)) seemingly select BOOT CODE, instead. :whistle:

I think this isn't the right place for us to philosophize on the ontological question of what a filesystem actually *is*. :P

No need to pose ourselves this kind of questions :), I am only trying to come to an agreement of some sort to make sure that SAME elements are called with tthe SAME name (or that a Rosetta's Stone of some sort is provided ;)), or, if you prefer, that other MSFN members that will read this thread or use the little apps/tools will have a less confusing experienced.

You know how I do like people taking the Red pill, but it should be their own choice, not be forced upon them by the lack of clearness in the tools/posts/instructions.

To add to the list of references:

http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html

Bytes Content

0-2 Jump to bootstrap (E.g. eb 3c 90; on i86: JMP 003E NOP.

One finds either eb xx 90, or e9 xx xx.

The position of the bootstrap varies.)

3-10 OEM name/version (E.g. "IBM 3.3", "IBM 20.0", "MSDOS5.0", "MSWIN4.0".

Various format utilities leave their own name, like "CH-FOR18".

Sometimes just garbage. Microsoft recommends "MSWIN4.1".)

/* BIOS Parameter Block starts here */

11-12 Number of bytes per sector (512)

Must be one of 512, 1024, 2048, 4096.

13 Number of sectors per cluster (1)

Must be one of 1, 2, 4, 8, 16, 32, 64, 128.

A cluster should have at most 32768 bytes. In rare cases 65536 is OK.

14-15 Number of reserved sectors (1)

FAT12 and FAT16 use 1. FAT32 uses 32.

16 Number of FAT copies (2)

17-18 Number of root directory entries (224)

0 for FAT32. 512 is recommended for FAT16.

19-20 Total number of sectors in the filesystem (2880)

(in case the partition is not FAT32 and smaller than 32 MB)

21 Media descriptor type (f0: 1.4 MB floppy, f8: hard disk; see below)

22-23 Number of sectors per FAT (9)

0 for FAT32.

24-25 Number of sectors per track (12)

26-27 Number of heads (2, for a double-sided diskette)

28-29 Number of hidden sectors (0)

Hidden sectors are sectors preceding the partition.

/* BIOS Parameter Block ends here */

30-509 Bootstrap

510-511 Signature 55 aa

On that page, the "Media descriptor byte" is interesting.

IBM defined the media descriptor byte as 11111red, where r is removable, e is eight sectors/track, d is double sided.

It seems like most of the values are/were checked by old versions of DOS, and I remember from here:

http://advancemame.sourceforge.net/doc-makebootfat.html

that the FF or 255 in FreeDOS means "auto-detect" AND that the actual "Drive Type" or "Media Type" needs to be correct.

What shall we do?

jaclaz

P.s.: Attached verion 04 with the above "Media descriptor byte" added tentatively and a couple more fixes.

REMOVED: se a couple posts below for new version

Edited by jaclaz
Link to comment
Share on other sites

Note that the quote from www.win.tue.nl must be read with due care. What you quoted is what they call "FAT-12 BPB", which is actually the original BPB. That one contains only the 16-bit number of sectors entry, so it'd be impossible to create any image bigger than 32 MiB (-1 byte) with that one. We already know, in fact this thread is full of attached demontrations, that we can use the Extended BPB (wich they misleadingly call "FAT-16 BPB") with FAT-12, and that's how our bigger floppy images are created. So, this would be the complete description of it (here all offsetes are in decimal and start from 0):

Bytes Content

0-2 Jump to bootstrap (E.g. eb 3c 90; on i86: JMP 003E NOP.

One finds either eb xx 90, or e9 xx xx.

The position of the bootstrap varies.)

3-10 OEM name/version (E.g. "IBM 3.3", "IBM 20.0", "MSDOS5.0", "MSWIN4.0".

Various format utilities leave their own name, like "CH-FOR18".

Sometimes just garbage. Microsoft recommends "MSWIN4.1".)

/* BIOS Parameter Block starts here */

11-12 Number of bytes per sector (512)

Must be one of 512, 1024, 2048, 4096.

13 Number of sectors per cluster (1)

Must be one of 1, 2, 4, 8, 16, 32, 64, 128.

A cluster should have at most 32768 bytes. In rare cases 65536 is OK.

14-15 Number of reserved sectors (1)

FAT12 and FAT16 use 1. FAT32 uses 32.

16 Number of FAT copies (2)

17-18 Number of root directory entries (224)

0 for FAT32. 512 is recommended for FAT16.

19-20 Total number of sectors in the filesystem (2880)

(in case the partition is not FAT32 and smaller than 32 MB)

21 Media descriptor type (f0: 1.4 MB floppy, f8: hard disk; see below)

22-23 Number of sectors per FAT (9)

0 for FAT32.

24-25 Number of sectors per track (12)

26-27 Number of heads (2, for a double-sided diskette)

28-31 Number of hidden sectors (0)

Hidden sectors are sectors preceding the partition.

32-35 Total number of sectors in the filesystem

(in case the total was not given in bytes 19-20)

In fact, for this to be valid, bytes 19-20 *must* be 0 (comment by dencorso)

36 Logical Drive Number (for use with INT 13, e.g. 0 or 0x80)

37 Reserved (Earlier: Current Head, the track containing the Boot Record)

Used by Windows NT: bit 0: need disk check; bit 1: need surface scan

38 Extended signature (0x29)

Indicates that the three following fields are present.

Windows NT recognizes either 0x28 or 0x29.

39-42 Serial number of partition

43-53 Volume label or "NO NAME "

54-61 Filesystem type (E.g. "FAT12 ", "FAT16 ", "FAT ", or all zero.)

/* BIOS Parameter Block ends here */

62-509 Bootstrap

510-511 Signature 55 aa

Of course, the above table is not really a quote, because it represents the merging of two different tables form the source. Also of course, this is also described on the already mentioned MS FAT-32 Specification v. 1.03 (2000), so what is most interesting are the additonal comments or details.

On that page, the "Media descriptor byte" is interesting.
IBM defined the media descriptor byte as 11111red, where r is removable, e is eight sectors/track, d is double sided.

It seems like most of the values are/were checked by old versions of DOS, and I remember from here:

http://advancemame.sourceforge.net/doc-makebootfat.html

that the FF or 255 in FreeDOS means "auto-detect" AND that the actual "Drive Type" or "Media Type" needs to be correct.

What shall we do?

I don't think you've got that right: to me it seems to refer to byte 0x24 = 36 which is the BIOS drive. Not the Media Type Byte. Read it again carefully:

-E, --drive DRIVE

Set the BIOS drive to setup in the FAT boot sector. Generally this value is ignored by boot sectors, with the exception of the FAT12 and FAT16 FreeDOS boot sectors that require the correct value or the value 255 to force auto detection.

Here are two other quite interesting references: SuperVinx (a great complement to the Starman's Pages) and...

J. de Boyne Pollard's FGA on OEM Names (which I'm sure you know, but not everybody is familiar with).

Link to comment
Share on other sites

I don't think you've got that right: to me it seems to refer to byte 0x24 = 36 which is the BIOS drive. Not the Media Type Byte. Read it again carefully:

Yes, most probably you are right, my memory is not as good as it was :(, I'll check and fix. :)

But the main issue I was trying to point out is that no "modern" floppy sizes use anything different from 240 and all hard disk partition/volumes use 248, so I was wondering if in the drop-down list any of the older values was to be included (as it is in current/latest) or if those "other values" should ONLY be coupled to the corresponding "oldish/smallish" floppy formats (and disappear from the drop down list used when "FREE" is selected). :unsure:

The quote from:

http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html

Was only to highlight (as it has been done :whisting:) TWO things:

Hidden sectors are sectors preceding the partition.
Bootstrap

still within my "obsession" :w00t: to try calling things with their names AND agree on a common terminology.

For the record, the J De Boyne Pollard's page you mentioned:

http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/volume-boot-block-oem-name-field.html

(guess why the suggested OEM string in the .xls is "IBM 2.0" ;)) are complemented by these other onee:

http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/bios-parameter-block.html

http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-filesystem-type.html

http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-fat-widths.html

These also contain some bits of info that may come of use.

The existence of 0x28 as an "alternative" to 0x29 is something I never suspected :blushing:

And this is aso fun/interesting:

http://homepage.ntlworld.com/jonathan.deboynepollard/Proposals/version-7-bpb.html

jaclaz

P.S.: Re: Disk number (or "Drive Number" (usual confusion on names.

You are of course right , it's there that the 255 gets a meaning in FreeDOS.

The thingy should be the same as the FreeDOS SYS parameter:

http://www.freedos.org/kernel/sys.txt

/B btdrv

Sets the BIOS boot drive # (in hex) stored within the boot sector.

So, we do know (from here and there :angel ) that 0 (0x00) means "A:" (or first floppy drive) and that 128 (0x80) means "C:" (or first hard disk).

But I cannot find - if not on makebootfat related things - any reference to the 255 as autodetect in FreeDOS.

There is this thread here:

http://osdir.com/ml/emulators.freedos.kernel/2004-09/msg00057.html

that seems to suggest that the 0xFF is a bad idea anyway, but cannot understand if the good guys resolved to leave it or remove it alltogether...

Attachment removed, see a few posts below for version 06.

Edited by jaclaz
Link to comment
Share on other sites

But the main issue I was trying to point out is that no "modern" floppy sizes use anything different from 240 and all hard disk partition/volumes use 248, so I was wondering if in the drop-down list any of the older values was to be included (as it is in current/latest) or if those "other values" should ONLY be coupled to the corresponding "oldish/smallish" floppy formats (and disappear from the drop down list used when "FREE" is selected). :unsure:

The Table below is quoted from Thom Hogan's "The Programmer's PC Sourcebook", 2nd. ed., Microsoft Press, 1991 (ISBN 1-55615-321-X) Section 2, p. 26.

post-134642-0-76183400-1312326599_thumb.

IMO, it's the most autoritative offical source for this particular info. So I think we sould, for our purposes, adopt it as the standard reference, and use the media types as described in it, and solely for those formats. In all other cases I do favor 0xF8 for HDD and 0xF0 for all formats >= "1.44 MB" (= 1440 kiB, that is 1.41 MiB, unformatted and 1.39 MiB formatted), which, BTW, is the common pratice, so, by now, a de-facto standard.

BTW, attached is a list of all the formats I've ever heard about, for 5.25" and 3.5" floppies, just for the record.

FDFORLST.7z

Link to comment
Share on other sites

BTW, attached is a list of all the formats I've ever heard about, for 5.25" and 3.5" floppies, just for the record.

Thanks. :)

They contain what I needed, "original" ROOT directory entries for the various formats.

I'll check and add this info.

BTW, some (not so loosely connected) experiment:

http://reboot.pro/15123/

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

Some BIOSes (and the one for the Asus A7V600-X is a case-in-point) when set to boot an "USB ZipDisk" will boot a pendrive having an MBR and exactly one partition, regardless of if that partition is active or not, as A: (and, of course, will do so also with a real USB ZipDisk). After the device is booted all sectors preceeding the Partition Boot Record (PBR = the Boot Sector of the given Partition) will be unaccessible. It seems that those BIOSes use the MBR to locate the PBR and then will set it as LBA 0, thus rendering the preceeding sectors unavailable.

So this creates problems to use how a device mounts at boot as a criterion to define floppy-like and HDD-like. I prefer the presence of the MBR makes a device HDD-like and its absence makes it floppy-like, regardless of the way it can boot, for the above reason.

That usage does not conflict with my interpretation of Floppy-Like. There will still be limitations on usage such as CHS only access. Unmodified DOS will not support LBA on an A: or B: Drive.

I will withdraw the following comment as you have disproven it.

I will agree that a Drive that uses a MBR is HD-Like because it cannot be Mounted as A: or B:.

Your example makes the presence or absence of the MBR even less important.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...