When I had this problem today, Google wasn't much help. Thread after thread with this problem and no solution, except of course to wipe the drive.
Files are important, especially your files, right?
I was running OS X 10.10 Yosemite, and was attempting to rid of a Bootcamp partition I set up on my Macbook's SSD. Disk Utility said no, and I figured the problem would be fixed with a disk repair, since I got the same error when trying to create the bootcamp partition. To do this properly, the disk (internal SSD) can't be in use, so I put it in Target Disk Mode and plugged it into my Mac Mini.
I of course have FireVault 2 enabled, and so it asks for the password every time I use TDM. I go to Disk Utility on the Mac Mini and begin the Repair Disk operation for the Macbook's SSD. It fails. Not only that, but it fails to remount the partition. So I unplug it and plug it back in. It asks for the password. I give it the password. No dice. Just hangs.
So I started panicking, I shut off the Macbook, tried to boot it normally. It wouldn't actually do anything, just sit on a black screen (Yosemite replaces the white/light gray background with black). So I rebooted again, this time holding the alt key. It brought up my Macbook's SSD. I selected it, and it started booting. Phew. It asked for my password right off the bat of course, because it's FireVault, and it took it and started booting.
But then it got stuck about 40% of the way through the loading bar (Yosemite also has a loading bar instead of s spinning circle). I tried booting a few times this way, kept getting stuck. Let it sit for a while. Nothing. So at this point I was freaking out. It seemed there was no way to access the files on this drive. I resorted to Googling the problem, but found nothing, aside from how to format my SSD and reinstall OS X. Like I said, though, files are important, so that wasn't an option...
So in order to recover your files from your FileVault 2 SSD, first you must ensure that you are in the same position I'm in. You tried repairing, didn't work. You can hold alt at boot and actually get to enter your password, and OS X does start to boot. If you can't get that far, because that unlocks FileVault, then you may be out of luck.
Otherwise, great! Let's get to work. What we'll be doing is booting OS X into Single-User Mode (Safe Mode + Verbose if you will), and using bash (gasp!), which you may also know as "Terminal", to access the precious files, mount a USB flash drive, and copy said files to said flash drive.
Make sure you have a flash drive of decent size. Ideally it's large enough to fit all your files onto it. Otherwise, if you're like me and all you have is a lowly 16GB drive laying around, that'll still work, you'll just have to make multiple "trips" if you will between your Macbook and the device (hopefully another Mac) you're unloading all these files onto. For clarification, if your flash drive is NOT large enough for all your files, you should have another Mac around that can take the files from the flash drive, so you can repurpose the flash drive for receiving new files from the corrupt drive.
Also, you'll want to make sure that there aren't any external drives plugged into the problem-child Mac. This complicates things down the line.
So anyway, with the Mac off, power it on, and immediately hold alt. Once you're at the "boot drive selection screen", hold command + s and while holding those two, hit enter. In a sec it'll ask for that FileVault password. Go for it, and then you'll see a light show of text, and a cursor at the bottom.
/sbin/mount -uw /
to cancel the automatic shutdown of Single-User Mode and to mount the Mac's HD/SSD.
Insert that flash drive, making sure that it's formatted as HFS+ (Mac OS Extended, Journaled).
hdiutil mount /dev/disk2s2
to mount the flash drive, which 99% of the time will be disk2s2, though if you get an error it probably isn't. Look at the disk in Disk Utility on a functional Mac to verify that the HFS+ part of the flash drive is in fact s2. Also, if you have a Mac Mini Server, or really any Mac with more than one internal HD/SSD, it may actually be disk3. So try disk3s2 if disk2s2 doesn't work.
Next, we'll want to make a mount point for the flash drive on the Mac's internal HD/SSD.
You can replace "flashdrive" what whatever you damn-well please, but do remember what you decide to name it.
Okay, so we didn't really mount the flash drive earlier, that was more so you didn't have to type in this longer command multiple times while trying to figure out if the flash drive is disk2 or disk3, etc.
/sbin/mount_hfs /dev/disk2s2 /Volumes/flashdrive
Of course replace disk2s2 with whatever you figured out your flash drive is, though again, for most people it should be disk2s2.
Note: if you eject this flash drive improperly (just pulling it out), upon reinsertion, it will take the next available disk number. So if it was disk2s2, now it's disk3s2. +1 for every time you do this. It's taking me so many trips to back up all my stuff I'm up to disk5s2, so don't feel too bad if you don't feel like ejecting properly.
If you do feel the need to eject properly, here's the command to do so:
hdiutil eject /dev/disk2s2
Though as long as you're sure there are no file transfers in progress, you're pretty much clear to remove the flash drive improperly. If that white block/cursor is preceded by "bash-3.2#" (or something similar), the transfer is complete. Keep that in the back of your head.
So actually copying the files. Ideally, you know what files you need to back up, and you know where they are. Here's an example snippet for copying your Documents folder to the flash drive:
cp -r /Users/you/Documents /Volumes/flashdrive
Now there are multiple "copy" commands we can use, I went with cp because that's the first one I found in Google. The -r is important because it tells cp to copy all files AND folders (a.k.a. directories) in your specified path. So without the -r, the above command wouldn't copy squat. You could tack on a * at the end of that (../Documents*) to copy all files in Documents, but it would still skip the directories (folders). The more you know.
Anyway, if you have a large enough flash drive, you can backup your entire home folder with:
cp -r /Users/you /Volumes/flashdrive
- If you don't know exactly where thinks are, use the ls command. For example, ls / will list all the folders (directories) in the root of the Mac's HD/SSD. You can work from there. For example, you might not recall where exactly this important file is, but you can use ls /Users/you/Desktop and ls /Users/you/Downloads to see if it's in your Documents folder or your Downloads folder.
-Remember, hidden folders and files are preceded by a period (ie, .localized), and files have their extensions affixed to them (ie, file.txt). Otherwise, it's a folder!
- To navigate to folders with names that have spaces (ie, "iTunes Media"), put a \ in between the last letter of the first word and the space itself to look like so:
- File transfers take considerably longer than if you were using a perfectly-functional Mac. Be patient. Ideally, you have a flash drive like a SanDisk Cruzer that flashes incessantly when it's transferring files. That should keep you content while you nervously wait for the first batch of files to backup.
-Make sure you backed up EVERYTHING that you need before formatting that pesky HD/SSD with the Recovery partition or an OS X USB Installer or Single-User Mode if you like it so much.
- When setting up OS X all over again on the Mac, really, really think before enabling FileVault 2 again. Remember, if not for FileVault, you wouldn't even have been in this mess.