[solved] Preventing Recovery Overwrite On System/normal Boot


reb00tz

Members
Jan 1, 2016
12
15
After moving my Mi6 from EU ROM to Global Stable 8.2.2.0, I realised that MIUI has now programmed either the boot.img or system.img to overwrite recovery partition on every "normal"/system boot.

So much for unlocking the bootloader... Since EU MIUI successfully prevents the China Stable ROM from overwriting recovery, will anyone be able to advise me?

Does anyone know where the pesky "reserved" copy is kept? I need to nuke it (or replace it).

Although the source system.img has a copy of the recovery-from-boot.p file, it appears to be different from the recovery.img file. Attempting to replace it with the TWRP image or removing it entirely (and flashing the rebuilt system.img) results in boot failure (see below for more information).
002934hsymy69lrn2z9ewg.jpg


Does anyone know:
  • where the "protected" recovery image may be found? and/or
  • how to repack/rebuild a system.img which will not cause a boot hang?

Note that I have rebuilt it "correctly" (as "correct" as I know) using the properly extracted file_contexts (as extracted from the file_contexts.bin) from the initrd.img from inside the boot.img using the command:
Code:
make_ext4fs -s -T -1 -S file_contents -L system -l <size of partition> -a system system.img <mount point>

I have tried both a blind fastboot flash system system.img, and also a standard "clean" flash using the MiFlash tool (after ensuring that the correct MD5, CRC and sparse CRC strings are edited in the various files, of course).

Thanks!