I encrypted my phone but now want it not encrypted so have to factory reset. However, if I try to do this from the CWM Recovery it says

-- Wiping data... 
Formatting /data...  
Error mounting /data!  
Skipping format... 
Formatting /cache...  
Formatting /sd-ext...  
Formatting /sdcard/.android_secure...
Error mounting /sdcard/.android_secure!
Skipping format... 
Data wipe complete.

When I try to factory reset from the normal GUI it doesn't give me an error but finishes very very quickly and hasn't worked (presumably the output above has happened in the logs).

What can I do?

  • Have you tried re-flashing the original recovery that shipped with the device? Perhaps that would allow you to perform a factory reset via the device's settings menu. Commented Nov 14, 2012 at 20:31
  • I've tried to do this but can't work out how to do it via Heimdall (Linux implementation of ODIN) - does it have to be via ODIN? Where would I find my original recovery? I may be just doing it wrong - which HOWTO should I be following for this?
    – Gausie
    Commented Nov 14, 2012 at 22:58
  • 1
    I would think Heimdall could do it as long as you could find a stock recovery image in the proper format. What specific device is it? Often the XDA sub-forum for a device will have a collection of various stock images, so that's where I'd start, personally; the manufacturer may provide them, too, though (I've never really checked if Samsung does this). Commented Nov 15, 2012 at 0:01
  • Is this right? forum.xda-developers.com/showthread.php?t=1863346
    – Gausie
    Commented Nov 15, 2012 at 11:28
  • 1
    Hm, I'm not entirely sure if the ROM package in those instructions has a recovery image or not. If it does, then that should work. There's another thread on XDA that talks about unrooting the S3 which might help, too: forum.xda-developers.com/showthread.php?t=1710613 That should reflash your device back to stock Samsung firmware (it talks about Odin but you should be able to substitute Heimdall as far as I know). Commented Nov 15, 2012 at 16:07

1 Answer 1


I have also encrypted the /data partition (on my Samsung I9300) and wanted to reset it for an upgrade. This failed with the error you mentioned, /tmp/recovery.log contains:

ClockworkMod Recovery v6.0.3.2
recovery filesystem table
  0 /tmp ramdisk (null) (null) 0
  1 /efs ext4 /dev/block/mmcblk0p3 (null) 0
  2 /boot emmc /dev/block/mmcblk0p5 (null) 0
  3 /recovery emmc /dev/block/mmcblk0p6 (null) 0
  4 /cache ext4 /dev/block/mmcblk0p8 (null) 0
  5 /system ext4 /dev/block/mmcblk0p9 (null) 0
  6 /data ext4 /dev/block/mmcblk0p12 (null) -16384
  7 /preload ext4 /dev/block/mmcblk0p10 (null) 0
  8 /modem emmc /dev/block/mmcblk0p7 (null) 0
  9 /sdcard datamedia /dev/null (null) 0
  10 /external_sd ext4 /dev/block/mmcblk1p1 (null) 0
-- Wiping data...
Formatting /data...
I:Formatting unknown device.
W:failed to mount /dev/block/mmcblk0p12 (Invalid argument)
Error mounting /data!
Skipping format...

DISCLAIMER: I am not responsibility for anything that goes wrong, including (but not limited to) user error.

If you wish to wipe the /data partition completely (including media like photos), follow the below instructions:

  1. Boot into recovery.
  2. Run adb shell in a terminal (Linux) or Command Prompt ("CMD", Windows). After a few seconds, you should see a line containing ~ #.
  3. WARNING. Triple-check the command that you are entering here. White space and capitalization are important. Make any mistake here and you may accidentally wipe your whole flash memory including recovery images.
    NOTE: if you want to encrypt your partition later, you have to leave 16KiB unallocated space on the end of the partition.
    In the adb shell, run the command mke2fs -t ext4 /dev/block/mmcblk0p12. Substitute /dev/block/mmcblk0p12 and ext4 according to the recovery filesystem table (for /data). Output when running the command:

    ~ # mke2fs -t ext4 /dev/block/mmcblk0p12 
    mke2fs 1.41.14 (22-Dec-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 34 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
  4. (Optional) Install new firmware (E.g. CM 10.1).

  5. Reboot.
  6. (Optional) In order to encrypt the partition while clearing your whole data partition, run vdc cryptfs enablecrypto wipe PIN_OR_PASSWORD (before Android 5.0) or vdc cryptfs enablecrypto wipe password PASSWORD_IN_HEX (since Android 5.0, see this post for details).
  7. Reconfigure device, choose language, enter name, install apps, etc.

Technical details below.

The factory reset menu item activates erase_volume("/data") in recovery.c which calls format_volume("/data").

format_volume is defined in roots.c:

int format_volume(const char* volume) {
    // <snip>
    // check to see if /data is being formatted, and if it is /data/media
    // Note: the /sdcard check is redundant probably, just being safe
    if (strstr(volume, "/data") == volume && is_data_media() && !handle_data_media) {
        return format_unknown_device(NULL, volume, NULL);

Since the volume name indeed starts with /data, and the recovery filesystem table contains an entry for type datamedia and handle_data_media is initially zero, format format_unknown_device is called. That function is defined in extendedcommands.c as follows:

int format_unknown_device(const char *device, const char* path, const char *fs_type)
    LOGI("Formatting unknown device.\n");

    if (fs_type != NULL && get_flash_type(fs_type) != UNSUPPORTED)
        return erase_raw_partition(fs_type, device);

    // if this is SDEXT:, don't worry about it if it does not exist.
    if (0 == strcmp(path, "/sd-ext"))
        // <snip>

    if (NULL != fs_type) {
        // <snip>

    if (0 != ensure_path_mounted(path))
        ui_print("Error mounting %s!\n", path);
        ui_print("Skipping format...\n");
        return 0;

fs_type is NULL and the path is /data. That means that the code path ends up at ensure_path_mounted(path) which is the place where this function fails. Looking at the name, ensure_path_mounted attempts to mount the partition by name which of course fails since the encrypted partition is not supported in CWM. Therefore, CWM refuses to "format" the partition (actually, all it does is erasing all files except for /data/media after mounting).

Therefore the goal is to format /data with ext4 (see recovery filesystem table) or mount the encrypted data partition somehow. I could not easily find the tools for mounting encrypted partitions, so I decided to go the easy way and just format the partition.

  • Note: apparently somebody managed to wipe his boot partition anyway. Hereby a friendly reminder: double-check that you are actually acting on the right partition!
    – Lekensteyn
    Commented Mar 9, 2015 at 1:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .