Create encrypted disk image or normal disk image on the command line

 I find that the disk utility GUI app is unreliable so I prefer to create disk images on the command line. This is also more efficient if you want to create more than one and don't want to click 100 times to do it.

 hdiutil create -size 150m -encryption -type SPARSE -fs HFS+ disimagename.sparseimage

If you don't want encryption, remove the -encryption part

If you don't want the image file to be size-flexible, remove the word SPARSE and change the extension from .sparseimage to .dmg

Obviously, the size 150m means 150 megs. You can change that to g for gigs etc.

If you want to encrypt from a specific source folder, use:

hdiutil create -encryption -stdinpass -srcfolder source_folder encrypted.dmg

This will create the image file out of the folder "source_folder"

Without encryption:

hdiutil create -srcfolder source_folder not_encrypted.dmg


Popular posts from this blog

Chunk validation failed

The most useful defaults-write options

Erasing firmware password