I need to hide a particular folder on my Mac from other people who might want to view or copy them while I’m away from home.
There are two ways I’m aware of. The first way is to hide the folder using Terminal.
chflags hidden your-folder
chflags nohidden your-folder
The second way is to move the files from the folder to a disk image, which is created using Disk Utility. And again, it seems there are two different ways, both are described here: Create a disk image using Disk Utility on Mac, sections
Create a disk image from a folder or connected device
Disk Utility > File > New Image > Image From Folder > Encryption = 128-bit AES encryption > Passoword = … > Image Format = read/write
and Create a secure disk image
Disk Utility > File > New Image > Blank Image > Size = 100 MB (default) (as far as I understand, this value doesn’t matter, because we will use read/write futher) > Format = APFS > Encryption = 128-bit AES encryption > Partitions = Single partition - GUID partition map (default) (I don’t know what does it mean) > Image Format = read/write disk image
What I don’t understand and what my question is about is whether any practical difference here between creating a disk image from folder and creating a blank disk image. And if it is, then what is this difference.
Note that a disk image should not be limited to a particular size. I want to be able to add there as many files as I want. That is, its size should be adaptive.
I’ve never relied on hiding files and folders. Anyone who knows to press Command + Shift + . (the period) can find those. I prefer to use encrypted dmg files.
If I don’t plan to add to the folder later I will create the dmg “from a folder”. If I do I create an empty file and size it accordingly.
I prefer the Disk Utility GUI. If I just want a protected folder I’ll create a DMG file much larger than I need initially. Then I will treat it like any other folder, adding and deleting files as needed. If I want to protect the folder containing this year‘s income tax forms, I will create it “from a folder” since I will never be adding to it.
Create a Sparse Image if you want the image to be able to grow (and shrink). However the maximum size must be specified as the size when you create the image.
I used encrypted sparse images for many years then discovered I could not open several older ones after installing Ventura. I was never able to verify the cause but the timing was suspicious. I no longer use them.
Hi, Tom. Sorry for a relly late reply. “Create a Sparse Image if you want the image to be able to grow (and shrink).” - I have tested it and it seems you are correct, they can grow (or I can create an image from folder, and it can grow as well), but seems the image doesn’t grow automatically. I have to manually enlarge its size using Disk Utility once it is full. Right?
A sparse image it takes little space when empty and takes more space as it fills. A standard image takes the same space empty as it does when full. The maximum size of a sparse image or the size of a standard image I don’t think can be changed after it is created. I’ve never tried to do so, so don’t know for sure.
Step 2. I prepared several 25 MB test files to copy them to that disk image. I am able to copy two of them, but not the third. It seems the size of the disk image doesn’t expand for me when it is full; it is the same 100 MB.
And what confuses me even move, it seems that if I delete files from the disk image, it doesn’t free space for me. That is, if I delete the two files I have copied there right now, and then try to copy one of them again, I will get the same “The operation can’t be completed…” message.
Sparse images and bundles don’t automatically recover space when contents are deleted. To do that, you’ll need to compact them with a utility or hdiutil.
Thank you very much, Karl. However, I still don’t understand how to create a disk image that will automatically grow as I add more and more files. Maybe you know?
Further down in the article I linked to above, in the section titled Creation and management, the author mentions three programs (DiskUtility, DropDMG, and Spundle) any of which you could use to create a sparse image or a sparse bundle, which would be the kind of disk image that grows with its contents.
EDIT TO ADD: I do not have enough information about your system and how you made your test files, for instance, to explain the behavior you have described.
When you delete a file it goes into the trash. You need to empty the trash before adding additional files to recover the space in the image. I do agree that you can’t add files even when there appears to be available space. I tried it with a standard disk image and the same thing happens. I haven’t found any explanation of this.
HOWEVER if you create the image as Mac OS Extended instead of APFS you can fill it all the way up.
When you create the disk image it is very small and enlarges as you put files into it. It will not shrink back down when you delete files – it simply becomes unused but will be used again if you add new files.