Finally resolved: Recovering data after wiping metadata is actually possible, but I need you help with some info


phonetic

Members
Mar 19, 2024
21
15
I need to ask a small favor from the good people of Xiaomi EU Community.

In short, I accidentally wiped the metadata partition on my Poco F3 and now I can't boot into the OS and access my data. I have a lot of pictures, videos and other stuff that I would hate to lose, because of a mistake. But all that is still on the phone, I just can't boot the phone to access it.

Thankfully, there is a way to fix this by creating a full backup of the phone with adb, then using a HEX Editor to manually look through that gigantic file and try to find the files that were in that metadata partition.

A huge thanks to bluet33th, a user from XDA Forums, without whom I would be helpless and couldn't do any of this. It might be a bit complicated and manual process, but it is possible. He explained everything in great detail here, so check it out, especially if you are facing the same problem, this will help you tremendously: https://xdaforums.com/t/how-to-recover-data-if-metadata-partition-was-deleted.4686789/

In order to find these files and put them back where they belong, I need your help, because I have to know their names, exact sizes and at least part of their content, so that I can search for it. Because I'm searching for a specific text in a text file that is 128 GB in size.

I have already tried this on another Xiaomi phone, to make sure this procedure works on Xiaomi phones and it does, but that phone had HyperOS with Android 14 and since every phone and android version is probably different, in order to be sure, I need this information specifically for Poco F3 with Android 13.

It doesn't take long, but if you don't have the time to look inside your metadata partition and tell me which files are inside of that partition and their sizes in bytes, you can just make a backup of the metadata partition and sent it to me, and I'll do the rest of the work.

Here are the steps on how to create a backup:

1) Turn on your phone and boot into TWRP, then connect your phone to a PC, type cmd inside Windows search and run cmd, then position cmd into your platform-tools folder (if you flashed your ROM, you should already have the necessary drivers installed for the next steps to work). For example, if your platform-tools folder on Windows is inside C:\platform-tools, all you need to type into cmd is: cd C:\platform-tools

You can also just go inside your platform-tools folder and type cmd in the address bar and the cmd will start already positioned inside that folder.

2) Then type adb devices and you should see your device, if you do, that means that all the drivers are successfully installed and your phone is detected.
02.png


3) Type adb pull /dev/block/by-name/metadata
03.png


4) After that, you should see a file named metadata inside C:\platform-tools. That is the file that I'm looking for and as you can see, it takes just a few minutes to get it.

You can skip the next steps (5 and 6), but I'll explain them, just in case someone wants to extract these files for themselves, so that you have them in case something like this happens to you. Of course, you can also proceed to extract the files and tell me their names and sizes.

Here is what you need to do:

5) Extract the content of the metadata file, you can use a software like 7-Zip. Go inside that extracted folder, then into vold > metadata_encryption > key

6) Inside of that key folder, you should see a few files. These are the important files and save them somewhere safe in case you ever need them. Since I don't have them anymore, in order to recreate them, I need to know their exact names and sizes in bytes. You can check the size of every individual file by right clicking on the file and choosing Properties. Then look under Size, not Size on disk, and in parenthesis, you should see the size in bytes.
Properties.png


Please, if you could check the size of every file and write down which file has what size. I would really appreciate it.

I'm specifically looking for someone who has a Poco F3 with Android 13 and MIUI, because I'm not sure if HyperOS changed something, so maybe the number of files or their size is different. But feel free to post the information even if you have HyperOS, but please mention that, so that I am aware of it.

Thanks a lot for your help, it really means a great deal.
 
Last edited:
I have a poco f6 pro hyperos a14 phone can you help me, I have the same problem.

I extracted the file metadata

What is the next step?
 
Last edited:
I have a poco f6 pro hyperos a14 phone can you help me, I have the same problem.

I extracted the file metadata

What is the next step?
If you exported the metadata file to your PC before you wiped the partition, then it's simple, you just need to place those files back inside the phone's metadata partition. If you haven't, then you'll need to dump the entire phone storage to a PC and try to find the contents of the files inside that dump, with a HEX Editor.

Check out what the user bluet33th wrote here on how to try and find the contents of the files: https://xdaforums.com/t/how-to-recover-data-if-metadata-partition-was-deleted.4686789/

Now, let's assume that you have found all the files and you just need to put them back inside the phone's metadata partition. If you placed those files inside your platform-tools folder that is in the root of your C: drive. Let's say you created a folder inside that one, named MetadataFiles and placed the files in that folder, so your files are now in: C:\platform-tools\MetadataFiles

Now you need to enter TWRP on your phone, connect the phone to a PC, open cmd inside your platform-tools folder, and run the following commands:

1) Go into phone shell: adb shell

2) Since you probably won't have the key folder, inside /metadata/vold/metadata_encryption, go into that directory first with this command: cd /metadata/vold/metadata_encryption

3) Than create the key folder: mkdir key

4) Exit the shell: exit

