mac68k-disk creates and edits floppy disk images for the first Macs: MFS, the
400K format of the Macintosh 128K and 512K (64K ROM), and HFS, the format of the
800K floppy, the Mac Plus and everything after it (400K, 800K and 1440K images). It
puts files on a disk, lists them, copies them back and deletes them - one small C
program, no dependencies. The images work in Mini vMac, Basilisk II and other
emulators, and on real hardware via a floppy emulator or a disk writer.
For a long time hfsutils was the tool for this, but it has been removed from Debian 13
and it never handled 400K MFS disks. mac68k-disk covers both formats with a handful of
commands. It is also the natural companion of mac68k-asm, the 68k assembler
toolchain that writes applications as MacBinary files.
git clone https://github.com/bircher988/mac68k-disk.git
cd mac68k-disk
make # needs only a C compiler and make
./mac68k-disk new Apps.dsk # an empty 400K MFS disk named "Apps"
./mac68k-disk add Apps.dsk Hello.bin # a MacBinary file from anywhere
./mac68k-disk ls -l Apps.dsk
Boot your System disk in the emulator with Apps.dsk as the second disk (for Mini
vMac: minivmac System.dsk Apps.dsk, or drag the image onto its window); the Finder
shows the disk and places the new icons itself.
macOS (Homebrew). The formula lives in the tap bircher988/tap and builds from source:
brew install bircher988/tap/mac68k-disk
Debian / Ubuntu / Raspberry Pi OS. Every
release has a .deb for arm64
(Raspberry Pi) and amd64 (PC). Download it and install it with apt:
wget https://github.com/bircher988/mac68k-disk/releases/download/v1.2.2/mac68k-disk_1.2.2_arm64.deb
sudo apt install ./mac68k-disk_1.2.2_arm64.deb # or _amd64.deb on a PC
To build the package yourself: packaging/debian/build-deb.sh.
From source (Linux, macOS, any Unix). make and then sudo make install puts the
binary into /usr/local/bin; make uninstall removes it again. PREFIX=... changes
the location.
In every case mac68k-disk version shows what is installed.
mac68k-disk new <image> [--hfs] [--size 400k|800k|1440k] [--name <volume name>] [--system <startup disk>]
mac68k-disk add <image> <file>... [--name <mac name>] [--type TTTT --creator CCCC] [--rsrc <file>] [-f]
mac68k-disk ls <image> [-l] [-R] [<folder>]
mac68k-disk get <image> <mac name> [-o <out>] [--data|--rsrc]
mac68k-disk rm <image> <mac name>
mac68k-disk mkdir <image> <folder>
mac68k-disk info <image>
mac68k-disk startup <image> [<application>] [-f]
mac68k-disk version | help
new creates an empty disk: MFS 400K by default, which every 68k Mac can read; with
--hfs an HFS disk of 800K (--size 400k, 800k or 1440k). The volume name is the
image file name without its extension unless --name gives one (at most 27
characters). New disks have no boot blocks - they are data disks. new never
overwrites an existing file.
With --system <startup disk> the new disk is a startup disk: it gets the boot blocks
of the given disk and its system files in a new "System Folder" - the contents of that
disk's System Folder or, if it has none, every file on it except the applications.
Add your programs and the Mac boots from it into a tidy desktop:
mac68k-disk new Programs.dsk --system System.dsk # "Programs": System Folder, nothing else
mac68k-disk add Programs.dsk Hello.bin Clock.bin
On HFS (--hfs --system ...) the folder is blessed, as the Mac needs it.
add copies files onto the disk. Each <file> is either a MacBinary file (versions
I, II and III, recognised by their header - the CRC for II and III, the zero fields and
exact fork lengths for I) or anything else, which becomes the data fork of a new file
with type and creator ????. The Mac name is the one stored in the MacBinary header,
or the file name without a .bin extension.
| Option | Effect |
|---|---|
--name <mac name> |
the name on the disk (one file only); it may contain a folder path, Games:Hello, and a name ending in : puts all files into that folder |
--type TTTT --creator CCCC |
set file type and creator (four characters each; either one alone works too) |
--rsrc <file> |
the resource fork, as a raw file (one file only; with --name and without a data file it makes a file that only has a resource fork) |
-f |
replace a file of the same name (otherwise that is an error) |
Files keep their Finder flags (bundle, invisible, ...), except the ones that describe their place on another disk: "on desktop", "inited" (icon placed), "changed" and "busy" are cleared, the icon position and window are set to zero, so the Finder places the icon itself the first time it opens the disk. Creation and modification dates come from the MacBinary header, or are "now" for raw files.
ls lists the root folder or the given folder, folders with a trailing :. -l
adds type, creator, the sizes of data and resource fork and the modification date;
-R lists all folders below, with their paths.
$ mac68k-disk ls -lR System.dsk
TYPE CREA DATA RSRC MODIFIED NAME
APPL ???? 0 516 2026-09-25 09:16 Hello
folder 2 items 2026-09-25 00:28 System Folder:
FNDR MACS 0 109195 1991-08-30 12:12 System Folder:Finder
ZSYS MACS 860 525073 1991-12-16 16:17 System Folder:System
get copies a file off the disk as a MacBinary II file <name>.bin in the current
directory, or -o names the output; --data or --rsrc write just that fork, as it
is; -o - writes to standard output.
rm deletes a file, or an empty folder. mkdir creates a folder - on MFS a folder of the Finder (see below). info shows format, volume name, allocation blocks, free space, number of files and folders, dates and whether the disk has boot blocks and a System Folder.
startup shows which application a startup disk opens when the Mac boots from it, and with a name sets it. Normally that is the Finder; with your program, the Mac boots straight into it - handy for tests in an emulator and for single-purpose disks:
cp System.dsk Test.dsk # a copy of a startup disk
mac68k-disk add Test.dsk out/Game.bin
mac68k-disk startup Test.dsk Game # boots into Game; "Finder" restores it
The name goes into the boot blocks (bbHelloName, at most 15 characters), and the
file must be on the disk. On HFS the application can be in any folder
(startup Test.dsk "Games:Play"): its folder is recorded in the volume header, where
the Mac looks for it - without that entry an application at the top level of the disk
is not found and the Finder starts instead. A plain name is looked for at the top
level and then in the System Folder. On MFS, a disk without real folders, the name is
enough. -f sets a name that is not there; info and startup say when the
application is not where the Mac looks for it.
Names on the disk are Mac Roman. Names on the command line are UTF-8 and are converted
("Über", "Café"); other bytes are taken as they are. Names are compared the way the
Mac does it, without regard to case: get Apps.dsk hello finds Hello. A file or
folder name has at most 31 characters on HFS and 63 on MFS, and no :. : separates
folders; a leading : is allowed (:Games:Hello). On MFS a name is unique on the
whole disk, whatever folder the file is in, so a plain name finds it anywhere:
get Programs.dsk System works as well as get Programs.dsk "System Folder:System".
Errors name the image and the problem, for example
Apps.dsk: disk full (Big File needs 300 KB, 120 KB free). Every command reads the
whole image, makes its changes in memory and writes the image back through a
temporary file that is renamed over the original, so a failed command - a full disk,
a duplicate name, a damaged image - never changes the image at all.
The images are raw sector images (.dsk, .img, ...): 512-byte sectors, no header,
400K = 409600 bytes, 800K = 819200, 1440K = 1474560. This is what Mini vMac, Basilisk II
and most floppy emulators use.
DiskCopy 4.2 images work as well, for every command - the container most old Mac
software comes in (.image, .img, sometimes .dmg): an 84-byte header in front of
the sectors, often 12 bytes of tag data per sector behind them. info names the format.
After a change both checksums in the header are set, so that DiskCopy accepts the image,
and the tags of the sectors that changed are cleared; the image stays a DiskCopy image.
new always makes a raw image. The compressed .dmg images of Mac OS X are another
format and are not supported; partitioned hard-disk images and HFS+ volumes are refused
with a clear message.
MFS (Inside Macintosh II, File Manager). New 400K volumes have Apple's geometry: the master directory block and the 12-bit block map in blocks 2-3, a 12-block file directory, 391 allocation blocks of 1 KB. Files are allocated contiguously where possible; directory entries never cross a block boundary.
MFS has no folders of its own - they are an illusion of the Finder, and mac68k-disk
reads and writes them the way the Finder 5.3 does: the invisible file DeskTop (type
FNDR, creator ERIK) holds one FOBJ resource per folder (its ID is the folder
number; the name, the parent folder, the icon position and the window are in it), plus
FOBJ 0 for the disk and STR 0 ("Finder 1.0"); every file names its folder in the
fdFldr field of its Finder information. New folders get the next free place on the
Finder's 64-pixel icon grid (the Finder places new files itself, but not folders).
Later Finders record a folder with four more bytes in front of its name, and the first
Finders (the disks of 1984) with a shorter record that has the name only as the
resource's name; such folders are read just the same, files can be added to them, and
all kinds can stand in one DeskTop file. mkdir always writes the record of the
Finder 5.3 - the Finder 1.1g of 1984 shows and opens such a folder too.
Removing the DeskTop file removes the folders, as in the Finder; the files stay. The
layout is documented at the top of src/mfs.c.
HFS. New volumes use the layout of Apple's disk initialization: the volume bitmap from sector 3, 512-byte allocation blocks, extents overflow and catalog file of 1/128 of the disk each, an alternate master directory block in the last-but-one sector. Changes read the whole catalog, apply the change and write the catalog back as a freshly packed B-tree (leaf nodes, index levels, node map, header) into the catalog file. When the catalog needs more room it grows: in place if the blocks behind it are free, else by another extent, else it moves into free space. Folder valences, the file and folder counts, the next catalog node ID, the free block count, the bitmap and the alternate MDB are kept consistent. New files are allocated contiguously, in at most three pieces per fork. Existing volumes made by Apple's system software or by other tools are edited in place: boot blocks, the System Folder, Finder information and all other records stay as they are.
The catalog keeps names in the Macintosh's case-insensitive order. mac68k-disk
follows the character ordering of Inside Macintosh I (International Utilities):
lowercase equal to uppercase, the non-breaking space with the space, typographic quotes
with the ASCII quote, accented letters of the original character set right after their
base letter. Existing records keep their order; only new ones are placed.
make test (needs python3) runs tests/run.sh: round trips on MFS and HFS disks
(MacBinary I, II and III, raw files, a file with only a resource fork, an empty file, a
300K file, --type/--creator/--rsrc), comparing name, type, creator, Finder flags
and both forks bit for bit; replace, remove and add again (the free space must come
back); folders on HFS and on MFS; startup disks made with new --system from MFS and
HFS disks, with and without a System Folder; 150 files and more in one folder, which forces a three-level catalog
B-tree and a catalog that grows and moves; 400K, 800K and 1440K HFS; error paths that
must leave the image unchanged; install and uninstall. After every change the image is
checked by tests/mactest.py, an independent structure checker for MFS and HFS (block
chains and bitmaps, B-tree links, key order, node maps, valences, counts, alternate
MDB; on MFS unique names and the Finder's folders: DeskTop resources, parents, item
counts, the folder of every file).
If hfsutils is installed, tests/oracle.sh also checks interoperability: images
written by mac68k-disk are read by hls/hcopy with identical content, images made
by hformat and hcopy (including files with extents overflow records) are read and
changed by mac68k-disk, and names with punctuation and accented letters added by
either tool are found by the other.
The images have also been checked on the machines themselves, in Mini vMac: a Mac Plus
with System 6.0.8 opens 400K MFS and 800K HFS disks written by mac68k-disk and runs
the applications on them, boots from a System disk that got a new file, and Apple's
Disk First Aid reports "No repair necessary" for disks with 150 to 270 files, folders
and a moved catalog; a Macintosh 512K with the 64K ROM (MFS only) runs applications from
a 400K disk made by mac68k-disk, and boots from a startup disk made with
new --system, with nested MFS folders: the Finder 5.3 shows them, opens them, and
after launching programs, shutting down and starting again there is no request to
repair the disk. tests/mactest.py accepts the DeskTop files the Finder itself wrote.
A Macintosh 128K with System 1.1 shows a file added to a folder of a 1984 disk, and a
folder made by mkdir on it. The startup application of an HFS disk was tried on a
Mac Plus with System 3.2 and with System 6.0.8: at the top level, in a folder and in
the System Folder.
- New files are stored in at most three pieces per fork;
mac68k-diskwrites no extents overflow records (it reads them, and removes them with the file). On a badly fragmented disk, adding a large file fails with a clear message. - A catalog that already has extents overflow records (large, fragmented hard-disk volumes) cannot grow; adding fails with "catalog full" when it is full.
- The order of names in the catalog is documented by Apple for ASCII and for the letter groups, not for the order among different accents on the same letter (for example "ä" and "ã") or for the backquote. Existing records are never reordered, but a new name that differs from an existing one in the same folder only there may be placed where the Mac does not expect it.
- New disks are not startup disks (no boot blocks). To make one, start from a copy of
an existing startup disk and add to it (
startupchooses what it opens). - MFS:
newmakes 400K volumes only; other MFS images can be read and changed. - Get Info comments in MacBinary files are ignored; file locking is not shown.
mac68k-disk is MIT-licensed, see LICENSE. It was written from Apple's documentation of
the file systems (Inside Macintosh) and contains no code from other disk tools.