Skip to content

Instantly share code, notes, and snippets.

@L-P
Last active October 9, 2020 08:27
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L-P/7285035 to your computer and use it in GitHub Desktop.
Save L-P/7285035 to your computer and use it in GitHub Desktop.
Removing device encryption on a Samsung Galaxy S3 (i9300) running CyanogenMod 10.1

Removing device encryption on a Samsung Galaxy S3 (i9300) running CyanogenMod 10.1

I couldn't disable the full-device encryption on my phone even by doing factory resets both from Android and the recovery mode, the later being unable to mount /data. There was a lot of people complaining about this on the internet but nobody provided a working solution so I had to investigate this myself.

Note: this will erase everything as would a factory reset do.

I hope this bit of knowledge will be useful to you.

TL;DR: recreate ext4 partition on /data

1. Get ADB

ADB can be found in the ADT bundle of the Android SDK [1] On debian-based distributions, ia32-libs needs to be installed for ADB to run. If you get a "file not found" error when running adb, run the following commands:

$ dpkg --add-architecture i386
$ apt-get update
$ apt-get install ia32-libs

[1] : http://developer.android.com/sdk/index.html

2. Boot your device into recovery and launch ADB

To boot the i9300 into recovery mode, turn it off and turn it on while holding the "home" and "volume up" buttons. When the "Samsung SIII" logo appears, release the buttons.

Plug the phone to the computer via USB and run the following commands:

$ adb usb
$ adb root
$ adb -d shell

You are know in a BusyBox environment running on your phone.

3. Obtain the partition number for USERDATA

To get the partition number for / run parted and the parted print command:

$ parted /dev/block/mmcblk0
GNU Parted 1.8.8.1.179-aef3
Using /dev/block/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
print
Model: MMC VTU00M (sd/mmc)
Disk /dev/block/mmcblk0: 15.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name      Flags
 1      4194kB  8389kB  4194kB               BOTA0
 2      8389kB  12.6MB  4194kB               BOTA1
 3      12.6MB  33.6MB  21.0MB  ext4         EFS
 4      33.6MB  41.9MB  8389kB               PARAM
 5      41.9MB  50.3MB  8389kB               BOOT
 6      50.3MB  58.7MB  8389kB               RECOVERY
 7      58.7MB  92.3MB  33.6MB               RADIO
 8      92.3MB  1166MB  1074MB  ext4         CACHE
 9      1166MB  2777MB  1611MB  ext4         SYSTEM
10      2777MB  3364MB  587MB   ext4         HIDDEN
11      3364MB  3372MB  8389kB               OTA
12      3372MB  15.8GB  12.4GB               USERDATA

/data is partition number 12 (USERDATA) on my device. The block device is then /dev/block/mmcblk0p12.

3. Create a new partition on /data.

Run mke2fs -t ext4 on the block device you got at the previous step.

$ mke2fs -t ext4 /dev/block/mmcblk0p12
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
755904 inodes, 3022848 blocks
151142 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=3095396352
93 block groups
32768 blocks per group, 32768 fragments per group
8128 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

4. Reboot

Reboot your device, you should see the CyanogenMod welcome/install screen instead of the Android password prompt.

@slisznia
Copy link

slisznia commented Dec 2, 2013

Your instructions worked great on Nexus 10 - CM-10.2. I suggest title change to:
"Removing device encryption with ClockworkMod Rrecovery"

@clschnei
Copy link

clschnei commented Dec 4, 2013

This won't wipe "sdcard" correct?

@gioannou
Copy link

Hi,

My device just randomly crashed one day while I was charging it, and it refused to boot after the fact.

Device: Galaxy S3 - GT-I9300
Firmware: CM 11 - 4.4.2 (Nightly)
Recovery: CWM
Encryption: YES

Because of the encryption I was unable to flash the device using ODIN, HEIMDALL, or Samsung Kies. They all just gave up either immediatley or after some time.

I would like to follow the above the steps, but when I use the following command in the ADB shell:

parted /dev/block/mmcblk0

it points me to the EXTERNAL sd card, not the internal one. If I remove the external card, then I get no results.

Where should I go from here to completely wipe the device?

Thank you very much,

George

@L-P
Copy link
Author

L-P commented Mar 10, 2014

@clschnei 'sdcard' is the (idiotic) name of the internal memory IIRC so it will be wiped. I don't have the device anymore so I can't confirm.

@gioannou no idea.

@andyg54321
Copy link

Great post. I would add: Leave at least a 16 KB space at the end so that encryption can be re-enabled later.

My S3 had the same numbers as OP. I used the following command that allowed encrypting again afterwards:
mke2fs -T ext4 -L data /dev/block/mmcblk0p12 12058624

Source:
http://forum.cyanogenmod.com/topic/82292-cm102-encryption-does-not-start-stuck-at-splash-screen/

@niko-dunixi
Copy link

I found this in google but it didn't work for me. I had to install TWRP recovery and force wipe everything. By everything I mean everything. I had to reinstall CM from recovery again because the rom itself was wiped. This was the only way I was able to remove encryption.

@tmhpfnr
Copy link

tmhpfnr commented Oct 25, 2014

Ty, that helped me.

FYI: On my device Galaxy Tab 2 (P5110) the data portion name is DATAFS and number 7.

@guilhermehecosta
Copy link

Thanks so much! Worked very fine for me. I'm using Cyanogem 13, Android 6.

@amini8
Copy link

amini8 commented Jan 29, 2017

Thanks, CM 14, Android 7
Can I translate it to Persian and put my github page ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment