[Galaxy S 4 Mini Original Android Development] Whitest:
RE: Encryption

I apologize if this is too much Off-Topic talk - but encryption not working is a common issue in CM.

I came across this problem a while ago, too - so I'll gather the information I collected about this issue to help others who want to encrypt their /data partition and have similar symptoms. Mine were the described soft reboots after starting the encryption process.

What CM actually encrypts is the /data partition of our S4 Mini.

For encryption to work again in CM you'll need to shrink the file-system of your /data partition. If you ever formatted your /data partition in CWM or TWRP the file-system will now use the whole space available. The problem now is, that for encryption to work 16 kbytes of free space in your partition is needed for the Crypto Footer (where encryption header information is stored).

and a quote from that link:

If you would start a logcat before starting the encryption process you'll probably see this error, too.

StockRom formatting always takes care of leaving this little bit of free space in the file-system, but CWM/TWRP partitioning doesn't. So one workaround for you guys would be to backup everything into a nandroid backup, get a working StockRom image, flash it via Odin with a valid PIT file (where the partition information is stored) and later repeat the usual steps to get back to CM 12.1 but without ever formatting the /data partition (factory reset (wipes everything except your internal storage) is sufficient)

I ran into this problem, too and didn't want to hassle with all this but instead looked for a possibility to shrink the file-system without the need to flash StockRom. I went through a lot of information on how to do it and finally did it and can tell you it's possible.

If you are up to it and a bit adventurous or just an experienced linux user have a read here and look especially at diogenesj's post

PLEASE MAKE SURE YOU KNOW WHAT YOU'RE DOING before starting to mess with partitions in your phone because you can really mess thinks up this way! I'm not responsible for you bricking your smartphone.

mke2fs command formats your /data partition so be sure to backup first! I'll leave the necessary maths and research to you (hint: partitions of the Galaxy S3 and S4 Mini are NOT the same! our /data partition usually resides at /dev/block/mmcblk0p24)

Still interested? Read on through these topics to learn more before you start:

Topic 1

Topic 2

Topic 3

Also keep in mind that CWM recovery can't read encrypted /data partitions until now. So if you want a full working recovery you'll have to switch to TWRP.

Also first set a screen lock pattern (PIN/password) before starting encryption. If you later want to separate PIN and encryption password (stronger encryption pass and easy screen unlock pin) you can use the app Cryptfs Password (requires root & works best with SuperSU) - additional information: have a read Encryption strength in Android

Summary: basically as we don't have any hardware encryption support on our S4 Mini your encryption will only be as strong as your password is. 4 digit PIN = not strong. On the other hand you don't want to enter a 20 letter password everytime you want to unlock your screen. With the mentioned app you can solve this problem. First set a easy to remember PIN for your screen lock and initial encryption. Later set a strong encryption password you'll only need to enter each boot in "Cryptfs Password" App