MacOS – FAT16 disk refuses to mount in Mountain Lion

disk-utilitymacosmount

I've recently resumed a small OS-from-scratch-in-Assembly project I started several months ago in Lion. Part of the project involves compiling a binary file with NASM (the one that is pre-included), then creating a disk image based on that binary. The important point comes from the fact that the binary is written to the first sector of the image to be bootable from other hardware (the binary is compiled with a FAT16 BPB), which I test with VirtualBox.

Unfortunately, whenever I compile and try to mount the image in Mountain Lion, I get a dialog box that says, "The following disk couldn't be opened: boot.img — no mountable filesystems". I figured this was some oddity in my code, so I made a blank FAT16 disk image with Disk Utility, then compared my disk with the one created in a hex editor, then modified my code accordingly. Unfortunately, while it did manage to mount afterwards, my code no longer worked after making said changes.

So, knowing that I managed to successfully compile the code before (and hadn't touched it since recently), I popped into Time Machine and pulled my old working directory out. I tested the image in VirtualBox, and it works. However, I get the same mounting error. I found this very peculiar, so I copied the disk image to a physical drive, plugged it in to an old Ubuntu box, and it did, in fact, mount. I even sent the disk image to a friend (who is still running the latest version of Lion), and he was able to mount the disk image.

TL;DR: Why does a FAT16 disk image I have properly mount in Lion, but not in Mountain Lion? I tried mounting by trying open boot.img, hdid boot.img, mount boot.img some_folder, and mount -t msdos boot.img some_folder, none of which worked. I've attached the disk image in question via Droplr.

Best Answer

I eventually got the disk to mount whilst retaining compatibility with my bootloader. For anyone wondering, the compatibility conflict was in the FAT BPB (BIOS parameter block). Basically, the BPB has a field for specifying how many sectors compose a FAT cluster, where I manually supplied a value of 1. However, changing this to 4 fixed the issue. For more information on the BPB, you can see this reference page (you want to look at byte 13).

For anyone stumbling upon this answer randomly, this basically means that some older disks (such as floppy disks copied by dd) may not be able to be mounted by OS X Mountain Lion any longer. This is just a hypothesis based on observations of my own project, but hopefully this helps someone else running into this far-fetched issue.