Tuesday, May 24, 2016

How to: Fix a corrupted DATA partition on the One



Since the One was relsed, I've had a few users asking me to help them fix their device. They couldn't boot their system or access anything on the DATA partition from inside custom recovery. Why this happens so often on the One I have no id...

Here is a short guide explaining how to fix this problem without sending the device for repair under warranty.

Short Explanation

This method can be used to fix any other partition too, just remember about changing the mount point - from "mmcblk0p37" to the relevant one. For example, the SYSTEM on the One is "mmcblk0p35". In some rare cases the mkfs.ext4attributes(likedir_nlink orresize_inode) might change too! To get a list of all eMMC mount points on devices use the command /proc/emmc. Never format RAW partitions! This method can be used only to format EXT4 partitions. Not following the guide properly might endin permanent damageto your device. I do not take any responsibility for that.
Some people might also find this helpful in case of need to remove the entire contents of the virtual SD-card. As long as the virtual SD-card is not a separate partition, (i.e. it isemulatedspace on the DATA partition [/data/media]) it can't be formatted - only wiped cln. I wrote an in-depthexplanation of how the virtual SD-card works on Android here -Virtual SD card on Android.
How Do I Recognise The Problem?
When trying to mount the DATA partition from inside the custom recovery using themount /datacommand you will most likely see this output: mount: mounting /dev/block/mmcblk0p37 on /data failed: Invalid argument
To be 100% sure you can check filesystem structure with the following command: /sbin/e2fsck -n -f /dev/block/mmcblk0p37
Repair Process
Note: the content of your DATA partition will be lost, including the contents of your virtual SD-card! I also assume you alrdy have custom recovery flashed and you are a user -LINUX people plse amend as needed.Download thismini-sdkpackage and extract it to c:\mini-sdkDownload this mkfs.ext4binary and put it into c:\mini-sdkConnect your device to the PCBoot your device inrecoverymodeOpen a command prompt on the PC (cmd.exe), type and confirm ch command with ENTER: /d c:\mini-sdkadb push mkfs.ext4 /tmpadb shellchmod 777 /tmp/mkfs.ext4/tmp/mkfs.ext4 -b 4096 -O ^huge_file,^dir_nlink,^ext_attr,^resize_inode,^extra_isize -m 0/dev/block/mmcblk0p37 of the whole command in one line to avoid mistakes:
Now your DATA partition will be formatted. It is not the same as "wiping", which is only removing all or just some files from particular partition. Formatting mns that the entire partition will be re-crted with the above attributes. You should see the following output:

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
1703936 inodes, 6815744 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
208 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768,98304,163840,229376,294912,819200,884736,1605632,2654208,4096000
Writing inode tables: done
Crting journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 25 mounts or180 days, whichever comes first.
Use tune2fs -c or -i to override.Your DATA partition is now completely empty, so we need to copy our particular ROM zip file there:Copy ROM zip file toc:\mini-sdk and rename it to "rom.zip"In the same command prompt windowtype and confirm ch command with ENTER:mount /datamkdir -p /data/media/0exitadb push rom.zip /data/media/0Copying rom.zip to the device will take a few minutes. Wait until it's done. The output should be: xxxx KB/s (xxxxxxxxxx bytes in xxx.xxxs).Now you can flash rom.zip from inside custom recovery. Done!

Have any questions or comments? Feel free to share!Also, if you like this article, plse use media sharing buttons (Twitter, G+, Facebook) below this post!

No comments:

Post a Comment