Removing encryption is not something you would usually want to do, but in some cases – such as debugging or avoiding encryption side-effects – this may be useful.
After encrypting your phone, Android does not offer an easy way to reverse this. You probably end up asking the internet, only to find out the common advice is to do a factory reset and restore from the Google backup (or use adb backup
/ adb restore
). This was not an option for me because Android backups suck (more on this in a later blog post).
Android’s Device Encryption encrypts the partition mounted at /data (when decrypted), so my plan was to replace /data with its decrypted self. Fortunately, this is quite simple using TWRP. I assume your device is connected and you have adb and fastboot installed.
- Boot the TWRP recovery
- Enter your decryption password when asked to
Or useadb shell twrp decrypt $password
. - Identify the /data device location:
adb shell df /data
This will include the path to the block device, such as/dev/block/mmcblk0p50
. - Write /data to an image:
adb pull $blockdevice userdata.img
Do not use TWRP backup to do this! Your backup will be incomplete. - In TWRP, select Wipe → Format Data
This step is required because it lets the OS know the data partition is no longer encrypted - Reboot to bootloader:
adb reboot bootloader
- Write the image back to /data:
fastboot flash userdata userdata.img
- Reboot:
fastboot reboot
That’s it, enjoy your totally unsecured phone!
Notes:
- Technically, there would be a more efficient way to achieve this (i.e. without storing and restoring the partition) by doing the reverse of Android’s inplace encryption: It would read each sector of the block device, decrypt it, and write it back, but cryptfs doesn’t implement it.
- There is a “Decrypt Phone” option in Samsung’s Android version, which I assume works that way.
- I don’t know what happens when you just copy the decrypted /data partition to the actual device, but it probably results in a mess ¯\_(ツ)_/¯