Some Technical Information
Disk Jockey started as a fun endeavor to contribute a little to the community, but it soon became an unexpected deep dive into the inner workings of machines I’ve used for over thirty years, and then some.
The goal is to explore, by myself, and to build something useful without resorting to external resources. People much smarter than me have built similar things, often much more competently, but we have saying in Belgium: “Someone else’s experience is like a comb for a bald man”. Using other people’s stuff would mean I’d learn nothing.
So, here’s some stuff I’ve learned. So you too can have a bald man’s comb, I suppose.
Some concepts
I’ve found that there was some confusion of terms around disk images so, here’s a list of concepts with some clarifications as to what they are.
Image
An ordered set of bytes that mimics the structure of a physical medium such as a floppy disk, a hard drive, a CD-ROM.
Raw Image
An image where the bytes are in exactly the same order as they are on the physical medium it mimics.
Being an exact copy makes a raw image easy to go through and reason about (if you know what you’re doing, obviously) but it poses 2 main problems:
- It’s just a stream of bytes. It could be a song, an photo, an application or anything else. File extensions can be used to differentiate between file types (like “jpg” or “mp3”) but there’s very little preventing a user from changing a file extension and muddling everything up.
- It’s not space-efficient. If you create a raw image, everything is exactly as it is on the physical medium, including the vast expanses of empty or redundant space.
Image Wrapper
A scheme that takes the raw bytes of an image and adds information to it so that it can be better understood or transfered.
Image wrappers strive to solve the issues inherent to raw images: they provide information about the stream so there’s litle to no guesswork about it. This solves problem 1 above.
Also, some image wrappers can compress the byte stream and reclaim the wasted space. That’s for problem 2.
Examples of image wrappers on the classic Mac are the Disk Copy 4.2 format (which Disk Jockey understands) or the NDIF (Disk Copy 6) format (which Disk Jockey doesn’t). On the Apple II, there’s the 2MG (aka 2IMG) format (which Disk Jockey understands) and others.
Volume
A place on a physical medium where users store their files and cherished memories.
For the vast majority of users (but most likely not you, dear reader), this is what they call “the hard drive” or “the diskette”, or “I don’t know where the computer put it” (if you’re my dad). It’s what the operating system presents to the users to interact with. A volume generally has a name and an icon on the user’s desktop. It’s in a format like HFS, MFS or ProDOS.
A floppy disk is a volume that’s easy to understand: everything is presented to the user, the operating system knows exactly how it’s structured, and it interacts with the whole disk.
A hard disk, however, is not a volume. It’s a
Device
A piece of hardware that is plugged into a computer. The computer communicates with the device through a driver installed in the operating system, or on the device itself. The driver translates the requests from the computer into instructions the device understands.
There are many kinds of devices that a classic Mac can talk to (there’s a whole book about them called “Devices” in the Inside Macintosh series) but Disk Jockey only concerns itself with a very specific subset of them: hard disks with a SCSI interface.
The hard drive of a classic Mac will generally be structured as follows:
- Device Descriptor (the bare essential information so that the computer knows what kind of device it’s talking to)
- Partition Map (see below)
- SCSI driver (so the computer knows how to interact with the drive)
- One big honking HFS volume taking up the rest of the hard drive space. This is the part of the hard drive that actually appears on the user’s desktop.
Partition
A slice of space from a hard drive allocated to a specific role.
Unbeknownst to most users, space from their hard drive is allocated to different functions that allow the computer to interact with the hard drive. In a classic Mac, a hard drive is divided into partitions that are listed in a structure near the beginning of the disk called the Partition Map.
There are over 20 types of possible partitions but, to stay on topic, here are the most interesting types for Disk Jockey:
Apple_Driver
andApple_Driver43
: this partition contains the SCSI driver for the deviceApple_HFS
: this partition contains a volume in the HFS formatApple_ProDOS
: this partition contains a volume in the ProDOS formatApple_MFS
: this partition contains a volume in the MS formatApple_partition_map
: this partition contains the partition map (yes, it’s pointing to itself)
As vou’ll have noted, a partition map can contain one or several volume partitions. It’s possible (and common) to create several volumes on the same hard drive.
Volume Image
This is the term used in Disk Jockey to describe a raw image containing only a volume. Emulators like Basilisk II use this format and make it appear to the emulated Macintosh as a floppy.
In Disk Jockey, you can create such an image by specifying that you want to use your image with Basilisk, mini VMac, or FloppyEmu. Disk Jockey will then create a file of the size you’ve specified, filled with nothing but zeroes (the actual hexadecimal value 0x00, not the ASCII character “0”). The emulated Macintosh will then believe that a blank floppy has been inserted and propose to format it in HFS.
The extension generally used for volume images is “.img”.
Device Image
In Disk Jockey, this is an image that contains a whole SCSI hard drive, including a Device Descriptor, the Partition Map, the SCSI driver and one or several partitions. BlueSCSI and RaSCSI require this image format because they strive to replicate a physical hard drive by interfacing with the Mac through SCSI (instead of pretending to be a floppy). For the illusion to work, the full structure of a SCSI hard drive has to be replicated, which is what Disk Jockey does when you specify that you want to use your image with BlueSCSI or RaSCSI.
The extension generally used for device images is “.hda”.
How Disk Jockey Builds a Disk Image
When you create a device image in Disk Jockey, the following steps take place:
- Grab a block of memory the size of the requested image (for the old fogeys like me that feared that it would blow up the user’s RAM, it turns out that computers these days have something called virtual memory so we’re safe)
- Build a Device Descriptor block that contains the size specified by the user. Put it at the top of the block of memory.
- Build a Partition Map containing several partitions: one for the partition map itself, one for the SCSI driver and one for an HFS volume that takes up all the space of the block of memory, minus the space taken by the other structures. Put the partition map at the expected place in the block of memory.
- Copy the bytes that constitute the HD SC Setup 7.3.5 SCSI driver to the expected place in the block of memory.
- Save the block of memory to the user’s Downloads directory. Release the memory. Done.
Note that I don’t mention anywhere that Disk Jockey actually creates the HFS volume. It doesn’t. When the Mac goes through the partition map, it discovers that there is a chunk of the hard drive reserved for an HFS partition but, when it tries to access it, it realizes it’s not formatted yet. So, it gracefully asks the user for the permission to do so, and does.