Best possible way to edit read only DMG

File: DMGI ran into a situation of editing bootable dmg for my need, I utilized the hdiutil shadow mode for my purpose and thought share best possible way to edit read only dmg with community.

What is DMG file and what’s the purpose of it?


  • Preserve bootable state of dmg
  • Eliminate a space required to convert read-only dmg to read-write
  • Add, edit, delete any items on dmg
  • Less time consuming as compare to other approaches

Edit Read Only DMG

Step 1

Attach read-only dmg file using hdiutil

Note: This command takes a while depending on dmg size.

Step 2

Modifying mounted dmg, perform add, edit or delete as per your need

Step 3

Detach mounted drive [Now it is modified one] by below command or Eject it from Finder

Step 4

Converting/Writing a shadowed dmg into read-only form

Note: This command takes a while depending on  dmg size.

That’s it, we have successfully edited read only dmg file! :)

Tags:, ,
  • Robu Andrei

    do i have to wait a while after the first command?

  • Robu Andrei

    instructions are not clear enough. i’m stuck at step 2, what to eject?

    • @robuandrei:disqus I just responded to your previous comment do i have to wait a while after the first command? and updated the article as well.

      “what to eject?”
      Response: Once you have modified the dmg, detach the mounted drive i.e modified dmg.

      To get list of mounted drive use command df.

      Then proceed to Step 4.


  • Sean C

    Many thanks for the syntax, worked great. (using df to display which disk to unmount helps for anyone interested)

    • Thanks, will add instructions to get disk information.


  • Noor440

    Thanks a lot, worked perfectly

  • Faewui

    <3 thx

  • elvis

    follow your instruction, I can modify the read-only dmg,but when I delete a file and the free space no change,what about the problem~~