FileVault Corruption

Sometime in the last couple of days (possibly the last week) the sparse image that FileVault stores my home directory within got corrupt. I noticed it yesterday when checking out Objective C files from subversion that ended up containing fragments of XML instead of the Objective-C source code they should have contained.

It turned out the XML was fragments of the NetNewsWire subscription plist (which NetNewsWire seems to save to disk pretty regularly). Something was definitely up. I logged out and booted up from my Tiger install DVD and performed a disk check using Disk Utility. The FileVault image was damaged (beyond repair) and the volume it was kept on (not my System volume) was damaged too.

I couldn’t repair the sparse image without repair the volume it resided on and paradoxically could not repair the volume without first repairing the image!

My last backup about two days ago had failed too – I thought rsync was just being flakey on 10.4 (it was core dumping) and stupidly didn’t pay it much mind. If I perhaps had taken the time to investigate then I might have realised something was up. Because my backup was incomplete I had no choice but to try and repair the disk image. I copied it to an external firewire drive (Lacie Pocketdrive) and deleted the original. That allowed Disk Utility to repair the volume but I couldn’t repair the sparse image without corrupting it (I only tried to repair the sparse image after copying it back to the original volume).

I didn’t have enough room to turn off FileVault so in the end I logged in as a different user (without FileVault), created my own sparse image and copied the contents of the corrupted FileVault sparse image to my new image.

I then used NetInfoManager and the terminal to try and manually disable FileVault. I then copied the contents of my backup image into the home directory.

Because I used the Finder (as a different user) to perform the copy (I wanted to make sure resource forks were copied and although cp under 10.4 should work fine with the extended attributes I didn’t want to take the risk) I had to manually recursively reset the file ownerships and then copy the dot prefixed hidden file at the root of my user directory.

I now seem to have a working user directory again. I have lost (but used .Mac syncing to get a copy of) my Mail.app preferences. I have also lost my TODO list (kept in OmniOutliner) which ended up containing a fragment of a NetNewsWire subscriptions list. Luckily I kept that in subversion and have only lost a little bit of content. I decided to trash the subversion working directories just in case, but everything was safely checked into the repository and I don’t think I have lost anything.

Everything outside of my FileVault sparse image is also fine (I keep ~/Music, ~/Movies, ~/Pictures and my source code/Xcode intermediate directories outside of FileVault with just symbolic links in their places).

Conclusion:

1) Always investigate a backup failure immediately. 2) Rethink FileVault. I’ve been using FileVault for almost a year with no problems. By moving large/often accessed files outside of FileVault I thought I was managing to get the best of both worlds. I am not sure now whether I am going to re-enable FileVault or not. Right now I’m coming down on the side of not re-enabling it (let’s see if I notice a performance boost in the next few days). 3) Implement a better backup strategy so that if the worst happens I can go back if I have to.

Things that saved my butt: 1) Keeping my home directory on a different partition to my System volume. 2) Having an admin user account ready to use for maintenance tasks. 3) My Lacie Pocketdrive. 3.5) Target Disk Mode (didn’t use it actually, but I easily could have) 4) A copy of the Tiger Install DVD (and the ease in which you can use the Install DVD to repair/investigate a volume). 5) .Mac sync – without this I would have lost my Mail configurations. Not the end of the world but a pain in the butt. 6) Keeping my important documents in subversion. 7) The ability to disable FileVault on a user account by using NetInfo Manager (and by manually copying data from the Sparse Image into the user directory). 8) Disk Utility. Although the disk repair function isn’t as great as (say) DiskWarrior the ability to create disk images and use the disk restore function between real volumes and disk images is fantastic.

