Create an Encrypted Disk Image with hdiutil
Build an AES-256 encrypted .dmg vault from the Terminal — no Disk Utility clicking required.
Run `hdiutil create -size 500m -fs APFS -encryption AES-256 -stdinpass ~/SecureVault.dmg`, then type your password when prompted.
01Command
Command
$ hdiutil create -size 500m -fs APFS -encryption AES-256 -stdinpass ~/SecureVault.dmg02What it does
hdiutil is the command-line engine behind Disk Utility, and it can script the whole encrypted-vault workflow: -stdinpass reads the password so it never lands in shell history or ps output. When double-clicked, the resulting .dmg asks for the password before mounting. Use -srcfolder to add content at creation time, or grow the image later with `hdiutil resize`.
03Risk
04Undo
Undo
$ hdiutil detach /Volumes/SecureVault && rm ~/SecureVault.dmg05Sources
- macOS hdiutil — create, attach and detach disk imagesEvidence: Documents hdiutil create with -encryption AES-256, -stdinpass, -size and filesystem options.
Last verified: 2026-09-17 · Category: System & Settings