I have a smartphone that is running Android 6.0 Marshmallow. I encrypted the device using the builtin mechanism. Unfortunately I forgot the password (intentionally). The only option to recover the phone is to Factory Reset the device, either from its recovery mode or using fastboot.

My smartphone has the TWRP recovery. When I wanted to Factory Reset the device using this mode, I simply couldn't do that because TWRP wasn't able to mount the /data/ partition:

enter image description here

So the question is simple: How to Factory Reset an encrypted device using the TWRP recovery? Is that even possible? Does TWRP recovery support this action?

  • Is your recovery ported or buold from source, maybe developer screwed recovery.fstab file. In theory twrp shouldn't have problems with /data encrypted. However if you can't wipe from twrp. Flash stock firmware it should handle things. – Једноруки Крстивоје Feb 11 '17 at 19:14
  • 1
    The TWRP recovery was ported from another device. I wrote the fstab file and wiping unencrypted /data/ partition works well. I added length=-16384 and encryptable=footer to the /data/ entry, but this did nothing (I know the key is at the end of this partition and not on a separate one). I also know that the stock recovery can fix this, but I just want to do it via TWRP. – Mikhail Morfikov Feb 12 '17 at 10:53
  • You are probably doing some wrong with .fstab. Ask question on stack owerflow or xda, developing and programming questions are offtopic here – Једноруки Крстивоје Feb 12 '17 at 11:43
  • TWRP > “Wipe” > “Format data” to re-format and mount “/data”, which deletes all data. – caw Oct 7 '20 at 19:24

I've managed to solve this issue. Apparently the ported TWRP image didn't have support for encryption. That's why it tried to mount the encrypted /data/ partition. I've build the image from source, and I've set the following flag:


Now it can detect the encrypted partition:

enter image description here

The only problem is that it can't decrypt the data with the right password. Maybe something else is missing.

  • Can you elaborate on how you made TWRP recognize the partition? I'm having the same problem but definitely not nearly as skilled as you in this department. I'm finding it hard to believe that I can't save an encrypted partition; wipe the device; reinstall the same rooted stock OS I was using; add the data partition and use the same password to decrypt the data. I'm probably very niave. – hortstu Oct 16 '18 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.