MBR test

There is little to no actual documentation on the requirements or restrictions of extended partitions in a Legacy BIOS type MBR partitioning system. For example, the MBR at LBA 0 has up to four (4) partition entries, all four of them could be used.

When disks started to get a little larger, manufacturers started adding a partition type of 05, and then later 15, indicating an extended partition entry. This entry simply pointed to a sector, relative to the parent sector the entry is contained in, to another sector holding four (4) more entries.

Since we all know how this works, I won't get in to it too much. However, my concern is, what are the restrictions on how many of these entries can be used?

For example, a well known name-brand software company states that if an extended partition is used, there should only be two entries used in the MBR, one for a standard partition, and one as an extended partition type. Then one or more of the paritition entries of the extended partition may be used. However, if one of these new entries is an extended partition entry, it must again be one of the only two entries including a standard partition type. Also, any extended partition is actually embedded within a parent extended partition.

Is this a requirement, a restriction, or simply the way some guy chose to do it, and all the rest of us followed?

The only reasoning I can see to do it this way is that each extended partition's base LBA is relative to the partition table sector it resides in. Since all LBA's are 32-bits in these partition tables, with this technique of relativity, you can have disks larger than 32-bit sector counts as long as the software parsing them can handle more than 32 bits. As for extended partitions being embedded within their parent, this could be to protect them from code that doesn't recognize extended partitions.

However, what about all the rest of the entries? Can any entry be used, and if so, can any entry point to any number of extended partitions, nested as deep as you wish?

I say, yes. Absolutely. Therefore, my MBR code is able to parse up to 127 nested partition tables, and only the limit of 127 due to the fact that 128 * 512 = 65536, the 16-bit segment barrier.

So how do you test your MBR code and nested partition table entries? Well, you make an image with numerous tables and run it and see.

I created a small app that will create numerous partitions, each a single sector in size, and allow extended partitions, each also a single sector in size. Then I placed some code at each normal partition to print which partition is was when booted. Then I can easily add and removed partition entries, extended partition entries, and nested extended partition entries, marking any entry as active.

Here is a small image, again only about 10 sectors in size, with numerous entries and up to three (3) total nested extended partitions, and the source code to create the image. The partitions are hard coded in the source code itself, but with a little studying of the code, you can add and/or change the partitions as you see fit. I only have each partition a single sector in size because there is no need to have anything more when simply testing a MBR code.

The app will place your given mbr.bin file at the first of the image, then add specified regular and then extended partitions. If you run the app as is with your MBR.BIN file, then boot it, you should have "Loaded VBR at lba 7" printed to the screen. LBA 7 is actually in the MBR entry table, but your code might parse any extended partitions first. If your code prints any other LBA, prints anything else, or doesn't print anything at all, you might want to check your code.

Which reminds me, who says which entries should be checked for active first? Any in the MBR table first, then extended partitions, or should you take the first partition nest and go until you finally come back to the MBR without finding any active partitions until now?

One more thing, the code doesn't create valid partition table entries other than the BI, SI, and Base Sector fields, the only three fields needed by a MBR to parse them. However, if your code needs the other entries, Starting/Ending CHS entries, etc., you can easily add them.

The FYSOS Specification

As most of you probably know, documentation is a key to a good project, both for the end user and probably more importantly, for the developer. Therefore, I have started a specification sheet for my FYSOS project. It is to document the workings of the project. At the moment it is a very rough draft and only has the boot and loader documented. I will add more as time allows. Update: A complete re-write is in progress...

The Simple File System, source code

I have released the source code to an app that will create SFS images, adding files listed in a resource file. Please let me know if you find any errors and comments are welcome. Thank you.

The Simple File System, version rc02

Due to clarifications from the original author, I have made modifications and clarifications of my own.

The Simple File System, version rc01

Made a minor change from my previous specification. All block address fields, including the Beginning and End Block fields in the File Entry are relative to the start of the volume. Simplifies it slightly.

The Simple File System

As most of you know, I am quite fond of file systems and was shown the Simple File System (SFS) over at OSDev.org. I decided to adopt it in FYSOS but had to make a few small modifications and improvements.

I would appreciate any comments you might have, suggestions, and/or otherwise. Once I have it static, I will release some code that creates SFS file system images allowing you to add files to it.

Thank you.

Bootable Thumb Drive

I now have a bootable thumb drive image of FYSOS for testing purposes.

https://www.fysnet.net/zips/fysos.zip (1.85Meg)

I use RUFUS at http://rufus.akeo.ie to write the hd.img file to a thumb drive. Works on WinXP and above.

Thank you.

Contributing to the cause

I have been working on my USB book and need a few more USB devices for testing. I have tested quite a few but could always use more tests. If you have an old USB device somewhere, collecting dust, wasting space, etc., and wish to send it my way, I would be sure and include your name in the next edition, as I have with the previous contributors.

Thank you.

You can send them to:

Ben Lunt
321 Pinedale Rd, Box 875
Taylor AZ 85939-0875
USA

OS Testing

The other day I saw that my UHCI driver was acting up on a certain device so I decided to test it out. I grabbed six (older) computers out of storage and decided to see if it was the UHCI controller or the device that my code didn't like. Come to find out, it was both. After some testing, research, and much trial and error, I got it working much better on all six computers and three emulators (not to mention finding a quirk in Bochs and VirtualBox).

Anyway, since I still have these machines out, I thought I would offer them for testing if you will repay the favor. (Testing the whole machine, not just USB)

However, I do have a few small requirements.

  • Must be a 1.44Meg floppy image that I can write to a real floppy and
    boot from it
    *or*
  • Must be an image that I can write to a USB flash drive and boot from it.
    However, it must be a tested and tried bootable image for USB.
  • Must not try to install or (intentionally) write to any media other than the
    booted media, though it can read from installed IDEs, SATA, AHCI's, USB's, etc.

If you wish to, but not a requirement, just a favor for me testing yours, please try mine at:

https://www.fysnet.net/fysos/floppy.img

(https://www.fysnet.net/fysos.htm)

The first link is the (uncompressed) 1.44Meg floppy image ready for testing. I have not tried it with a bootable USB thumb drive (yet).

The booted OS will pretty much only detect all hardware and media, booting to a simple DOS like prompt. If you wish, you can type "gui" at the prompt and the GUI will start, though I currently only have a few items compiled in for testing.

While booting (at the blue screen), you may press F9 to stay in text mode (suggested for testing) or press F8 to choose a video mode. However, you must use a video mode to try the (minimal) GUI. (With this in mind, it will only boot from a Legacy BIOS machine. My UEFI boot is on the second URL above, though not updated to the new/fixed code)

After you have booted (or exited the GUI), please type "write_debug" at the A:\ prompt and the OS will write all my debug stuff to the disk. I would appreciate this DEBUG.TXT file.

Send me a link to your image with a little instruction and I will test it on these machines and let you know if I find anything.

Thank you.


Below is an image of four of the six mentioned machines. Each has various drive types, drive sizes, volume file system formats, UHCI, OHCI, EHCI (no xHCI, xHCI only on my Flagship and I won't test with it), PS/2 keyboard/Mouse, APIC, ACPI, IOAPIC, 3 1/2" floppy, etc.

As a side note, the machine on the far left, not part of the four standing, is an old 486DX with a 5 1/4" floppy with a whopping 8Meg of RAM.