Installing CM9 on an Encrypted Android Tablet

Author: 

Shawn Webb

I love Android. I also love my Transformer Prime tablet. Time has proven to me, however, that CyanogenMod provides both a richer feature set and better stability than stock Android. Around three weeks ago, I traveled from the USA to Canada to attend BSDCan. Knowing how the TSA and US Customs agencies love to think they're above the law, I decided to encrypt my then-stock tablet. This article will explain how to move from an encrypted stock Android installation over to CM9, a not-so-easy feat to accomplish.

Disclaimer
While I hope these directions would be useful for other devices (smartphones included), the commands are specific to the Transformer Prime. You will need to do some research about the partition layout and the commands you'd need to run. This article is meant to be more of a guide and is meant to be adapted to your device. I am in no way, shape, or form responsible for any damage, repairable or not. I will not answer questions or comments about bricked devices. If you follow these steps (or adapt them to your device), you do so at your own risk.

Prerequisites

  • A spare SD card
  • A working adb installation
  • Knowledge of Linux shell commands
  • CM9 and gapps downloaded onto the spare SD card

The dilemma
When you encrypt your Android device, the /data partition is what gets encrypted. The partition in full is encrypted and cannot be mounted within CWM. CWM also cannot perform a wipe, since it cannot mount the /data partition. And CWM cannot mount the external SD card. This is our dilemma. No access to the internal SD. No access to the external SD. No way to perform a wipe and format the internal SD from CWM.

The Solution
What we need to do, then, is use adb while the tablet is in recovery mode to reformat the internal SD card, thereby removing the encryption. On the US Transformer Prime, the internal SD card is at /dev/block/mmcblk0p8. The partition for our spare SD card will be at /dev/block/mmcblk1p1. You will need to replace those device entries for any other device you might attempt this on. After formatting the internal SD card, we will mount it and then mount the external SD card at /data/media:

  • In CWM, wipe cache
  • adb shell
  • mke2fs -t ext4 /dev/block/mmcblk0p8 # Warning: This can take a while. Be patient.
  • mount /data
  • mount /dev/block/mmcblk1p1 /data/media

Now go back to CWM on your device, then go ahead and flash your CM9 and gapps zips like normal. You now have CM9 installed! The /data partition is not encrypted. If you do not need to flash any other ROMs (unlikely if you're reading this article), feel free to re-encrypt your device.

Conclusion
I want to give thanks to utkanos on FreeNode's irc at #cyanogenmod. He helped me put together the pieces as to why CWM wasn't able to mount /data. Because of him, I am now running CM9 on my Transformer Prime. I hope this article helps those who were in my same position.

Tags: 

6 Comments

Nandroid Backup

Hey,

is there any way to do a nandroid backup before wiping phone?
I'm running stock rom and don't wanna brick my prime ;)

With best regards

B-Paul

thank you

Just wanted to say thanks for this - had the same problem on my S3 and your instructions helped me to figure it out. I'm never encrypting a rooted android device ever again... too much of a headache!

Installing CM 10 to TF300T with JB

Hello,
I have similar problem. ASUS Transformer TF 300T with Android 4.1 and it is encrypted. I wish to install CyanogenMod 10. When I run adb shell I get error error: insufficient permissions for device. Otherwise adb, fastboot and so on work fine... Any idea how to solve it? And how can I get blocks for EU TF300T?

Installing CM 10 to TF300T with JB

Hello,
I have similar problem. ASUS Transformer TF 300T with Android 4.1 and it is encrypted. I wish to install CyanogenMod 10. When I run adb shell I get error error: insufficient permissions for device. Otherwise adb, fastboot and so on work fine... Any idea how to solve it? And how can I get blocks for EU TF300T?