Tuesday, March 3, 2015

Protecting Files On Your Mac

In the past, I have spoken at length about protecting your information with good passwords, especially when traveling. I have a tip this month for protecting files. I wish the same techniques apply to iOS devices, but it is not possible. Maybe someday.

The technique will work on Macs going back to Snow Leopard (at least) and all the way up to Yosemite. This technique can protect any type of files that can be copied from one disk to another. I suggest protecting your password file this way. Every Mac has the tool needed to perform this technique.

The technique is to create a password protected disk image, a special type of disk image called a SparseBundle. Think of it as a special file that can contain other files, and it is comprised of formatted space, not unlike any formatted disk, such as your USB drive.

For all of this to make sense, follow along on your Mac.

To create this disk image and the space for your files, open Disk Utility, found in your Utilities folder. At the top is a button called New Image. Tapping the button opens a dialog box with a number of fields.

At the top is a Save As field used to name the disk image (SparseBundle) which will contain everything. This file is the file you can copy from one Mac to another or even save in your Dropbox account. Give it a good name, and then use the Save As area to show it where to save the SparseBundle.

Next is the Name field. This is the name of the virtual disk contained within the disk image. The virtual disk will appear on the sidebar of a Finder window, just like your Mac's hard drive may show up as Mac HD.

The next field is Size in megabytes or MB, which is the *maximum* size this disk image can attain. The disk image starts out small and grows larger as files are dragged into the disk. If the maximum space you need is 150 MB, give it some leeway, and put 180 MB in this field, because the SparseBundle will itself take some space.

In the Format field, select Mac OS Extended (Journaled). The next field is Encryption. If you need to protect your files, select 128-bit AES Encryption. With encryption selected, you will be asked to enter a password. Make it one you can remember, since this disk image will hide your file of passwords from prying eyes.

In the Partitions field, select No Partitions Map. And, in the last field, Image Format, select Sparse Bundle Disk Image. Then, tap the Create button, and the new disk image will be created with the virtual disk sitting on the sidebar of your Finder window along with an eject button.

To use this disk image, drag files to the virtual disk, and they will be copied, just as if you had dragged the files to a USB drive. If you don't want unprotected files around, delete the original file on your hard drive.

Unmount the virtual disk by clicking on the eject button in the sidebar. The files are now protected by the password you chose. To get to the protected files again, double click on the disk image (with the name from the Save As field). You will be asked for the password.

The really great thing is you can copy the disk image to a thumb drive or other device and open it on any Mac running Snow Leopard or newer. Just don't forget your password! I have copied my disk image to my Dropbox account, and it works on all my Macs. But, if someone breaks into my Dropbox account and steals the disk image, they cannot open it without the password. The same goes for any USB drive containing a copy of the disk image.

Remember that the disk image is open as long as you leave it mounted; it will be unmounted when you shut your Mac down, but will remain mounted if your Mac simply goes to sleep.

As I previously stated, the disk image (SparseBundle) file will grow in size to accommodate files you have copied into the virtual disk, up to the maximum size you gave. When you remove files, the size will not automatically decrease. This may be a problem for those trying to fit a big disk image onto a USB drive.

There is a way to shrink the disk image after deleting files from it. You must be willing to use the Terminal. First, click the virtual disk eject button in the Finder window to unmount it. Then, go into the Finder and type this command:

hdiutil compact  /Users/rick/TestDMG.sparsebundle  -batteryallowed

The -batteryallowed option tells it to compact even if you are on a MacBook running on battery. In the middle is the path to your disk image. The easy way to get the path is to type the first two words of the command and a space, and then drag the disk image file to the Terminal window, and the path will be added for you.


Give it a try, and protect those files!

No comments:

Post a Comment