Detail oriented

Ed Fine's blog.


macOS Recipes

Convert a DMG to an ISO file

hdiutil makehybrid -iso -joliet -o [filename].iso [filename].dmg

Mount an ISO file

Curiously, unlike the *nix systems, where you use mount -t iso9660 to mount an ISO image, in macOS you use

hdiutil mount [filename].iso

This creates a mount point under /Volumes.

Decode a mobileconfig file

Apparently a .mobileconfig file is an Apple plist in CMS (Cryptographic Message Syntax) format.

Anyway, to decode it, you can try the macOS security utility (only included after 10.3).

security cms -D -i [filename].mobileconfig

Create a macOS Sierra ISO

Why would you want to to this?

For one thing, Apple doesn’t appear to provide its macOS distributions as .iso files.

And now that VMware ESXi 6.5 officially supports macOS (as long as ESXi is running on Apple-branded hardware), the easiest way to create a macOS guest is from an ISO file connected to an ESXi virtual CD/DVD drive.

# Mount the installer image
hdiutil attach /Applications/Install\ macOS\ \
    -noverify \
    -nobrowse \
    -mountpoint /Volumes/install_app

# Create the Sierra blank ISO image of 7316mb with a Single Partition - Apple Partition Map
hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J

# Mount the blank ISO Image
hdiutil attach /tmp/Sierra.cdr.dmg \
    -noverify \
    -nobrowse \
    -mountpoint /Volumes/install_build

# Restore the Base System into the Blank ISO Image
asr restore \
    -source /Volumes/install_app/BaseSystem.dmg \
    -target /Volumes/install_build \
    -noprompt \
    -noverify \

# Remove Packages link and replace with actual files
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/

# Copy installer dependencies
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg

# Unmount the installer image
hdiutil detach /Volumes/install_app

# Unmount the ISO Image
hdiutil detach /Volumes/OS\ X\ Base\ System/

# Convert the ISO Image to ISO/CD master (Optional)
hdiutil convert /tmp/Sierra.cdr.dmg -format UDTO -o /tmp/Sierra.iso

# Rename the ISO Image and move it to the desktop
mv /tmp/Sierra.iso.cdr ~/Desktop/Sierra.iso