Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.3: Use any disk image format with FileVault System
A lot of people have been having problems with FileVault lately. I'm one of them, and ended up doing a clean reinstall of Panther due to corruption. Speculation is that the cause of FileVault's problems is that it uses a sparse image. I wondered if FileVault would accept other types of disk images. Sure enough, it did. Here's how to convert your encrypted home directory to a different type of image and possibly prevent corruption.

First of all, I can't guarantee that this will prevent corruption, or that it won't cause other problems. The total amount of time I've tested this so far adds up to less than 30 minutes. There is also one limitation that it has compared to the sparse image which I'll detail below. The normal caveats (backup your data, use at your own risk, don't blame me, etc.) also apply. You will need a user with root access. I've done this using sudo and an administrator account, but the root user and single-user mode should work too.

[robg adds: Before you read the rest and try this hint, it's worth repeating: have you backed up lately?! With the release of 10.3.1, the corruption issue may be gone, but I figured folks might want to experiment with other disk image formats ... at their own risk, of course!]

Log out of the account that you want to convert and get root access. Open a Terminal and go to the user's home directory. If you do an ls, you'll see a file called shortname.sparseimage. The user I tried this on had test for a shortname, so that's what I'll use for the rest of the hint. You should record some information in case you want to convert back to a sparse image later. Type hdiutil imageinfo test.sparseimage. A dialog will pop up asking for the password to the image every time you run hdiutil. Use the user's password. If you're using sudo, don't forget you need to enter your own password in the terminal first. A lot of stuff scrolls by, but fortunetly the last line is the one we're interested in. Write down the number of total bytes and keep it somewhere safe.

The next step is to resize the image. This is the major limitation of this hint. I think the reason that Apple uses a sparse image is because it is dynamically sized. That means that your home's disk image doesn't take up any more space than it needs. None of the other image types, as far as I can tell, are able to do this. You will need to create a fixed size image. The problem is that if you run out of free space in your home directory but still have free space outside of it, you're out of luck, and vice versa. It's up to you to decide how much space you want in your home directory. There really is no good way to decide how much it should have. Once you have decided, enter this line:

hdiutil resize -size 10g test.sparseimage
Replace the 10 with however many gigs you want, or use an m instead of a g if you want to specify the size in megs. Now it is time to create the new image. Creating the image will require as much space as you specified in the previous step. Since you hopefully specified it to be less than the free space you already have, that shouldn't be a problem. Enter this line:

hdiutil convert test.sparseimage -format UDRW -o test -encryption
Enter the password for the current image, and then when prompted for the new password enter the same one again. Now get some coffee, go for a walk or repaint your house, because this is going to take a long time. It's done once the dots are all the way across the terminal. Once it's done creating the new image, rename the old one temporarily:

mv test.sparseimage test.sparseimage.bak
Then put the new image in its place:

mv test.dmg test.sparseimage
There's one more step before putting this to the test. Just to make sure there are no problems with permissions set the new image to be owned by the user:

chown test.test test.sparseimage
Now log in as the user and if all went well, your new encrypted home should be mounted. If you were having corruption problems before, see if it still happens. Once you're satisfied that the new image is working fine, you can delete the old one. One note: you will still get the dialog about recovering space when you log out. I don't think what it says is true any more, but it doesn't hurt to click continue.

If you want to return to the sparse image use these commands as the super user:
 % mv test.sparseimage test.old.sparseimage
 % hdiutil convert test.old.sparseimage -format UDSP -o test -encryption
Find out the original size of the sparse image. Remember the total bytes you wrote down as the first step?
 % hdiutil resize -size 75161965568b test.sparseimage
 % chown test.test test.sparseimage
 % rm test.old.sparseimage
If anybody can figure out how to make File Vault mount a UDZO type image read/write, then this will be almost perfect as a replacement for the sparse image. If this turns out to not prevent corruption, note you can also use this to create read-only images, which might be useful for public computers. Check the man page for hdiutil to see the different image types you can use.
    •    
  • Currently 3.00 / 5
  You rated: 5 / 5 (8 votes cast)
 
[20,296 views]  

10.3: Use any disk image format with FileVault | 1 comments | Create New Account
Click here to return to the '10.3: Use any disk image format with FileVault' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3: Use any disk image format with FileVault
Authored by: seromlig5 on Mar 09, '05 06:11:32PM

Please tell me if your instructions solve this problem: I needed to clean some crud out from underneath the space bar on my G4 667/10.3.8 TiBook's keyboard seven agonizing days ago and duly disconnected power supply and removed battery before removing the keyboard. When I had put everything back together and switched on the computer, FileVault, or what I have dubbed "VileFault" after belatedly discovering numerous similar horror stories, had nicely locked up about 10 GB and several years' worth of my documents, pictures, sound clips, preferences, email, appointments, addresses, etc., into a sparseimage which I cannot for the life of me, and it may be the death of me, manage to pry open. Double-clicking on the sparseimage elicits this response: "The following disk images failed to mount . . . . . Reason: no mountable file systems." I've turned VileFault off, forever, and tried Disk Utility at least a dozen times. Have also tried unsuccessfully to use Data Rescue but their instructions call for connecting to a FireWire drive and I've now discovered that there seems to be a problem with my FireWire port which I've never used before. A technician for Disk Warrior (I don't own their product) gave me some instructions for solving the problem with Terminal which have also failed so far to work.
I would be incredibly grate ful for advice that will help me get my files back.

---
There are three kinds of people in the world: those who can count, and those who can't.



[ Reply to This | # ]