Page 1 of 1

Formatting fat12 floppy image in OS X

Posted: Wed Jan 07, 2015 5:36 pm
by bubach
I'm trying to get my environment set up for OS X. My coding was all done in Windows before, so now I'm working on getting scripts in order to make a floppy disk image out of my assembled sources.

Part of my little shell script looks like this

Code: Select all

    #Format image in MSDOS format and mount it
    DISKNAME=`hdiutil attach -nomount bos.img`
    diskutil eraseVolume MS-DOS BOS $DISKNAME
This all works fine... Except. It uses what I suspect is HDD like values for the FAT12 BPB.
/dev/rdisk1: 2829 sectors in 2829 FAT12 clusters (512 bytes/cluster)
bps=512 spc=1 res=1 nft=2 rde=512 sec=2880 mid=0xf0 spf=9 spt=32 hds=16 hid=0 drv=0x00
So..
RDE (root directory size) of 512 instead of standard floppy 224
SPT(sectors per track) 32 instead of standard 18.
HDS(heads) 16 instead of standard 2

Is there something I can do for diskutil to treat this as a floppy and not harddrive? Or any other tips for working with floppy images under OS X?

Re: Formatting fat12 floppy image in OS X

Posted: Thu Jan 08, 2015 1:13 am
by Combuster
I would always recommend mtools for being an OS-independent tool for do the job. I'm also guessing that (knowing Apple) getting access to a mac and personally reading the documentation is going to be little more than duplicated effort.

Re: Formatting fat12 floppy image in OS X

Posted: Thu Jan 08, 2015 10:42 am
by bubach
While I would prefer to do this with built in tools, I can understand if it's not possible. I've already tried mkdosfs-osx package which didn't work out well, but "mtools" was news to me. Homebrew could fetch it without problems, and mformat seems to do excatly what I need. Thank you!

Re: Formatting fat12 floppy image in OS X

Posted: Sun Jan 25, 2015 9:22 pm
by bashcommando
bubach wrote:While I would prefer to do this with built in tools, I can understand if it's not possible. I've already tried mkdosfs-osx package which didn't work out well, but "mtools" was news to me. Homebrew could fetch it without problems, and mformat seems to do excatly what I need. Thank you!
Okay, forgive me if I am thinking a bit too much like Linux but here we go: If I am correct there should be a shell command called mkfs.fat. It works like mkfs.fat [device/file] [sectors], now be careful because it is kind of like dd. It will overwrite everything on the drive. If you are writing it to a file then make sure to specify sector size or it could fill your hard drive. :cry: According to MikeOS it creates a FAT12 system. The exact command used was:

Code: Select all

mkdosfs disk_images/mikeos.flp 1440
I might be off with the directory structure, but it still works. Hope I helped!