I want to encrypt some folders on my Mac.

I know there is a way of doing it by making a dmg file, but I also want to keep editing those folders. So I just want to encrypt that folder while being able to add more things in the encrypted folder. You know, it should act as how the password works on a user account, if that makes any sense :P

  • 2
    a .dmg is editable, so long as that's how it's mounted – Tetsujin Feb 15 '15 at 18:11
  • @Tetsujin Yes, but dmg files are a fixed size and have to be resized manually in Disk Utility. – grg Feb 15 '15 at 18:13
  • ahh… I always wondered what the heck a sparsebundle actually was. Your answer is the first post I've ever seen that distinctly ties one concept to the other in my head. ty. – Tetsujin Feb 15 '15 at 18:16
  • @grgarside read/write sparse images are .dmg and don't need to be resized manually. See my comment on your answer for more details. – bmike Feb 17 '15 at 22:29

You can use a sparse bundle which will expand when the contents increases in size.

  1. Enable advanced image options in Disk Utility.

    defaults write com.apple.DiskUtility advanced-image-options 1
  2. Open Disk Utility and select FileNewDisk Image from Folder… or press ⌘N.

  3. Select the folder that you want to encrypt and press Image.

  4. Choose sparsebundle as the Image Format, and choose the level of encryption you require.

  5. Choose a password to encrypt the image and click OK.

If, after removing some files from the sparse bundle, you wish to decrease its size, you can compact it:

hdiutil compact /path/to/folder.sparsebundle
  • I've done this and adding files to either a sparse image or sparse bundle image fails with an out of space error. Are you sure you didn't mean to choose a new image and specify some large size like 20 GB? I'd also run with a sparse disk image over sparse bundle unless you were rsyncing it or needing to back it up via Time Machine and worries about efficiency of backup space instead of storage efficiency. – bmike Feb 17 '15 at 22:27
  • @bmike The folder that you select to create the image from must have a contents that, once compressed, exceeds 16 MB, or two bands. Otherwise, yes, one will receive that error. Creating a sparse bundle of arbitrary starting size does mitigate this problem. I'm not au fait with the exact differences between sparse disk image and sparse bundle but will research this tomorrow and adjust my answer if necessary. – grg Feb 17 '15 at 22:40
  • Bundle spews the data across many "band" files and is a directory. The sparse image does the same inside one binary file which is more efficient from a CPU and filesystem standpoint. The bundle allows small changes to just effect one band file so rsync and Time Machine can copy more incremental bits and not have to send the whole blob when one file (or a file's metadata) changes. I'd say - make a 0.1 TB Sparse Disk Image and then copy whatever you please into it :-) – bmike Feb 17 '15 at 22:53

SOLVED - When you go into disk utility and go to create a new image file, you must use the second drop down for file type and choose "read/write" instead of "compressed". Then set the encryption and password, create the dmg file. You now have a password protected folder that you can access and paste new files / folders to.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .