[Motorola Droid 4] dicer42:
Encryption

I have been trying to get the device encryption working and wanted to share some of the things I found out so far:

1. If you create a new ROM slot (or even with the stock slot), chances are that your data partition is not formatted correctly to work with encryption. This is because the filesystem needs to be a bit smaller than the partition. Safestrap doesn't seem to take care of this when adding new rom slots. Also: Each time wiping with the Advanced -> Settings -> "Use rm -rf..." option disabled, the home partition will not work after that anymore. So I guess this affects basically everyone with a custom rom.

How to find out?

If you go to Settings -> Security -> Encrypt phone and the android with gears will not go away even after a minute, you are affected.

If you connect via adb logcat you can see the following error in the log:

E/Cryptfs ( 237): Orig filesystem overlaps crypto footer region. Cannot encrypt in place.

There is an easy fix to this: Make the filesystem a bit smaller. See this thread for more than enough info on this: http://xdaforums.com/showthread.php?t=2122702

Unfortunately those flashable patches are not working with Safestrap. So I modified the second one a bit (removed all the logging) and it can now fix the userdata filesystem (see attached file)

As always: Make a backup though! ;)

2. After I got that out of the way, I was able to actually start the encryption. The phone would just reboot though, never encrypting anything. adb logcat showed:

E/Cryptfs ( 179): unmounting /data failed
E/Cryptfs ( 179): Error enabling encryption after framework is shutdown, no data changed, restarting system

There is an issue with lots of comments over at Googles android bug tracker: https://code.google.com/p/android/issues/detail?id=58073

None of the suggestions helped in my case. What did help is the following:

Open a shell with adb. Then, right after you hit the "Encrypt phone" button in the third step issue this command:

root@cdma_maserati:/ # umount /pds && umount /data/tmp

This first seems to make Cyanogenmod reload (startup animation is showing) but after that the encryption sets in. This might take a while and unfortunately we don't seem to have adb log access at this stage. It seems to finish just fine though.

Now for the not so good part: After rebooting I get asked for the password. If I enter a bogus one I get an error. That's good. If I enter the correct one, the gear droid shows for a second and then I get a black screen. Nothing happens, even after several minutes. No adb log access either.

Has anyone been able to turn on encryption on their droid4? Any ideas why this happens? Or why I have to manually umount stuff? And what is /pds anyway?

I tested with stargos cm11 and with official cm11 nightlies. A friend used a cm11 nightly on his S4 Mini, so I guess this should be working in cm11!

Any ideas? I've been debugging this for days now! Can't count the times I had to wipe data... Btw: Every time you get the black screen after encryption reboot, you need to wipe data. Make sure Advanced -> Settings -> "Use rm -rf..." is disabled! Recovery obviously can't mount data anymore. After wiping, apply my shrink fix again.

Also: I will post this fix as its own topic as soon as I actually got it working...