Skip to content

hdiutil MacOS command

The hdiutil command in MacOS is a versatile tool used for creating, manipulating, and converting disk images. It allows users to mount, unmount, verify, and resize disk images, as well as convert them between different formats. With hdiutil, users can also encrypt and decrypt disk images, making it a valuable utility for managing disk images efficiently on MacOS.

hdiutil Syntax:

Terminal window
hdiutil command [option] [parameter]

hdiutil Options:

OptionDescription
-helpDisplay help for hdiutil command
-createCreate a new disk image
-attachAttach a disk image
-detachDetach a disk image
-infoDisplay information about a disk image
-convertConvert a disk image from one format to another

Parameters:

ParameterDescription
commandThe specific hdiutil command to execute
optionThe option to modify the command behavior
parameterAdditional parameter required for the command execution

hdiutil Command Usage Examples:

Create a New Blank Image

Terminal window
hdiutil create -size 100m -fs HFS+ -volname MyDisk MyDisk.dmg

Creates a new blank disk image named MyDisk.dmg with a size of 100 MB formatted with HFS+ file system.

Encrypt an Image with a Password

Terminal window
hdiutil create -encryption AES-256 -size 200m -fs HFS+ -volname EncryptedDisk EncryptedDisk.dmg

Creates a new encrypted disk image named EncryptedDisk.dmg with a size of 200 MB, using AES-256 encryption and formatted with HFS+ file system.

Mount an Image

Terminal window
hdiutil attach MyDisk.dmg

Mounts the disk image file MyDisk.dmg to the system, allowing you to access its contents.

Convert an Image to Read-Only

Terminal window
hdiutil convert -format UDRO -o ReadOnlyImage.dmg MyDisk.dmg

Converts the disk image file MyDisk.dmg to a read-only disk image file named ReadOnlyImage.dmg in UDRO format.

Verify Integrity of an Image

Terminal window
hdiutil verify MyDisk.dmg

Verifies the integrity of the disk image file MyDisk.dmg to ensure it is not corrupt or damaged.

How do I mount a disk image using hdiutil in MacOS?

To mount a disk image using hdiutil in bash, execute the following command:

Terminal window
hdiutil attach /path/to/disk_image.dmg

How do I create a new disk image using hdiutil in MacOS?

To create a new disk image using hdiutil in bash, execute the following command:

Terminal window
hdiutil create -size 1g -fs APFS -volname NewDisk /path/to/new_image.dmg

How do I unmount a disk image using hdiutil in MacOS?

To unmount a disk image using hdiutil in bash, execute the following command:

Terminal window
hdiutil detach /path/to/mount_point

How do I verify a disk image using hdiutil in MacOS?

To verify a disk image using hdiutil in bash, execute the following command:

Terminal window
hdiutil verify /path/to/disk_image.dmg

How do I convert a disk image format using hdiutil in MacOS?

To convert a disk image format using hdiutil in bash, execute the following command:

Terminal window
hdiutil convert /path/to/original_image.dmg -format UDTO -o /path/to/converted_image.cdr

How do I list information about a disk image using hdiutil in MacOS?

To list information about a disk image using hdiutil in bash, execute the following command:

Terminal window
hdiutil imageinfo /path/to/disk_image.dmg

How do I create a sparse disk image using hdiutil in MacOS?

To create a sparse disk image using hdiutil in bash, execute the following command:

Terminal window
hdiutil create -size 1g -type SPARSE -fs APFS -volname SparseDisk /path/to/sparse_image.sparseimage

How do I compact a sparse disk image using hdiutil in MacOS?

To compact a sparse disk image using hdiutil in bash, execute the following command:

Terminal window
hdiutil compact /path/to/sparse_image.sparseimage

Applications of the hdiutil command

  • Create disk images
  • Convert disk images between formats
  • Mount disk images
  • Verify and repair disk images
  • Burn disk images to physical media
  • Resize disk images
  • Encrypt and decrypt disk images
  • Split disk images into segments