hdiutil
hdiutil uses the DiskImages framework to manipulate disk images. Common verbs include attach, detach, verify, create, convert, compact, and burn.[1]
Documentation
- man 1 'hdiutil' [EN]
Further Information
- Tipp: Passwort aus verschlüsseltem DMG entfernen (14.02.2020) [DE] @ heise online
Subcommands & Parameters
- General parameters
- The following parameters descriptions apply to many subcommands:
- -agentpass
- Force the default behavior of prompting for a passphrase. Useful with -pubkey to create an image protected by both a passphrase and a public key.
- -encryption AES-128|AES-256
- Specify a particular type of encryption or, if not specified, the default encryption algorithm. As of OS X 10.7, the default algorithm is the AES cipher running in CBC mode on 512-byte blocks with a 128-bit key.
- -quiet
- Close stdout and stderr, leaving only hdiutil's exit status to indicate success or failure. -debug and -verbose disable -quiet.
- -stdinpass
- Read a null-terminated passphrase from standard input.
- -verbose
- Be verbose: produce extra progress output and error diagnostics. This option can help the user decipher why a particular operation failed. At a minimum, the probing of any specified images will be detailed.
- attach IMAGE
- Attach a disk IMAGE to the system as a device.
- burn IMAGE
- Burn IMAGE to optical media in an attached burning device.
- -device
- Specify a device to use for burning. See -list.
- -list
- List all burning devices, with OpenFirmware paths suitable for -device.
- -[no]verifyburn
- Do [not] verify disc contents after burn. The default is to verify.
- chpass IMAGE
- Change the passphrase for an encrypted IMAGE. The default is to change the password interactively.
- compact IMAGE
- Scans the bands of a sparse (SPARSE or SPARSEBUNDLE) disk IMAGE containing an HFS filesystem, removing those parts of the image which are no longer being used by the filesystem.
- create IMAGE
- Create a new IMAGE of the given size or from the provided data.
- -fs FILESYSTEM
- Where FILESYSTEM is one of HFS+, HFS+J, HFSX, HFS, MS-DOS, or UFS. -fs will cause a filesystem of the specified type to be written to the image.
- -size SIZE
- Specify the SIZE of the image with the addition of tera-, peta-, and exa-bytes sizes. The larger sizes are useful when creating large sparse images.
- -type UDIF|SPARSE|SPARSEBUNDLE
- UDIF is the default disk image type. If specified, a UDRW of the specified size will be created. Specifying SPARSE creates a UDSP: a read/write single-file single file file image which expands as is is filled with data. SPARSEBUNDLE creates a UDSB: a read/write backed by a directory bundle. The default for UDSP is to grow one megabyte at a time.
- -volname NAME
- The newly-created filesystem will be named NAME.
- resize IMAGE
- Resize a disk IMAGE or the containers within it.
- -size SIZE
- Specify the SIZE of the image with the addition of tera-, peta-, and exa-bytes sizes. The larger sizes are useful when creating large sparse images.
Examples
- Create a encrypted SPARSE image with a maximal size of 300 GB
hdiutil create -stdinpass -fs 'HFS+' -type 'SPARSE' -size '300g' \
-encryption 'AES-256' -volname 'Backup' 'backup.dmg'
- Compact a SPARSE image
hdiutil compact -stdinpass 'image.dmg.sparseimage'
- Mount an ISO image to /Volumes
hdiutil attach 'sample.iso'
- Burn an ISO image
hdiutil burn 'sample.iso'
- Mount a password protected disk image without user interaction
echo -n "${PASSWORD}" | hdiutil attach -stdinpass 'image.dmg.sparseimage'
- Mount a protected disk image with a password provided by Bitwarden
bw get --raw 'password' 'Disk Image' \
| hdiutil attach -stdinpass 'image.dmg.sparseimage'
References
- ↑ man 1 'hdiutil'