Read more articles
Compose a new article

How to create a HFS+ disk image in Mac OS X to encapsulate/transfer Mac OS 9 and earlier files

Category: Disk images , Mac OS 9 , Mac OS X
Composed by: that-ben
On: 2018-10-30 10:28:24

Old Mac files (Mac OS 9 and earlier) need to be encapsulated properly before being moved/copied to a non-HFS partition/disk such as on a Windows PC or a web server or they will get corrupted, effectively losing their resource fork, which will render them useless on your Mac OS 9 or earlier environment.

The best way to protect old Mac files before moving/copying them out of your OSX environment is to first copy them onto a HFS+ disk image, which can then be mounted under Mac OS 8.1 or newer. (Note: if you need to bring old Mac files all the way back to a pre-1998 Mac OS environment, this article will not help you as Mac OS 8.0 and earlier require HFS Standard, not HFS+ so the image you're about to make based on this article won't mount under those OS and note that Intel OSX (2006 and newer) disable writing to HFS partitions anyway, so you won't even be able to make the HFS Standard disk image anyway.)

OK so here's how to make a HFS+ disk image under any Mac OS X version.  When you're done with executing the command, you can double click the created file to mount the volume and you can drag and drop files on the mounted volume to copy files onto the disk image.  Don't forget to unmount the disk image before copying/moving it to another drive (drag and drop the mounted volume in the trash).

There are 2 commands I like to use.  It really depends on your scenario:

The first command lets you create a HFS+ disk image with a fixed volume size.  This is interesting if you wanted to fit the disk image on a drive that has limited free space and you wanted to make sure it would not be any bigger than what's available.  Before using the following Terminal command, make sure to adapt "./Desktop/diskimage" to the destination disk image path you want (i.e.: diskimage on the desktop) and "10M" to the amount of disk space your image shall use.  You can go with gigabytes too (e.g. "2G" for 2 gigabytes) : hdiutil create -fs HFS+ -o "./Desktop/diskimage" -size 10M -layout SPUD -type UDIF -nospotlight

The second command lets you create a HFS+ disk image mirroring a folder's contents.  Before using the following Terminal command, make sure to adapt "./Desktop/stuff" to the source folder path to copy from (i.e.: a folder named "stuff" on the desktop) and "./Desktop/image" to the destination path : hdiutil create -srcfolder "./Desktop/stuff" -fs HFS+ "./Desktop/image"

Note: The files created by hdiutil will automatically be named ending with .dmg when you run those commands, so i.e. if your command has the destination path as "./Desktop/image" it will in fact create a file named: "./Desktop/image.dmg"