boredzo

Also @boredzo@mastodon.social.

Breaker of binaries. Sweary but friendly. See also @TheMatrixDotGIF and @boredzo-kitchen-diary.



My understanding of the status quo of disk images on other platforms (particularly Windows and Linux) is that it's pretty damn primitive. They're typically just raw disk dumps of the whole device, and most tools for working with them are third-party/not bundled, command-line-based, or both. Mounting a disk image on Linux via a loopback device does not guarantee that the volume will show up in your distro's file navigator; I have no idea how to tell the file navigator “hey, there's a new volume over here”.

On the Mac, we have a structured format for disk images, called UDIF (Universal Disk Image Format). These disk images include checksums of the volume(s), and optionally a code signature that can be verified at mount time.

UDIF images present as .dmg files. Double-cilcking a .dmg in the Finder launches a GUI app that shows a progress bar for the verification and mounting process, and (by default) the image's volumes will be navigable in the Finder.

UDIF images also support compression via a wide variety of algorithms. You can compress a raw disk image, of course, but blah.img.xz will simply decompress to a new uncompressed file for you to separately mount. A compressed .dmg simply mounts when double-clicked, same as usual, with no additional effort. (Compressed disk images can only be mounted read-only, which is typically the desired behavior.)

When you dig into the gory details from the command line, you benefit from another good subsystem of macOS, Disk Arbitration. When a storage device (physical or otherwise) mounts, DiskArb creates device files for each volume in addition to the partition map. For CD-ROMs, the raw CD gets the whole-disk device, and volumes on the CD get subdevices. For most other devices, the partition map is the whole-disk device and the partitions are subdevices. This gives you a ton of flexibility that 99% of the time you won't need, but makes things massively easier when you hit a 1% case.

The disk image system does support raw images, so it's also possible to image a device by simply copying its (unmounted) device file to a regular file. Then you can hdiutil attach that file, or feed it to your favorite emulator.

We really should have this kind of tooling on other platforms. It's one of the things I miss whenever I'm trying to do any kind of preservation or playing with emulators on a Linux machine.

(It would help a lot if Apple would publish a damn spec for the UDIF format…)


You must log in to comment.
Pinned Tags