[Guide] About repairing/fixing the persist partition

Search This thread

Allx0021

New member
May 18, 2019
2
0
method 1- adb commands: working on redmi note 7 lavender, everything returned to normal, even wifi, although the proximity sensor and varometer do not work or maybe this device does not have them, and as expected the DRM is in L3. THANK YOU SO MUCH Yuki1001
 

pndwal

Senior Member
Is your persist partition broken? If so just flash it. Don't think too much. The phone works normally is the first thing. And sorry, I don't know if it will effect the widevine DRM security level. Don't use it like a toy. Persist means "persist", its data should not be changed after shipping. Only flash it when your persist partition is broken or cannot works properly.
Hi Yuki1001

Great guide / fix!

Could you please do us (all those concerned with restoring Widevine DRM L1 security / TEE for HD video streaming after persist corruption) a favour if you still have this device? (I have RN8T.)

Please can you install and open DRMInfo app, and just say if Security level is L1 under Widevine CDM?

Many thanks, PW 👍
 

Yuki1001

Senior Member
Hi Yuki1001

Great guide / fix!

Could you please do us (all those concerned with restoring Widevine DRM L1 security / TEE for HD video streaming after persist corruption) a favour if you still have this device? (I have RN8T.)

Please can you install and open DRMInfo app, and just say if Security level is L1 under Widevine CDM?

Many thanks, PW 👍
Hello pndwal:

I still have RN8 (as one of my backup phones) because it has the ability to try out anything without interrupting my work. Flashing persist is necessary when your persist partition corrupts which may cause sensors fail. Your DRM level changes to L3 at the time you unlock the bootloader.

BR.
 
Last edited:
  • Like
Reactions: pndwal

pndwal

Senior Member
Hello pndwal:

I still have RN8 (as one of my backup phones) because it has the ability to try out anything without interrupting my work. Flashing persist is necessary when your persist partition corrupts which may cause sensors fail. Your DRM level changes to L3 at the time you unlock the bootloader.

BR.
But it seems most MIUI devices don't actually lose Widevine L1 security (for decoding HD in TEE) with bootloader unlock; only if persist is corrupted... That's why I wondered if your fix, particularly 1) Restore from persist.bak, restores L1...

I have Redmi Note 8T, stock, rooted... Always had L1:
IMG_20220428_212126.jpg

🙂 PW
 
  • Like
Reactions: pnin

Yuki1001

Senior Member
But it seems most MIUI devices don't actually lose Widevine L1 security (for decoding HD in TEE) with bootloader unlock; only if persist is corrupted... That's why I wondered if your fix, particularly 1) Restore from persist.bak, restores L1...

I have Redmi Note 8T, stock, rooted... Always had L1:
View attachment 5600539
🙂 PW
My RN8 is obviously L3.

At that time I had only thought my phone was damaged, with strong nervous I found the persistbak and did a dd command to restore the persist. Then I'd like to help everyone who did something same with me to get out of such situation with an easy solution. Then I made these flashable zip files and uploaded to the thread.

I've lost my original persist/persistbak backup and have overwritten the 2 partitions for many times so my phone will last L3 forever. But if you didn't touched persistbak, do a backup of its raw data to a safe place in order to restore your own unique image, instead of a generic persist.img.


The generic persist.img is only for emergency situation, but it's surely a way to fix, isn't it?


Actually I seldom touch DRM content. I buy DVDs and CDs for watching films and listening to music.
 
Last edited:
  • Like
Reactions: pndwal

pndwal

Senior Member
My RN8 is obviously L3.

At that time I had only thought my phone was damaged, with a strong nervous I found the persistbak and did a dd command to restore the persist. Then I'd like to help everyone who did something same with me to get out of such situation with an easy solution. Then I made these flashable zip files and uploaded to the thread.
Yup... Thanks
I've lost my original persist/persistbak backup so my phone will last L3 forever. But if you didn't touched persistbak, do a backup of its raw data to a safe place in order to restore your own unique image, instead of a generic persist.img.

The generic persist.img is only for emergency situation, but it's surely a way to fix, isn't it?
I lack experience with this, but as I understand it, generic image won't change existing device-specific (unique) data / numbers, whereas device-specific backup will... So I guess either should fix basic corruption, but you wouldn't want to flash device-specific persist on a different device...

I may also be wrong about this! 😝

I've learnt a bit about Widevine security from posts in Magisk General Discussion and other threads, and note it's implementation seems to vary a lot across OEMs.

Eg, on OnePlus and other, widevine itself seems to poll SafetyNet, and L1 is lost on unlocking bootloader, but can be restored w/ SafetyNet passing by means of Universal SafetyNet Fix module etc... On MIUI, other users report that like RN8T, their devices retain L1... It may be that only corrupted persist breaks this...

- https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-86770675
- https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-86771223
- https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-86771507
Actually I seldom touch DRM content. I buy DVD and CDs for films and music.
Good... Is L3 Widevine the only persist related issue you are aware is remaining? PW
 

Yuki1001

Senior Member
Is L3 Widevine the only persist related issue you are aware is remaining? PW

In fact it is related to sensors and carrier network (and more). Widevine Security Level is not the point to talk. Obviously, there is no way we can accept the carrier network and sensors stop working.


generic image won't change existing device-specific (unique) data / numbers, whereas device-specific backup will... So I guess either should fix basic corruption, but you wouldn't want to flash device-specific persist on a different device..

Yes. The generic image only contains some basic sensors' startup data. But it's a complete filesystem image so it will overwrite your all previous data in persist partition. Flashing the image is not an incremental operation to the partition.

Exactly, the DRM security key is stored in persist partition. Only untouched persist and persistbak after shipping include the DRM Decryption Key.

It's consistent with the posts what you mentioned. So if you lose your device-specific persist.img backup and persistbak (the security key), you will lose L1 forever.
 
Last edited:
  • Like
Reactions: pndwal

Zibri

Senior Member
Dec 10, 2010
370
124
On a healthy system that has only a bad persist partition, all is needed is just a line of code from any recovery image:

dd if=/dev/block/by-name/persistbak of=/dev/block/by-name/persist conv=notrunc
and then a reboot.
persistbak is never really backed up by the system and should be identical to persist.img you find in your firmware.

I just tried erasing persist... then I was in a soft boot loop... so I copied persistbak to persist (or persist.img to persist) and the result was the same. Same contents.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 30
    Disclaimer: I am not responsible for the results of any of these operations.


    Everyone knows that the persist partition is responsible for sonsors and carrier network etc. Once this partition is failed or lost, your phone will go wrong. I just faced, then solved the problem and I want to share the solution that could maybe help other persons.

    This was how it happeded:
    While I was flashing the phone, I erased the partition called "persist" accidently. When I was trying to flash the persist partition, the phone returned a message said that you can't flash the controlled partition. I suddenly relized something bad happened. Then I reboot the phone and find that many sensors stopped working. But the worst thing is the carrier network signals lost. I want to contact the service center at first. But I think as long as the phone is unlocked, there are tons of possibilities to fix it, unless it's hard-bricked. So I wanted to try to fix the partition.

    As we know, Xiaomi phones have backup partitions for most of the important partitions. For example, vbmeta and vbmetabak partitions. The vbmetabak usually is the backup of vbmeta. This persist partition also has a backup partition called "persistbak". This backup partition can be used to repair the persist partition. There are 2 ways to fix the persist partition. Choose the method you preferred.


    1. This way is for users have erased the persist partition, but haven't modified/erased the persistbak partition. If you don't want to type commands just use method 2.
    Go to fastboot, flash the twrp recovery first. Then hold the POWER and VOLUME UP to force the phone boot to twrp recovery. Connect the phone to your PC and open adb command window. Type the following commands in order:

    adb shell

    cd /dev/block/by-name

    ls -all

    Check the output, find the partitions called "persist" and "persistbak". Remember the blocks corresponding to these two partitions. They should be similar to "mmcblk0p**". Once you know these correspondences, you can restore the persist partition immediately. For example, the persist partition and persistbak partition correspond to mmcblk0p$$ and mmcblk0p%% respectively (persist---->mmcblk0p$$ and persistbak---->mmcblk0p%%). Run this following command to restore your persist partition:

    dd if=/dev/block/mmcblk0p%% of=/dev/block/mmcblk0p$$

    Note: You need to replace "mmcblk0p$$" and "mmcblk0p%%" with the real partition block name.

    Now the persist partition has been fixed/restored. Reboot your phone to system and check whether sensors and carrier network etc. all work fine.


    2. This way is for users that have erased persist partition and persistbak partition or can't restore the partition using method 1. Also, this method is a universal and easy way to fix both persist partition and persistbak partition. It doesn't need to type any command but only a swipe.
    I have made the persist partition repair tool for both global version and Chinese version. Both of them are in attachments. These tools make the repair process very easy. Both flashable zip files are tested on my Redmi Note 8 and they work fine.
    I have also posted them to Mi Community.
    Flash the repair tool in attachment. Choose the right file and flash it.
    Now the persist partition and persistbak partition have been fixed/restored. Reboot your phone to system and check whether sensors and carrier network etc. all work fine.


    If you think it's useful, please click the "Like" button.
    2
    Does this fix "device storage corrupted" error?
    Actually I have this error but my sensors, carrier, wifi ... Etc all working great this error still appears. Anyway I think magisk hide config props module damaged my device's persist when I changed the fingerprint then I came back to stock rom and this error happened so my question is: is this process risky Or could cause losing mac or imei? And am I going to lose widevine l1?
    I'm thinking about backing up my current persist before proceeding do you think it's a good idea?

    Yes. It can fix "find device storage corrupted" . You won't lose your imei or mac. At that time I erased the persist partition by a command "fastboot erase persist" accidently. I have tried both method 1 and 2, and the error is no longer appeared.
    About backing up, the persistbak partition is a backup partition for your current persist partition. So if you failed, just restore the persistbak to the main persist partition. And you can also export the raw image of your current persist partition. Of course, the error will appear if you restore the corrupted persistbak.
    1
    Disclaimer: I am not responsible for the results of any of these operations.


    Everyone knows that the persist partition is responsible for sonsors and carrier network etc. Once this partition is failed or lost, your phone will go wrong. I just faced, then solved the problem and I want to share the solution that could maybe help other persons.

    This was how it happeded:
    While I was flashing the phone, I erased the partition called "persist" accidently. When I was trying to flash the persist partition, the phone returned a message said that you can't flash the controlled partition. I suddenly relized something bad happened. Then I reboot the phone and find that many sensors stopped working. But the worst thing is the carrier network signals lost. I want to contact the service center at first. But I think as long as the phone is unlocked, there are tons of possibilities to fix it, unless it's hard-bricked. So I wanted to try to fix the partition.

    As we know, Xiaomi phones have backup partitions for most of the important partitions. For example, vbmeta and vbmetabak partitions. The vbmetabak usually is the backup of vbmeta. This persist partition also has a backup partition called "persistbak". This backup partition can be used to repair the persist partition. Here is a way to fix the persist partition.


    This way is for users have erased the persist partition, but haven't modified/erased the persistbak partition.
    Go to fastboot, flash the twrp recovery first. Then hold the POWER and VOLUME UP to force the phone boot to twrp recovery. Connect the phone to your PC and open adb command window. Type the following commands in order:

    adb shell

    cd /dev/block/by-name

    ls -all

    Check the output, find the partitions called "persist" and "persistbak". Remember the blocks corresponding to these two partitions. They should be similar to "mmcblk0p**". Once you know these correspondences, you can restore the persist partition immediately. For example, the persist partition and persistbak partition correspond to mmcblk0p$$ and mmcblk0p%% respectively (persist---->mmcblk0p$$ and persistbak---->mmcblk0p%%). Run this following command to restore your persist partition:

    dd if=/dev/block/mmcblk0p%% of=/dev/block/mmcblk0p$$

    Note: You need to replace "mmcblk0p$$" and "mmcblk0p%%" with the real partition block name.

    Now the persist partition has been fixed/restored. Reboot your phone to system and check whether sensors and carrier network etc. all work fine.


    2. This way is for users that have erased persist partition and persistbak partition or can't restore the partition using method 1.
    Find someway to download the fastboot ROM for your device. Exract the tgz file and open the folder called "images". Copy the "persist.img" to the adb tool folder. Because of the limitations of Xiaomi, you can't flash the persist partition or the persistbak partition directly. Copy the persist img file to the internal storage or sdcard on your phone. Now reboot to twrp recovery, connect the phone to your PC. Use these command to make a file that you can dd it to the persist partition and the persistbak partition:

    adb shell

    simg2img /sdcard/persist.img /sdcard/persist333.img

    Now you have a file that can dd to the persist/persistbak partition. Then type these following commands in order:

    cd /dev/block/by-name

    ls -all

    Check the output, find the partitions called "persist" and "persistbak". Remember the blocks corresponding to these two partitions. They should be similar to "mmcblk0p**". Once you know these correspondences, you can restore the persist partition and the persistbak partition immediately. Type these following commands in order:

    dd if=/sdcard/persist333.img of=/dev/block/mmcblk0p$$

    dd if=/sdcard/persist333.img of=/dev/block/mmcblk0p%%

    Note: You need to replace "mmcblk0p$$" and "mmcblk0p%%" with the real partitions block name.
    Now the persist partition and persistbak partition have been fixed/restored. Reboot your phone to system and check the whether sensors and carrier network etc. all work fine.


    If you think it's useful, please click thanks button.

    Does this fix "device storage corrupted" error?
    Actually I have this error but my sensors, carrier, wifi ... Etc all working great this error still appears. Anyway I think magisk hide config props module damaged my device's persist when I changed the fingerprint then I came back to stock rom and this error happened so my question is: is this process risky Or could cause losing mac or imei? And am I going to lose widevine l1?
    I'm thinking about backing up my current persist before proceeding do you think it's a good idea?
    1
    Disclaimer: I am not responsible for the results of any of these operations.


    Everyone knows that the persist partition is responsible for sonsors and carrier network etc. Once this partition is failed or lost, your phone will go wrong. I just faced, then solved the problem and I want to share the solution that could maybe help other persons.

    This was how it happeded:
    While I was flashing the phone, I erased the partition called "persist" accidently. When I was trying to flash the persist partition, the phone returned a message said that you can't flash the controlled partition. I suddenly relized something bad happened. Then I reboot the phone and find that many sensors stopped working. But the worst thing is the carrier network signals lost. I want to contact the service center at first. But I think as long as the phone is unlocked, there are tons of possibilities to fix it, unless it's hard-bricked. So I wanted to try to fix the partition.

    As we know, Xiaomi phones have backup partitions for most of the important partitions. For example, vbmeta and vbmetabak partitions. The vbmetabak usually is the backup of vbmeta. This persist partition also has a backup partition called "persistbak". This backup partition can be used to repair the persist partition. There are 2 ways to fix the persist partition. Choose the method you preferred.


    1. This way is for users have erased the persist partition, but haven't modified/erased the persistbak partition. If you don't want to type commands just use method 2.
    Go to fastboot, flash the twrp recovery first. Then hold the POWER and VOLUME UP to force the phone boot to twrp recovery. Connect the phone to your PC and open adb command window. Type the following commands in order:

    adb shell

    cd /dev/block/by-name

    ls -all

    Check the output, find the partitions called "persist" and "persistbak". Remember the blocks corresponding to these two partitions. They should be similar to "mmcblk0p**". Once you know these correspondences, you can restore the persist partition immediately. For example, the persist partition and persistbak partition correspond to mmcblk0p$$ and mmcblk0p%% respectively (persist---->mmcblk0p$$ and persistbak---->mmcblk0p%%). Run this following command to restore your persist partition:

    dd if=/dev/block/mmcblk0p%% of=/dev/block/mmcblk0p$$

    Note: You need to replace "mmcblk0p$$" and "mmcblk0p%%" with the real partition block name.

    Now the persist partition has been fixed/restored. Reboot your phone to system and check whether sensors and carrier network etc. all work fine.


    2. This way is for users that have erased persist partition and persistbak partition or can't restore the partition using method 1. Also, this method is a universal and easy way to fix both persist partition and persistbak partition. It doesn't need to type any command but only a swipe.
    I have made the persist partition repair tool for both global version and Chinese version. Both of them are in attachments. These tools make the repair process very easy. Both flashable zip files are tested on my Redmi Note 8 and they work fine.
    I have also posted them to Mi Community.
    Flash the repair tool in attachment. Choose the right file and flash it.
    Now the persist partition and persistbak partition have been fixed/restored. Reboot your phone to system and check whether sensors and carrier network etc. all work fine.


    If you think it's useful, please click thanks button.
    not to hate or dislike or be rude or anything... but people will lose Widevine L1 support by this method... so if anyone doesn't want HD videos on netflix etc, go ahead with this method.. otherwise don't even touch persist partition.
    1
    Thank you so much, flashing the zip worked !