My phone failed to encrypt after I rooted it. So this is the solution:
The problem is, that there is no space left for the encryption header. so you need to make the partition smaller in order to encrypt it.
- install TWRP and go into the console
- find out what is your data partition. it should be something like /dev/block/mmcblk0XX
- umount your data partition
umount /data umount /sdcard
- Now display the block count of your partition (e.g. 6661115)
tune2fs -l /dev/block/mmcblk0pXX
- wirte this „Block count:“ on a paper and reduce it by 8. This should be something like 32kB.
- check your partition before reducing it.
e2fsck -f -p /dev/block/mmcblk0pXX
- Now you can reduce the partition size by invoking:
resize2fs /dev/block/mmcblk0p26 6661107
- now you need to reorder your file system with this command:
e2fsck -f -p /dev/block/mmcblk0p26
- restart and encrypt your file system.