This entry was posted in Uncategorized and tagged . Bookmark the permalink.
  • Bruce Campbell
    Oh boy, FileVault (I now call it VileFault) has become corrupt on my Leopard MBP, I found I couldn't log in to my normal working account, and I took the following steps to fix it:

    <ol>
    <li>I logged into the admin account I have had set up on my machine since the beginning so I could do some diagnostics</li>
    <li>Immediately ran DiskWarrior, which reported that all the files could be recovered, but that it couldn't write the repaired directory, as it detected a media fault (I guess this means the damaged sparseimage acts the same as a damaged HD), so I should immediately copy the files to another location.</li>
    <li>I quickly got out my portable backup FireWire drive, plugged it in and copied the files to the backup disk</li>
    <li>Tried several times to copy the sparseimage file to another backup disk, so that I could go back if this whole process doesn't work</li>
    <li>When Finder copy didn't work, I tried using SuperDuper! to copy the sparseimage, but that failed as well.</li>
    <li>In frustration, I trashed the sparseimage, emptied the trash, then copied the recovered file structure from the DiskWarrior run into the Users folder.</li>
    <li>Attempted to log on to my normal account, and got the same message, "You are unable to log in to the FileVault user account "bmc" at this time" with the second line "Logging in to the account failed because an error occurred."</li>
    </ol>
    Is that it? Is there any way to get the OS to "forget" about the FileVault status, and just deal with the recovered directory structure as if FileVault had never been turned on?

    A couple of other pieces of information:
    <ul>
    <li>Running Leopard 10.5.6 now, but upgraded from Tiger.</li>
    <li>FileVault was implemented in Tiger (the old version of FV), and I didn't do the right thing when I upgraded.</li>
    <ol>
    <li>I should have done a full backup.</li>
    <li>I should have turned FV off before the drive got too full to do it.</li>
    <li>I should have done a clean install and migrate, rather than upgrading over Tiger.</li>
    </ol>
    </ul>

    Any assistance greatfully appreciated! This is both painful, and time consuming!
  • Hey Bruce,

    I haven't used FileVault in years - since this blog post actually. Wish I could help but really - might be time to create a new user account and swap your files manually? I don't know.

    Sorry.
  • Visitor
    My favorite remote backup tool for Mac or Windows is JundleDisk.com - highly secure, highly automatic, and very affordable. The service backs an encrypted copy of your data on Amazon S3 servers for about $0.15 per GB. I have FileVault enabled on my local machine and regularily perform a local backup of my data. But a remote backup is also essential.... Mozy.com is also a similar service but I have heard some mixed reviews. Carbonite.com is coming out with a Mac client soon as well....
  • matthew
    i have a similar problem. I enabled firevault on my main account and now when i log in, i get the spinning beach ball of death. i also seem to have a 210 gig home folder AND a 140 gig hard drive (total capacity.) Whenever I select it, it freezes up my computer. When i log in with another account, i look in my home folder and it is empty. Any suggestions?

    P.S.: it is a network account
  • Hi Tom,

    I just dont risk my data by using FileVault any more... But thanks for the link - hopefully it'll prove useful to others.
  • Tom
    I ran into similar issues, and wrote up a howto on fixing it. Let me know if this works for you:

    http://ekettoz.blogspot.com/2007/02/filevault-h...
  • Well in my case the disk underlying the sparse image was corrupt. Copying the sparse image to anothe drive helped me deal with that. IIRC (this was a while ago) the sparse image could be mounted but some data was missing.
  • Venu
    Greetings,

    We have a sparse image which after leaving mounted and experiencing a crash gives the error that it is a corrupted image and can't be mounted.

    Is there any hope to recover this image?

    Does anyone have any experience recovering in similar circumstances. Unfortunately we don't have a backup so this is problematic.

    We read here: /filevault_corruption/
    that you were able to copy the files from your sparse image to another. How do you do this? Our image is password protected (this is the whole point of doing it this way). So anyway we can copy the files from this corrupted image is ok.

    Any suggestions how to do this? That is, save the files?

    Thanks
    Venu
    vee308hotmail.com
blog comments powered by Disqus