Formatting fat12 floppy image in OS X

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Formatting fat12 floppy image in OS X

Post 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?
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Formatting fat12 floppy image in OS X

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: Formatting fat12 floppy image in OS X

Post 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!
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
bashcommando
Member
Member
Posts: 62
Joined: Mon Jan 06, 2014 4:23 pm

Re: Formatting fat12 floppy image in OS X

Post 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!
Building an operating system is like building an airplane, you don't want it to crash.
Post Reply