[ASUS ZenFone 8] bnsmb:
If a serious error occurs when booting Android, Android boots the phone from the recovery installed on the phone. The standard Android recovery then aborts the boot process with an error message similar to this one:

Cannot load Android system. Your data may be corrupt.

and the only options to continue are "Try again" or "Factory data reset".

The error message is not really useful and most documentation on the Internet that I found recommends a factory reset to fix the problem. In most cases, factory reset works, but it has the disadvantage that you lose all the settings and data on the phone. So in most cases this is the worst option.

However, if the error is not caused by an invalid or missing file in the partitions for /data or /metadata, resetting to factory defaults will not fix the problem, but the data from the phone will still be gone.

Therefor I wrote this little HowTo.

This HowTo is not about how to fix that error -- it only contains some hints to find the reason for the error.

To get more information about the error and also the possibility to backup the phone's data, TWRP can be used:

Just poweroff the phone, reboot the phone into the bootloader, and then reboot the phone from the TWRP image, e.g:

sudo fastboot boot /data/backup/ASUS_ZENFONE8/twrp/twrp-3.7.0_12-0-I006D-enhanced.img

Note:

In most cases, there is no option to turn off the phone in this dialog, so the phone must be turned off using the phone keys.

The key combination to turn off the phone during this dialog depends on the phone; on an ASUS Zenfone 8, this key combination must be used:

Press Volume UP + Volume DOWN + Power for 20 or more seconds

After the phone booted into the TWRP image connect via adb to the phone and check the TWRP logfile for a more detailed error message. The logile used by TWRP is /data/recovery/log.gz. Search for the string "Android Rescue Party trigger" in the TWRP logfile.

Note:

/data/recovery/log.gz is a compressed file ; use gzip to uncompress it.

Example:

ASUS_I006D:/ # gzip -cd /data/recovery/log.gz | more
Starting TWRP 3.7.0_12-0-d07fdb3c on Sat Jan 10 00:53:15 1970
(pid 403)
I:Lun file '/config/usb_gadget/g1/functions/mass_storage.0/lun.0/file'
PRODUCT_USE_DYNAMIC_PARTITIONS := true
TW_INCLUDE_CRYPTO := true
I:TW_BRIGHTNESS_PATH := /proc/lcd_brightness
I:Found brightness file at '/proc/lcd_brightness'
I:TWFunc::Set_Brightness: Setting brightness control to 420
I:TW_EXCLUDE_ENCRYPTED_BACKUPS := true
I:LANG: en
I:AB_OTA_UPDATER := true
Starting the UI...
Skipping adf graphics -- not present in build tree
setting DRM_FORMAT_XBGR8888 and GGL_PIXEL_FORMAT_RGBA_8888
setting DRM_FORMAT_XBGR8888 and GGL_PIXEL_FORMAT_RGBA_8888
....
I:Switching packages (TWRP)
boot command: boot-recovery
I:Startup Commands:

Android Rescue Party trigger! Possible solutions? Either:
1. Wipe caches, and/or
2. Format data, and/or
3. Clean-flash your ROM.

The reported problem is:
'--reason=set_policy_failed:/data/misc'

'--reason=set_policy_failed:/data/misc'
ro.boot.bootreason=shutdown
ro.boot.id.rf=1

If the error message is still not helpful in finding the reason for the error, try a Google search.

And if a factory reset is necessary, you can at least back up your data on the phone before performing the reset.

More infos about Android Rescue Party Trigger

The Android Rescue Party Trigger is an error handling process from Android (see here for more details about this Android functionality)

Android Rescue Party Trigger can also be triggered by Android while the OS is running :

In this case there should be some additional messages in the logfile /data/system/uiderrors.txt.

In addition, and if Magisk is installed, it might be useful to write the logcat messages to a file using the script from this post:

https://gist.github.com/niikoo/3f6bd13a69f2d68f3dd51cc667e79bdc

File: /data/adb/post-fs-data.d/0001logcatboot

#!/system/bin/sh
mkdir -p /cache/logs
/system/bin/logcat -r 1024 -n 9 -v threadtime -f /cache/logs/log >info.log 2>err.log &

The script can also be "installed" after the error already occured, to do this:

Boot the phone from the TWRP image; copy the script to the directory /data/adb/post-fs-data.d; make it executable and reboot the phone again from the installed OS to trigger the error again.

Note that logcat is not yet running if the error occurs in the early boot phase.

Caution:

If possible, TWRP will mount /data into the partition used for /data in the Android OS. Therefore, you can view the recovery boot logs in /data/recovery even after restarting the Android operating system as the user root.

However, if mounting the partition for /data in TWRP does not work, /data will be a directory in the root file system, e.g.:

130|ASUS_I006D:/ # df -h /data
Filesystem Size Used Avail Use% Mounted on
rootfs 3.2G 101M 3.1G 4% /
ASUS_I006D:/ #

In this case the contents of /data/reocvery are lost after rebooting the phone!

Notes:

[Update 14.07.2024]

Android uses the device /dev/block/by-name/misc to store commands for the bootloader (e.g. to force a reboot into the recovery or to do a factory reset). To avoid endless loops every recovery for an Android phone must clean the device misc. Therefor the error message is only visible in the logs of the first boot of TWRP.

The active log file for TWRP is /tmp/recovery.log; you can also use that file for the checks. Note that /tmp is mounted on a ramdisk.

On the page https://source.android.com/docs/core/tests/debug/rescue-party are instructions to force an Android Rescue Partry trigger by setting some properties but I did not get that to work neither in the OmniROM 13 nor in the ASUS Android 12.

To avoid the reboot from the TWRP image, install the TWRP recovery on the phone. In this case, Android will automatically boot into the installed TWRP recovery when a fatal error occurs.