www.xlr8yourmac.com
The Source for Mac Performance News and Reviews

Systems  | CPU Upgrades  | SCSI | IDE | Firewire  | Video  | Audio  | Games  | Misc/OS  | Archives  | Search

Searchable Databases of Mac Owner Reports on:
CPU Upgrades | Drive Compatibility (HD/DVD/CDRW/Tape) | System/Graphics Benchmarks | Game Reviews

Got Questions? - Check the FAQ for Answers
800+ Answers on CPU Upgrades/CDR/DVD/Storage/Video Cards/Firewire/Games & More!
Email News/Tips/Reviews | Advertise here
Return to News Page

Click for iPhone Accessories!
Click for iPhone Accessories!

Shrink Encrypted Home Directory (aka file vault) Sparse Images
By: Martin Schwarz
Posted: 7/22/2005


Encrypting the home directory is recommended especially for notebooks. Unfortunately, the encrypted sparse image used in Mac OS X tends to grow and grow. The automatically used shrinking mechanism (I suppose it is "hdiutil compact") doesn't reduce the size efficiently. So I tried the following approach: I created a new sparse image, mounted the original home image and copied over everything. By doing so I could reduce the size of my home sparse image from 732 to 490 MB. Logging in now goes noticeably faster.

The procedure was tested using Mac OS X 10.4.2, and earlier in 10.3.x.

That's the way it works:

Log in as administrator. You need the terminal and some familiarity with the command line, some time (roughly one hour, but no time pressure) and a clear head.

1) Create a new empty sparse disk image. This is going to be the shrunk image. Replace the username with your user's username, the uid and gid with your user's uid and gid respectively. You will be asked to provide a password. This _must_ be the user's login password. Make sure to uncheck the "remember..." checkbox.
hdiutil create -type SPARSE -fs HFS+ -encryption -volname username -uid 502 -gid 502 -autostretch /Users/Shared/shrink.sparseimage

2) Very important: Make a work copy to play around with. It serves as a backup, too.
sudo cp /Users/username/username.sparseimage /Volumes/A

3) Mount the two images
hdiutil attach -owners on /Users/Shared/shrink.sparseimage
hdiutil attach /Volumes/A/username.sparseimage

4) Copy the contents of the orignial to the shrink image. Be careful not to mismatch the images: The first is the source, the second destination. Upon mounting two images with the same volume name (not identical to the file name), the second gets a number attached.
sudo ditto /Volumes/username /Volumes/username\ 1

5) Check if all files inside the new image have correct ownership:
sudo ls -l /Volumes/username
If not, this could be because you missed the "-owners on" flag in step 3). In this case, get the finder info for the Volume and uncheck the "ignore ownership" checkbox. Now run "sudo chown -R 502:502 /Volumes/username\ 1"

6) Unmount everything
hdiutil detach /Volumes/username
hdiutil detach /Volumes/username\ 1

7) Change owners and permissions on the image file itself. Replace 502 with your user's uid, of course!
sudo chown 502:502 /Users/Shared/shrink.sparseimage
sudo chmod 744 /Users/Shared/shrink.sparseimage

8) ls -l should now look similar to this:
-rwxr--r-- 1 username username 513807612 Jul 20 14:55 /Users/Shared/shrink.sparseimage

9) Now copy the new over the old image. Be sure to have a backup! If you followed these instructions, you should have one.
sudo cp /Users/Shared/shrink.sparseimage /Users/tinu/tinu.sparseimage

10) Check if everything works! Better log out all users before trying it out. If it fails, the only thing to do will be to reset the computer...

Some additional hints on working with encrypted homes:

  • Be careful in saving things to the desktop. I make use of /Users/Shared for not so important stuff, e.g. downloads from the internet.
  • Watch for swap files and directories inside your home! For example Gimp must be configured not to use ~/.gimp-something as swap space.
  • Don't keep 50MB of internet cache. 10MB will work fine.
  • For a break, don't just put the machine to sleep. If it crashes, unsaved data is likely to be lost. Log out frequently instead.
    -(c) Martin Schwarz
  • Return to Main News Page


    iPhone Accessories


    FasterMac.net
    Internet Access

    OWC SPECIALS!
    (see full list)

    = MEMORY =
    4GB (2x2GB) Mac Pro RAM (800MHz) $130

    4GB (2x2GB) Mac Pro RAM (667MHz) $127.50

    4GB (2x2GB) PC6400 for 2008 iMacs $72.25

    4GB (2x2GB) PC2-5300 SODIMMs $69

    2GB PC2-5300 SODIMM $35

    1GB DDR400 DIMMs $29.75

    512MB PC-133 SDRAM $31.75

    = WIRELESS =
    802.11N/g/b PCI, PCMCIA or USB adapters under $50
    802.11N/G/B Router $65

    = TV TUNERS/DVR =
    ElGato Turbo.264 $77.50

    EyeTV 250+ w/clear QAM $130

    = CPU UPGRADES =
    7447A 1.6GHz $225

    G3 1GHz ZIF upgrade $125

    = HARD DRIVES =
    500GB 7200rpm/16MB cache $69

    WD 640GB 7200rpm/16MB Cache $75.50

    1TB SATA HDs from $118

    EliteAL eSATA/FW800/400/USB 2.0 Case Kit w/SW $79

    1TB EliteAL FW/USB 2.0 $189

    1TB EliteAL SATA/FW800/400/USB2 $247.75

    = NOTEBOOK HDs =

    500GB Samsung M6 HD + USB 2.0 Case Kit $207.50

    320GB/7200RPM/16MB cache $137.50

    200GB/7200RPM/16MB cache $83.50

    160GB 2.5in HDs from $68

    250GB 2.5in HDs from $72.99

    = GRAPHICS CARDS =
    ATI HD 3870 PCIe $217.99!

    ATI 9800 Pro AGP $205

    ATI 9600 Mac/PC AGP $179


    XLR8YourMac.com T-Shirts $14.99
    Support this site!



    Mac Help Now!
    Freq. Asked Questions
    (Check First!)

    Mac Model Articles

    CPU Upgrade Articles

    Video/Card Articles

    Storage Articles

    Search Mac Drive Upgrades/Compat. Database

    Search the CPU Upgrade Database

    Search the
    Game/System Perf. Database

    Read Game Reviews


    Recent Reviews and Articles:
    Listing/links to recent articles, guides and reviews you may have missed.  Details

     
    = back to www.XLR8YOURMAC.com =


    = Other Site Topic Areas =
    Systems | CPU Upgrades | SCSI | IDE | Video | Firewire | Audio | Tips/Misc | Mac OS Articles | FAQ


    Copyright © , 1997-2008. All Rights Reserved
    All brand or product names mentioned here are properties of their respective companies.

    Legal: Users of the web site must read and are bound by the terms and conditions of use.