Alternative floppy disk sector sizes
Alternative floppy disk sector sizes
Now the most interesting part. Has anyone booted a 3.5-inch floppy that is formatted using e.g. 1024 bytes per sector? Was the first sector loaded at 0x07C00 by BIOS, and how many bytes? At some point I am going to test this but has someone done this? I know there might be compatibility problems even if it worked on some computers. However, I would like to test the robustness of my boot loader and this is an interesting experiment.
Re: Alternative floppy disk sector sizes
Microsoft says that MS-DOS supports 8-inch floppies using different sector sizes (128 and 1024) so it seems that the 512-byte size is not hard-wired in software (MS-DOS). I guess those floppies are quite rare by now. The current FAT specification says that valid "bytes per sector" values are 512, 1024, 2048 and 4096. Has anyone really seen a FAT file system using other values than 512?
-
- Member
- Posts: 5590
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Alternative floppy disk sector sizes
Microsoft supports FAT32 with 4096-byte sectors, at least for the EFI system partition.Antti wrote:Has anyone really seen a FAT file system using other values than 512?
Re: Alternative floppy disk sector sizes
Hi,
However; don't forget that each track is separate. Nothing prevents you from using 512 byte sectors for the first track (just to make BIOS happy) and then using larger sectors for all the other tracks.
Here's some maths (for 1440 KiB floppies):
We know that (by reducing the size of the gap between floppies) you can squeeze 21 (512 byte) sectors on a track. Each sector has about 210 bytes of mess before and after it (address marks, sync. fields, CRC, etc), plus a "GAP 3" length between them of about 25 bytes. This means "21 * (210 + 512 + 25) bytes" is probably the limit for the unformatted capacity of a track. That's about 15.3 KiB.
Now we can work backwards and calculate sectors per track for various sector sizes, using "sectors = 15687 / (210 + bytes_per_sector + 25)":
This means the best case would be 160 tracks at 12 KiB per track, or 1920 KiB of disk space. With one track of 21 normal 512 byte sectors (to keep BIOS happy) and 159 of the 12 KiB tracks you'd end up with 1918.5 KiB of disk space.
Note: You can't have a mixture of different sector sizes on the same track. The sector size that matters is given in the format command itself, and the "sector size" field in the data that the format command writes to disk doesn't effect the size of sectors created when formatting.
Of course all of this is only theory. In practice, it should work for real floppy drives and real floppy controllers; but won't work with things like Bochs; and may or may not work with USB floppy controllers, "floppy emulation El Torito" CD, etc.
Cheers,
Brendan
I haven't done it. As far as I know; BIOS is also supposed to work with "512 bytes or larger" sector sizes (and not smaller); but BIOS is also only supposed to load 512 bytes regardless of the sector size. I don't know if this is actually supported properly in practice, but it's not something I'd want to rely on (I'd assume that an excessively large number of systems fail to support it properly, simply because nobody ever tested it).Antti wrote:Now the most interesting part. Has anyone booted a 3.5-inch floppy that is formatted using e.g. 1024 bytes per sector? Was the first sector loaded at 0x07C00 by BIOS, and how many bytes? At some point I am going to test this but has someone done this? I know there might be compatibility problems even if it worked on some computers. However, I would like to test the robustness of my boot loader and this is an interesting experiment.
However; don't forget that each track is separate. Nothing prevents you from using 512 byte sectors for the first track (just to make BIOS happy) and then using larger sectors for all the other tracks.
Here's some maths (for 1440 KiB floppies):
We know that (by reducing the size of the gap between floppies) you can squeeze 21 (512 byte) sectors on a track. Each sector has about 210 bytes of mess before and after it (address marks, sync. fields, CRC, etc), plus a "GAP 3" length between them of about 25 bytes. This means "21 * (210 + 512 + 25) bytes" is probably the limit for the unformatted capacity of a track. That's about 15.3 KiB.
Now we can work backwards and calculate sectors per track for various sector sizes, using "sectors = 15687 / (210 + bytes_per_sector + 25)":
- 1024 byte sectors = 12 sectors per track = 12 KiB per track
- 2048 byte sectors = 6 sectors per track = 12 KiB per track
- 4096 byte sectors = 3 sectors per track = 12 KiB per track
- 8192 byte sectors = 1 sector per track = 8 KiB per track
- 16384 byte sectors = 0 sector per track = 0 KiB per track
This means the best case would be 160 tracks at 12 KiB per track, or 1920 KiB of disk space. With one track of 21 normal 512 byte sectors (to keep BIOS happy) and 159 of the 12 KiB tracks you'd end up with 1918.5 KiB of disk space.
Note: You can't have a mixture of different sector sizes on the same track. The sector size that matters is given in the format command itself, and the "sector size" field in the data that the format command writes to disk doesn't effect the size of sectors created when formatting.
Of course all of this is only theory. In practice, it should work for real floppy drives and real floppy controllers; but won't work with things like Bochs; and may or may not work with USB floppy controllers, "floppy emulation El Torito" CD, etc.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Alternative floppy disk sector sizes
Me neither. My "official" floppy disk images are very conservative, for example:Brendan wrote:but it's not something I'd want to rely on
Code: Select all
"1.44 MB" disk image (source: Microsoft)
# of Heads (Sides) 2
# of Cyls (Tracks) 80
# of Sectors/Track 18
# of Free Sectors 2847
# Sectors/Cluster 1
# Sectors/FAT 9
# of FAT Copies 2
# of Root Dir Sectors 14
# Reserved Sectors 1
# of Hidden Sectors 0
# of Bytes/Sector 512
# of Bytes/Cluster 512
# Root Dir Entries 224
Media Descriptor F0
A second side note, I am tempted to use "reserved sectors" because that would solve many problems. Maybe I will change my mind and start using it. But not yet.
I have even left the partition table area unused (all zeros) although there are no partitions. That disk image is unmistakably a floppy disk image. If, for some reason, the table area is interpreted...
I will write another reply post later.
Re: Alternative floppy disk sector sizes
Another interesting topic is the Diskette Parameter Table (pointed by the interrupt vector 0x1E). My floppy boot sector makes a copy of the table and checks and modifies the "bytes per sector" and "sectors per track". I guess the latter has been important for multi-sector reads. The former, "bytes per sector" (2 = 512, 3 = 1024, ...), is not very clear to me. I modify both of them according to the values found in the BPB but I am not sure if it makes sense to modify the "bytes per sector". Note that I only use the modified table if there are changes. For most systems, the interrupt vector 0x1E will not be modified. If it is modified, the "INT 0x13, AH = 0x00" is called.
If the "bytes per sector" is important for reads, then the BIOS would not be able to load the first 1024 byte sector because the default table will have it set to 512.
If the "bytes per sector" is important for reads, then the BIOS would not be able to load the first 1024 byte sector because the default table will have it set to 512.
-
- Member
- Posts: 5590
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Alternative floppy disk sector sizes
It's true that the format track command can only create sectors of uniform size, but it's still possible to mix sector sizes in a single track.Brendan wrote:Note: You can't have a mixture of different sector sizes on the same track. The sector size that matters is given in the format command itself, and the "sector size" field in the data that the format command writes to disk doesn't effect the size of sectors created when formatting.
Re: Alternative floppy disk sector sizes
In general, I am not very into increasing the data capacity. Even at its best, the floppy disk capacity is quite limited no matter what we do. I could even go to the opposite direction, i.e. decreasing the data capacity if it gives me more reliability. Of course, all this discussion about a little bit hack-ish methods to do things differently is going to make things less reliable in practice. However, that 21-sector track is not a very hack-ish hack if Microsoft thought it is realiable enough for releasing software.Brendan wrote:We know that (by reducing the size of the gap between floppies) you can squeeze 21 (512 byte) sectors on a track.
For me this all about making good boot code. Having an unusually formatted floppy is just an extra feature. And having this discussion is interesting, of course.
Re: Alternative floppy disk sector sizes
A joke. I took two floppies and reduced the gap between them. How this is supposed to help?Brendan wrote:by reducing the size of the gap between floppies
All right, it is Friday...
Re: Alternative floppy disk sector sizes
I tested it but only on one computer. The BIOS interrupt for reading sectors (INT 0x13, AH=0x02) returned error 0x04 (sector not found/read error) if the Diskette Paremeter Table sector size (offset 3, 2=512, 3=1024) does not match .Antti wrote:At some point I am going to test this
If it does match, then it works. It really reads 1024 bytes. Of course, this is far from practical. I need to boot computer with a normal floppy, copy and patch the table, and then warm reboot or chain load the 1024-sector-formatted floppy.
-
- Member
- Posts: 5590
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Alternative floppy disk sector sizes
Put 512-byte sectors in the first track (or cylinder) and you can still make it bootable. Then you can put just about anything in the rest of the disk.Antti wrote:I need to boot computer with a normal floppy, copy and patch the table, and then warm reboot or chain load the 1024-sector-formatted floppy.
Re: Alternative floppy disk sector sizes
I am not sure but it should be possible to format the track like this:Octocontrabass wrote:Put 512-byte sectors in the first track (or cylinder) and you can still make it bootable.
Code: Select all
Command settings for track 1:
_____________________________________________
| |
| Bytes/sector 1024 (3) |
| Sectors/cylinder 9 |
| Gap ? |
| Filter byte ? |
|_____________________________________________|
Sector marks for track 1:
_____________________________________________
| |
| Cyl Head Sector Bytes/sector |
| 0 0 1 512 |
| 0 0 2 1024 |
| 0 0 3 1024 |
| 0 0 4 1024 |
| 0 0 5 1024 |
| 0 0 6 1024 |
| 0 0 7 1024 |
| 0 0 8 1024 |
| 0 0 9 1024 |
|_____________________________________________|
Note 1: layout is not interleaved.