5) Put all the files (encrypted_key, keymaster_key_blob, secdiscardable, version) back inside the phone's metadata partition with adb push, one command at the time:
adb push C:\platform-tools\MetadataFiles\encrypted_key /metadata/vold/metadata_encryption/key/
adb push C:\platform-tools\MetadataFiles\keymaster_key_blob /metadata/vold/metadata_encryption/key/
adb push C:\platform-tools\MetadataFiles\secdiscardable /metadata/vold/metadata_encryption/key/
adb push C:\platform-tools\MetadataFiles\version /metadata/vold/metadata_encryption/key/

6) Go into shell again: adb shell

7) Go to: cd /metadata/vold/metadata_encryption/key

8) Change permission for all the files with chmod command, one command at the time:
chmod 600 encrypted_key
chmod 600 keymaster_key_blob
chmod 600 secdiscardable
chmod 600 version

Then just reboot your phone, and it should boot inside the system.
 
Thank you for your interest
The problem is that I am a beginner
I extracted the file (storage-dump-after-wipe.img) which was about 51 GB in size
And by searching in the program (HxD Hex Editor) for (KMKD)
I found something like the attached image
And I did not understand exactly how to extract the file
Note: I think I can put the files in the path (TWRP ) via (/metadata/vold/metadata_encryption/key/) and USB
And I thank you again for your interest.

If the method works for me, I will try to photograph the stages, perhaps it will benefit the community.
 

Attachments

  • 2024-09-22 152821.png
    2024-09-22 152821.png
    523 KB · Views: 12
Thank you for your interest
The problem is that I am a beginner
I extracted the file (storage-dump-after-wipe.img) which was about 51 GB in size
And by searching in the program (HxD Hex Editor) for (KMKD)
I found something like the attached image
And I did not understand exactly how to extract the file
Note: I think I can put the files in the path (TWRP ) via (/metadata/vold/metadata_encryption/key/) and USB
And I thank you again for your interest.

If the method works for me, I will try to photograph the stages, perhaps it will benefit the community.
Unfortunately, that is not the content of the keymaster_key_blob file. I attached the image of how that content of the file with KMKD should start.

As you can see, it should start with pKMblob followed by KMKD. If you can't find that, like I wasn't able to, that probably means that either Xiaomi works a little different and because you have no metadata, some folders appear empty, and when you create the dump, it simply doesn't dump that part of the storage where this content might be, like for example on OnePlus, which bluet33th mentioned. He managed to find the content of the files in the dump.

Or maybe there is another way to dump the storage on Xiaomi, which will include all the encrypted files that now appear as empty. But I haven't found it yet.

If you however manage to find the content of the keymaster_key_blob file, you need to select it inside the Hex Editor, the Decoded text, then go to File > Save Selection... and name it keymaster_key_blob. This will create the keymaster_key_blob file. Now if you scroll inside the dump up or down, you should see content of the other files, for example the content of the version file is just the number 1 in the Decoded text part. But for the other two remaining files, you can only guess the start and end of the content by the size of the file for your phone, which I can't know. For that you'll need to find someone who has the same phone as you, dump the metadata, and check the file sizes.

I guess the content of these files should be somewhere near the the content of the keymaster_key_blob file, just scrolling up or down, you should be able to find it.

The content of the encrypted_key file should be just a little longer than the content of the keymaster_key_blob file. And the content of the secdiscardable file, is a lot bigger.

Keep in mind, there might be some other files needed for your phone, but as I already said, you'll need to find someone with the same phone and check which files are used in the metadata on the Poco F6 phone.

I hope this helps you and you can find the contents of the files inside the dump.
 

Attachments

  • keymaster_key_blob.png
    keymaster_key_blob.png
    35.1 KB · Views: 19
Hello.
I would like to thank you for your help and time, I am grateful and appreciative to you. As well as user bluet33th
First of all, I would like to mention that I am not fluent in English, so I use Google Translate for help.

As for repairing the metadata file.
I gave up :emoji_smile::rolleyes: I am really sorry.
Since I am a beginner, I could not understand what you mentioned correctly,
So I took a copy of storage-dump-after-wipe.img as bluet33th mentioned in his topic : https://xdaforums.com/t/how-to-recover-data-if-metadata-partition-was-deleted.4686789/ The file size was (230) GB.
Then I format the phone and installed a new ROM.
I also took a copy of the metadata file, perhaps it will be useful to anyone who needs it.

The first question: Is there a way to restore the (storage-dump-after-wipe.img) file to the phone again?
The second question: I have a metadata file for the (poco f6 pro) phone, if anyone needs it?

Note:
Regarding the data on the mobile, it is not very important to me because my phone is new and my old phone is working and my important data is in it.
I don't mind trying other methods.
Like finding a way to flash the file (storage-dump-after-wipe.img) file back to the phone.

Again I am grateful to you. Also I am very sorry and apologize to you that I gave up.