How to create a dmg image


Thanks for visiting! If you're new here, you may want to subscribe to my RSS feed. This blog posts regular information about web development, unix/linux, How-tos and patches. Go ahead, subscribe to my feed! You can also receive updates via email, instant messenger, skype or tweeter.

In a previous post I showed you how to mount a .dmg image from the command line.

Have you ever wondered how you can create such an image? Continue reading if you want to know.

Let's assume you want to create an image with a size of 10Mb that is formatted with a case sensitive HFS+ filesystem, with a Volume name Test stored in a file with the name Test.dmg.
Here is the command line you have to type in the shell:

hdiutil create  -size 10m  -fs "Case-sensitive HFS+" -volname Test   Test.dmg

If you want to put files on it you have to attach it first:

hdiutil attach Test.dmg

Or you could just add -attach to the list of parameters of the hdiutil command and it will also attach it after it creates it:

hdiutil create  -size 10m  -fs "Case-sensitive HFS+" -volname Test  -attach  Test.dmg

Now you can copy your files to /Volumes/Test and when you're done you can detach the image in case you want to transfer/copy/move it:

hdiutil detach /Volumes/Test

If you want a quick way to create an image from the contents of a folder you can use something like this:

hdiutil create  -fs "Case-sensitive HFS+" -volname Test  -srcfolder /path/to/source/folder  Test.dmg

With that you can also specify a format for the image like compressed or read-only images.
Note that in this case I have not used that -size specifier anymore because the image will be as large as the contents of the source folder.

hdutil create --help for more details about image formats encryption and other goodies :)

  • Digg
  • Reddit
  • del.icio.us
  • Slashdot
  • Spurl
  • StumbleUpon
  • Furl
  • description
  • Netscape
  • NewsVine
  • Technorati
  • YahooMyWeb
  • Simpy
If you enjoyed this post, you should subscribe to my full RSS Feeds

close Reblog this comment
blog comments powered by Disqus

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License

Technology Blogs - Blog Top Sites Search For Blogs, Submit Blogs, The Ultimate Blog Directory Blogarama - The Blog Directory 5starsblog Computers Blogs - Blog Flare blog search directory gob BlogHop