How To Guide How to "fix" the error Cannot load Android system. Your data may be corrupt. - ASUS ZenFone 8

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:
Bash:
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:
Code:
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
Code:
#!/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.:
Code:
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:
The Android kernel uses the device /dev/block/by-name/misc to store the kernel parameter for the recovery kernel. The kernel from the recovery TWRP will clean the device /dev/block/by-name/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.

Related

Boot-Time Auto-SuperLog! [12 Apr 2013]

Boot-Time Auto-Superlog! [12 Apr 2013]
USERS --- TESTERS --- DEVS​Plumb the depths of Middle Droid with Auto-Superlog!​
So…
Your device doesn't finish booting
It reboots on its own (and you may not know it)
An application or feature crashes (and you may not know it)
Generally speaking, any manually-launched app or tool could miss key events leading to random reboot or application crash.
Problem addressed with Auto-Superlog!​
cm10-auto-superlog-v1.0.zip (3MB): http://www.mediafire.com/?cf5f9rq4z7p6gep
This flashable zip is tested working on my Atrix running CWM Recovery 5.0.2.0 and CM10 SuperLite. It should also work on epinter’s CM10 4.1.x builds and on close relatives. Not sure about 4.2.x yet.
In this exciting age of alpha-beta ROM testing, my lightweight Auto-Superlog, presently built on epinter’s versatile CM10 boot image (for demo purposes), can help just about anyone, whether end-user, tester or developer!
In fact it is already helping me track down abnormal battery drain and shutdown problems!
Alternatively instead of flashing the boot-time version, you can extract “auto-superlog.sh” from the flashable zip and manually execute it at run time.
Features
Automatically launches at boot-time under “class_start core” --- just after ROM filesystems are mounted, thus maximizing the likelihood of capturing key events, even if phone does not finish booting
Comprehensive log set includes: system build properties (getprop), kernel configuration file (from /proc/config.gz), kernel dmesg and system logcat --- all in sync, all in ASCII text format, and all stored in a single gzipped, time-stamped tar file on $EXTERNAL_STORAGE/auto-superlog for easy access and analysis.
Android events are quietly, nimbly and continuously streamed via kernel “dmesg” and system “logcat” commands. The dmesg log is pushed at 2-second intervals (default) with a 1MB ring buffer which is cleared on each pass. Logcat is configured to log “main” and “system” events with a generous 10MB buffer to help in discerning error trends.
Access real-time dmesg and logcat output right on your device by tapping the /data/auto-superlog directory using a (root) file explorer.
Log file contents are time stamped using absolute time ([YYYY-]MM-DD HH:MM:SS), enabling users to correlate Android events with the outside world
Filename timestamps show when your system was rebooted
Self-cleaning feature: On reboot, your most recent superlog is gzipped and archived to $EXTERNAL_STORAGE and then is removed from /data/auto-superlog so only your most recent superlog remains on the /data partition.
Shell script: auto-superlog.sh is stored under /system/bin, enabling users to extract and execute it at run-time and/or customize.
How to kill dmesg and logcat? Use the ps and grep commands: http://stackoverflow.com/questions/3117095/stopping-an-android-app-from-console (It’s a sheepish way of saying “mechanization of this feature is still in work” lol)
Instructions
Nandroid Backup current ROM (security blanket)
Flash zip if running epinter CM10 4.1.x or close relative (e.g. SuperLite)
Reboot and relax.
…OR, if you don’t want to flash the zip, but still want the run-time features of auto-superlog, simply extract /system/bin/auto-superlog.sh from zip and do this…
copy auto-superlog.sh to /system/bin (Tip: mount /system/bin as read-write (rw), then revert to ro when done)
chmod 0755 /system/bin/auto-superlog.sh
sh /system/bin/auto-superlog.sh (using Script Manager or other tool, as root)
Click to expand...
Click to collapse
After launching the script, just tap the Home button to resume other activity as the loggers are now running in background. Then you will have real-time streaming dmesg and logcat (as well as getprop and kernel config) at your fingertips --- literally.
The advantage of flashing the zip (if it’s compatible with your ROM) is that you are more likely to capture key events leading to a failed boot, random reboot or application crash.
Screenshots
​
Boot Image Source Code
This is the only change I made to CM10 boot.img...
Code:
ramdisk/init.olympus.rc ...
# sendust7 (12 Apr 2013)
service auto-superlog /system/bin/sh /system/bin/auto-superlog.sh
class core
# class main
# class late_start
user root
group system
# disabled
oneshot
# sendust7 (12 Apr 2013)
Documentation
dmesg: http://unixhelp.ed.ac.uk/CGI/man-cgi?dmesg+8
logcat: http://developer.android.com/tools/debugging/debugging-log.html#outputFormat
Android Encryption: http://source.android.com/tech/encryption/android_crypto_implementation.html
from Android Encryption…"This magic was accomplished by requiring all services to be in 1 of 3 groups: core, main and late_start. Core services are never shut down after starting. main services are shutdown and then restarted after the disk password is entered. late_start services are not started until after /data has been decrypted and mounted.”
Click to expand...
Click to collapse
Thoughts and Ideas: This has been a fun project so far. Time permitting, I may be able to service bug fixes and add more goodies like event filtering.
Disclaimer: Standard disclaimers apply.
Credits:Emerson Pinter (CM10 for Atrix 4g), Cyanogenmod Team
Very nice!
The OS considers the internal SD as EXTERNAL_STORAGE in assigning the env variable which is perhaps the reason you should too:
Booted without external sd mounted:
Code:
[email protected]:/ $ echo $EXTERNAL_STORAGE
/storage/sdcard0
Booted with external sd mounted:
Code:
[email protected]:/ $ echo $EXTERNAL_STORAGE
/storage/sdcard0
Possibly just tweak this part of your script:
Before
Code:
/system/bin/mount -t vfat /dev/block/mmcblk1p1 $EXTERNAL_STORAGE
After
Code:
/system/bin/mount -t vfat /dev/block/mmcblk0p18 $EXTERNAL_STORAGE
This then sends the archive to a location that will always exist (sdcard0).
I mention as I don't always have external SD mounted.
Sent from my MB860 using Tapatalk 2
Thanks sendust7
Good job !

Workaround: how to use full device encryption with custom recovery and newer ROMs.

Starting with Android L/Lollipop/5.0, full device encryption will be enabled by default, and for good reason. However, we slightly more security-conscious/paranoid SGS3 users have had problems for a while with using custom ROMs and keeping our encryption, as the main custom recovery with support for encryption --- TWRP --- has some incorrect build flags and other problems that aren't considered a priority. However, thanks to the very same bug report and discussion on the issue on TWRP's pages, someone found a solution which I can confirm works for me as well: https://github.com/TeamWin/Team-Win-Recovery-Project/issues/247#issuecomment-52651670
One option would be to check whether CWM Recovery supports your device. Then you'll have access to MiniVold in recovery mode and you can mount encrypted partitions through adb. I prefer the TWR method of just typing in my password, but as long as that does not work on my Galaxy S3, this does:
adb shell
setprop ro.crypto.state encrypted
vdc cryptfs checkpw 'your passphrase here'
mount /dev/block/dm-0 /data
and when you're done backing up/installing a zip
umount /data
Click to expand...
Click to collapse
For Windows users, here's a batch file you can use to automate this process:
Code:
adb shell setprop ro.crypto.state encrypted
adb shell vdc cryptfs checkpw "%~1"
adb shell mount /dev/block/dm-0 /data
Save it under whateveryouwant.bat and then give it the password as a parameter (if the password contains spaces, enclose it in quotes).
Caveat: I've found some operations will unmount /data, which for some reason cannot then be re-mounted by any combination of these commands. Workaround is to just reboot Philz Touch Recovery / CWM Advanced Recovery, re-mount, and continue.

How to patch `system.img` to root the Samsung S10 5G (Qualcomm) device?

Hi All,
Device Detail:
- Samsung S10 5G
- Qualcomm Device
- Model: SM-G977U
- ROM: VZW-G977UVRU2ASH7-20190827135903
- Kernel-Version - Linux version 4.14.83-16633035 ([email protected]) (clang version 6.0.10 for Android NDK) #2 SMP PREEMPT Wed Aug 14 16:23:48 KST 2019
Background: I have
- rooted the device with instructions given by Magisk.
- I can successfully reboot to the recovery rootfs.
Problem: I am trying to modify the `system.img.ext4.lz4` file to root the device with normal boot. I am aware that it will not let the device install OTA Updates.
Unpack-Pack System and make new AP.tar, flash:
- Without any modification to the `system.img`, I have just unpacked `system.img.ext4.lz4`->`system.img.ext4`->`system.img`->mounted to system directory and packed it back to `system.img`->`system.img.ext4`->`system.img.ext4.lz4`.
- Replaced unpack-packed `system.img.ext4.lz4` with the AP `system.img.ext4.lz4` and make a tar of it.
- Then I have flashed it using Odin v3.13 along with BL, CP, and HOME_CSC.
- Odin has show PASS and I have rebooted the device into recovery mode.
- Done the Wipe data/factory reset and reboot to recovery again but released the recovery key combination on splash screen as mentioned in the root instructions .
- The device stuck in a boot loop.
Tries:
1. Disable Dm-verity
- Removed `avb` flag from `boot.img` with
Code:
magiskboot dtb boot.img patch
- Removed `avb` and `verify` flags from `dtbo.img` with
Code:
magiskboot dtb dtbo.img patch
- Patched `ramdisk.cpio` with
Code:
magiskboot cpio ./initrd 'patch false true'
Patched `boot.img` and `dtbo.img` is working fine with magisk patched AP file but the `ramdisk.cpio` creating the issue: Stuck at splash screen when trying to go to recovery after successfully flash with Odin. Download mode is appearing on splash screen.
So, I have used `boot.img` and `dtbo.img` along with unpack-packed `system.img.ext4.lz4` but the result is still a boot loop. I have also tried a combination of `boot.img` and `dtbo.img` along with unpack-packed `vendor.img.ext4.lz4` and flashed the AP.tar with other files but still the result is a boot loop.
So, I want to debug the problem and got to know about `pstore` which preserve the logs when kernel panic.
2. pstore
- Checked that `/sys/fs/pstore` is mounted by the system with following in init file: Grep the pstore using `find . | grep '\.rc' | xargs cat | grep pstore -n -i` and get following result:
Code:
314: # pstore/ramoops previous console log
315: mount pstore pstore /sys/fs/pstore nodev noexec nosuid
316: chown system log /sys/fs/pstore/console-ramoops
317: chmod 0440 /sys/fs/pstore/console-ramoops
318: chown system log /sys/fs/pstore/console-ramoops-0
319: chmod 0440 /sys/fs/pstore/console-ramoops-0
320: chown system log /sys/fs/pstore/pmsg-ramoops-0
321: chmod 0440 /sys/fs/pstore/pmsg-ramoops-0
- Checked the kernel config by pulling the file from /proc/config.gz.
Code:
$ cat config | grep PSTORE
CONFIG_PSTORE=y
CONFIG_PSTORE_ZLIB_COMPRESS=y
# CONFIG_PSTORE_LZO_COMPRESS is not set
# CONFIG_PSTORE_LZ4_COMPRESS is not set
CONFIG_PSTORE_CONSOLE=y
CONFIG_PSTORE_PMSG=y
CONFIG_PSTORE_PMSG_SSPLOG=y
CONFIG_PSTORE_RAM=y
- Check the `ramoops` configuration:
Code:
./sys/module/ramoops/parameters/console_size 262144
./sys/module/ramoops/parameters/dump_oops 1
./sys/module/ramoops/parameters/ecc 0
./sys/module/ramoops/parameters/ftrace_size 262144
./sys/module/ramoops/parameters/mem_address 3241148416
./sys/module/ramoops/parameters/mem_size 1048576
./sys/module/ramoops/parameters/mem_type 0
./sys/module/ramoops/parameters/pmsg_size 262144
./sys/module/ramoops/parameters/record_size 262144
`pstore` setup looks fine but when I am trying the get logs from `sys/fs/pstore` then I found nothing.
I have tried it by two ways:
1. Crash manually with panic kernel using:
Code:
echo 1 > /proc/sys/kernel/sysrq
echo c > /proc/sysrq-trigger
Followed Reading Kernel Logs
2. Flashing non-working rom that cause a boot loop and then flashed a working ROM with rooting steps and checked the file at `sys/fs/pstore`.
I need a favor in:
- Any steps to fix/debug the `pstore` problem?
- Any other way to find the kernel logs?
Update 1: I get the logs from recovery but I am not able to identify the problem.
Logs link: https://drive.google.com/file/d/1b-XNmjpYvH-L8lY0xA0SYr7XcITVCrVS/view?usp=sharing
Description: In this video, I have done the following:
1. Displayed recovery logs before: The last recovery logs are ends with 8.
2. Rebooted the device with a recovery key combination. I have already wipe data partition before making this video.
3. The boot loop happens and in the next reboot, I have pressed the recovery key combination to open the recovery mode where logs that end with 9 displayed.
4. Then I have recorded `last_history`, `last_avc_message_recovery`, `last_log.9` and `last_kmsg.9`
5. `last_history` and `last_avc_message_recovery` looks unchanged(same as before boot loop).
6. Then, I just have tried to mount the system but that didn't work.
7. At last, I have just rebooted the system normally without any recovery key combination.
Some Highlighted logs of last_log.9
exec -f /system/bin/e2fsck -v -y /dev/block/bootdevice/by-name/cache
error: _do_exec: can't run '/system/bin/e2fsck'
(errno 13 : Permission denied)
/system/bin/e2fsck terminated by exit(255)
...
E:Can't read /cache/recovery/last_locale: No such file or directory
...
W:Failed to unmount /efs: Device or resource busy
can't unmount /efs - Device or resource busy
...
W:Failed to set brightness: Invalid argument
I:Screensaver disabled
Atomic Commit failed in DisableNonMainCrtcs
Atomic Commit failed, rc = 0
...
Reboot Recovery Cause is [[BootChecker]RebootRecoveryWithKey]
...
print_recovery_cause() : reboot_reason=[[BootChecker]RebootRecoveryWithKey]
...
[property list]
persist.audio.fluence.speaker=true
...
ro.vendor.build.security_patch=2018-08-05
Supported API: 3
I:/efs is already mounted
W:Failed to unmount /efs: Device or resource busy
check_selective_file:Can't unmount /efs - Device or resource busy
just_reboot_after_update = 1
should_wipe_cahcewipe_cache
-- Wiping cache...
erase_volume(/cache)
...
MDF_I: Completed reset MDF flag!
MDF_I: Completed initialized MDF for Recovery!
mke2fs 1.43.3 (04-Sep-2016)
Discarding device blocksL 4096/153600??????????????????????????????done
Discard takes 0.00051s
Creating filesystem with 153600 4k blocks and 38400 inodes
...
Creating journal (2048 blocks): done
...
copy_logs
...
Cache wipe complete
[Checking pre-multi-csc2]
[start failed section]
sales_code=VZW
Carrier ID=[XAA]
[system partition space check]
The device has /product partition.
[out-recovery]
I:system root image is true, so need to change the unmount point from /system to /system_root
running out-recovery time : 0.000s
running recovery time: 1.738s
copy_avc_msg_to_data(1, )
I:fs_type "ext4" for /cache
copy_file 'proc/avc_msg' 'cache/recovery/last_avc_msg_recovery'
!__RECOVERY_FOR_ASSAMBLY
b_del_recovery_command = true
Rebooting...
## finish_recovery_terminate(del=1, reboot_cmd=reboot, clear_BCB=1)
## finish_recovery(delcmd=1,...
I:Saving locale "en-US"
I:fs_type "ext4" for /cache
I:[libfs_mgr]dt_fstab: Skip disabled entry for partition vm-linux
I:## unlink /cache/recovery/command
copy_logs
I:fs_type "ext4" for /cache
copy_log_file :: create recovery log file '/cache/recovery/log'
copy_log_file :: create recovery log file '/cache/recovery/last_log'
Click to expand...
Click to collapse
Is anyone have experience in detecting problems from the kernel logs?
i can not help you, but we can collect ideas. what about re-sign the system.img? there is a key somewhere, i guess just deleting won't work but maybe it is possible to calculate checksum
or maybe you can switch to SuperSU 2.79 SR3 (latest release from chainfire) or at least look inside the update-binary shell script how to root system.
regarding dm-verity i would start with searching for "verify" flag in your fstabs and remove it. magisk is also doing some hex patches and re-signing, it's the best source to look inside magisk installer zip update-binary/ updater-script, if you have the knowledge to read code
another option is try to port a twrp recovery from another snapdragon (i wonder if somebody did this already) if you can find a porting guide
so the vzw s10 5g is unlockable?
elliwigy said:
so the vzw s10 5g is unlockable?
Click to expand...
Click to collapse
yes
aIecxs said:
yes
Click to expand...
Click to collapse
Figures lol.. I have a g975u from big red n don't plan on buying another lol
aIecxs said:
yes
Click to expand...
Click to collapse
Message me on telegram and I can help you if you help me.. I'm curious in some logs and what not.. I also might have something you can use..
Did you get it working? I have the same phone and I want to use the 600mgz tmobile 5g in a few days, so I need the right rom.
elliwigy said:
so the vzw s10 5g is unlockable?
Click to expand...
Click to collapse
aIecxs said:
yes
Click to expand...
Click to collapse
Snapdragon bootloader unlockable? How?
I'm a VZW customer and can get the phone on an upgrade, but want to root it...
i got a g977p and twrp n magisk working great
do you think it is possible to flash other branding on verizon devices with modded odin?
aIecxs said:
do you think it is possible to flash other branding on verizon devices with modded odin?
Click to expand...
Click to collapse
dunno.. its not possible on n976v..
Was there any luck on rooting the Verizon G977U?
@Vats12 has already successful rooted with magisk in recovery. this thread is for rooting system (kind of rooting where su binary is placed in /system/xbin like for older devices, which breaks OTA)
aIecxs said:
@Vats12 has already successful rooted with magisk in recovery. this thread is for rooting system (kind of rooting where su binary is placed in /system/xbin like for older devices, which breaks OTA)
Click to expand...
Click to collapse
So you want like the supersu method?
ExtremeGrief said:
So you want like the supersu method?
Click to expand...
Click to collapse
Yes, do you know how to do this?
Magisk (guide) does a lot of other things too..
Maybe we can use Magisk to disable the securities and then SuperSu can help in the rooting system?
Vats12 said:
Yes, do you know how to do this?
Magisk (guide) does a lot of other things too..
Maybe we can use Magisk to disable the securities and then SuperSu can help in the rooting system?
Click to expand...
Click to collapse
But why? Safetynet will be gone
What model is the device?
ExtremeGrief said:
But why? Safetynet will be gone
What model is the device?
Click to expand...
Click to collapse
model see OP! i guess because of the buttons needed for booting in magiskrecovery, but the reason is not important only HOW (for Vats12, not for me i don't own this device)
Sorry but this thread needs to be closed
aIecxs said:
model see OP! i guess because of the buttons needed for booting in magiskrecovery, but the reason is not important only HOW (for Vats12, not for me i don't own this device)
Click to expand...
Click to collapse
I don't want to be the one who shouts fake, but the instructions you gave a link to says you have to be able to flash a bootloader first, which means an unlocked blootloader, if you have Verizon rom this is not possible, as the blootloader is locked.
If you did find a way to flash a modified bootloader, or a modified recovery those are the instructions we need, because in fastboot you are unable to do this with a locked bootloader and you are unable to unlock the bootloader on Verizon. If you have a modified bootloader or recovery flashed on your device what did you use to flash it with Odin? Because only way to flash a boot.img is either get into download mode and flash with Odin, or with Edl, if you got into edl mode then can you provide instructions on that, because we would like to know how to get the device into EDL mode as well
Sorry boys this is a hoax.
@DroidisLINUX there is video proof in OP, and again for you:
This is not a tutorial about unlocking and rooting, it is a question how he can modify /system to permanently integrate su

How To Guide Some hints using TWRP

This HowTo contains some hints for using TWRP in general and some tips for using CLI commands in TWRP.
I will update this post in case I find something new & useful regarding TWRP and update the history section at the end of this post.
The test environment for the instructions below was
TWRP 3.6.2.12 for the ASUS Zenfone 8
TWRP 3.7.0_12-0 for the ASUS Zenfone 8
Note:
This is NOT a general HowTo for TWRP.
How to test a TWRP image?
It's recommended to boot from the TWRP image file before installing it into the boot or recovery partition of your phone. To do this do
Bash:
# connect the phone via USB to your PC
# boot the phone into the bootloader - e.g. via
#
adb reboot bootloader
# boot the phone from the TWRP image (this will not change anything on the phone)
#
sudo fastboot boot <twrpimage_file>
If everything works you can install the TWRP image into the boot or recovery partition using the approbiate menu entry in TWRP.
How to connect via adb to an TWRP session?
TWRP supports adb session as user root, therefor an
Bash:
adb shell
on your PC is sufficient to open an adb shell as user root on the phone booted into TWRP.
In case you get a permission denied error kill the running adb daemon on the PC and restart the adb command. If that does not fix the error disconnect and reconnect the USB cable between the PC and the Phone.
Be aware that TWRP starts the adb daemon twice after booting. Therefor an adb session to the phone started to early after the boot into TWRP might be killed. In this case just open a new adb shell.
How to check if the phone is booted into TWRP ?
Check the value of the property ro.twrp.boot; this property is only set if TWRP is running
e.g:
Code:
ASUS_I006D:/ # getprop ro.twrp.boot
1
ASUS_I006D:/ #
How to check if the running TWRP was booted from an TWRP image or from a boot or recovery partition?
Check the value of the property ro.bootmode; the value of this property is "unknown" if TWRP was booted from an image file via "fastboot boot <twrp_image_file>", e.g.
Code:
ASUS_I006D:/ # getprop ro.bootmode
unknown
ASUS_I006D:/ #
-> TWRP was booted from an TWRP image file
Code:
ASUS_I006D:/ # getprop ro.bootmode
recovery
ASUS_I006D:/ #
-> TWRP was booted from the boot or recovery partition
How to get the version of the running TWRP?
Check the value of the property getprop ro.twrp.version, e.g.:
Code:
ASUS_I006D:/ # getprop ro.twrp.version
3.7.0_12-0
ASUS_I006D:/ #
Where is the log file from TWRP?
The logfile with the messages written while booting TWRP is /data/recovery/log.gz.
e.g.
Code:
130|ASUS_I006D:/ # ls -ltr /data/recovery/l*gz
-rw------- 1 system system 8022 2022-12-26 14:03 /data/recovery/log.gz
ASUS_I006D:/ #
ASUS_I006D:/ # gzip -cd /data/recovery/log.gz | head -10
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
ASUS_I006D:/ #
The current logfile of the running TWRP is /tmp/recovery.log, e.g.:
Code:
ASUS_I006D:/ # ls -l /tmp/recovery.log
-rw-rw-rw- 1 root root 43303 2023-05-19 20:11 /tmp/recovery.log
ASUS_I006D:/ #
Where are the settings from TWRP stored?
The settings from TWRP are stored in the file
/data/media/0/TWRP/.twrps
This is a binary file.
Note that on phones with active encryption that file is only accessible after /data is decrypted.
How to edit a file while booted into TWRP?
The editor nano is part of TWRP and can be used to edit files in an adb session.
How to mount a partition while inside TWRP?
Use
twrp mount <mountpoint>
to mount a partition while TWRP is running.
Note that you should use this command with caution in adb sessions because the adb session may be killed after the mount
How to decrypt an encrypted /data partition
Use
twrp decrypt <password>
to decrypt an encrypted /data partition, e.g.
Code:
ASUS_I006D:/ # ls /data/media/0
+lnodCAAAAAnYFLObBoWS5ZNb5yVMpze 8KdHMCAAAAQOgtDHq,XdSfFPW+XURA2M KlfTJCAAAAwL93jkH2ugnU4eUG3Zzm7M W9W9SCAAAAgh6lwoP0mNiEK9VIWJoH6L
0nUvhAAAAAQ9ptz+L5qPQrpzcAt4G06K DWk4KDAAAAA,B1xVDmT3dZI87g2C0IS8 M6jcmCAAAAAU,4gn9o0zoBZmkysyXy49 bE7t0CAAAAQ2YuHL9styNaf,iSf2cCO,
4nFjMBAAAAwv2oUczXEpKUDfRIOi+nR5 EcHrdAAAAAglBtbhNWl0NvyX8aW+3CHN O5ZVrDAAAAAlKd7PPpo7CaQmkFbZzKRm haPcnBAAAAw9o2lLF97zpPTaC+byP92s
5yL8gCAAAAgekBDBUi4,W78rJAkgFcMF FA1aZAAAAAg2XNF+M859lpPY,3rUC2cY Vda+LCAAAAwR+g6Tav35+h,Epc8latGR mSKc8BAAAAwm+12sMClHPf+zwtHAeW+Q
8CsF+DAAAAwI3tImfOqIS9aHCQ3S7Cdg JpuFgAAAAAwdEzuQerx4681dzGLjlK3X VvEV4DAAAAgRgoqCfrypNqryZxRACnfr rMJEjAAAAAgwTgx,vA5ewWMVizc2LAos
ASUS_I006D:/ #
ASUS_I006D:/ # twrp decrypt 12345
Attempting to decrypt data partition or user data via command line.
Attempting to decrypt FBE for user 0...
User 0 Decrypted Successfully
Data successfully decrypted
Updating partition details...
...done
ASUS_I006D:/ #
ASUS_I006D:/ # ls /data/media/0
Alarms Android Audiobooks DCIM Documents Download Movies Music Notifications Pictures Podcasts Recordings Ringtones TWRP
ASUS_I006D:/ #
see the TWRP Commandline Guide for the known parameter for this command
Note that existing adb sessions will be stopped after sucessfully executing this command.
How to check if the data partition is encrypted from within a booted TWRP
To check if the data partition is encrypted in a script executed in a running TWRP use code like this:
Spoiler: # check if the data partition is encrypted
Bash:
PASSWORD="1234"
CRYPTO_READY=$( getprop crypto.ready )
TWRP_DECRYPT_DONE=$( getprop twrp.decrypt.done )
if [ "${TWRP_DECRYPT_DONE}"x = "true"x ] ; then
echo "The data partition is not encrypted or already decrypted"
elif [ "${CRYPTO_READY}"x = "1"x ] ; then
echo "The data partition is encrypted"
# sample commands to decrypt the data partition
#
# echo "Decryptiong the data partition now ..."
# twrp decrypt "${PASSWORD}"
elif [ "${CRYPTO_READY}"x = "0"x ] ; then
echo "The data partition is not encrypted"
else
echo "ERROR: The value of the property crypto.ready \"${CRYPTO_READY}\" is not known"
fi
How to install a ZIP file via cli command from within a running TWRP?
Copy the zip file to the phone via adb push and then use
twrp install /path/to/update.zip
to install a ZIP file from within TWRP
Note that the parameter must be a fully qualified filename.
Using this method to update the OS only works in a terminal session on the phone; it does not work in a adb session (at least in my tests until now ...)
What commands are available in TWRP?
Most of the Unix commands are available in TWRP
Be aware that a lot of Unix commands in TWRP are implemented using a general binary called toybox (toybox is something like busybox) and do not support all parameter like the original Linux commands
Code:
ASUS_I006D:/ # ls -l /bin/ | wc -l
261
ASUS_I006D:/ # ls -l /bin/ | grep toybox | wc -l
175
ASUS_I006D:/ #
What other TRWP specific commands can be used while in a running TWRP?
Spoiler: The twrp command
Code:
ASUS_I006D:/ # twrp
TWRP openrecoveryscript command line tool, TWRP version 3.7.0_12-0
Allows command line usage of TWRP via openrecoveryscript commands.
Some common commands include:
install /path/to/update.zip
backup <SDCRBAEM> [backupname]
restore <SDCRBAEM> [backupname]
wipe <partition name>
format data
sideload
set <variable> [value]
decrypt <password> [USER ID]
remountrw
fixperms
mount <path>
unmount <path>
listmounts
print <value>
mkdir <directory>
reboot [recovery|poweroff|bootloader|download|edl]
See more documentation at https://twrp.me/faq/openrecoveryscript.html
ASUS_I006D:/ #
See more documentation at https://twrp.me/faq/openrecoveryscript.html
https://twrp.me/faq/openrecoveryscript.html
and a few others like bootctl (see below) or magiskboot (see below).
How to change the active slot for the next reboot while in TWRP?
Use bootctl, e.g.
Code:
ASUS_I006D:/ # bootctl get-current-slot
1
ASUS_I006D:/ # bootctl set-active-boot-slot 0
The usage for the command bootctl is
Spoiler: bootctl usage
Code:
ASUS_I006D:/ # /bin/bootctl
/bin/bootctl - command-line wrapper for the boot HAL.
Usage:
/bin/bootctl COMMAND
Commands:
hal-info - Show info about boot_control HAL used.
get-number-slots - Prints number of slots.
get-current-slot - Prints currently running SLOT.
mark-boot-successful - Mark current slot as GOOD.
get-active-boot-slot - Prints the SLOT to load on next boot.
set-active-boot-slot SLOT - On next boot, load and execute SLOT.
set-slot-as-unbootable SLOT - Mark SLOT as invalid.
is-slot-bootable SLOT - Returns 0 only if SLOT is bootable.
is-slot-marked-successful SLOT - Returns 0 only if SLOT is marked GOOD.
get-suffix SLOT - Prints suffix for SLOT.
set-snapshot-merge-status STAT - Sets whether a snapshot-merge of any dynamic
partition is in progress. Valid STAT values
are: none, unknown, snapshotted, merging,
or cancelled.
get-snapshot-merge-status - Prints the current snapshot-merge status.
SLOT parameter is the zero-based slot-number.
ASUS_I006D:/ #
see also How to switch the active slot
How to use Magisk binaries while booted into TWRP
Magisk is another great tool for Android phones -- for details about Magisk see here:
https://github.com/topjohnwu/Magisk
The Magisk binary for manipulating the boot partition, magiskboot, is already part of TWRP. This binary can be used to unpack and repack boot partition (or boot partition images), ramdisks, or compress/decompress files. The binary works without problems while booted into TWRP.
Spoiler: magiskboot usage
Code:
1|ASUS_I006D:/ # magiskboot
MagiskBoot - Boot Image Modification Tool
Usage: magiskboot <action> [args...]
Supported actions:
unpack [-n] [-h] <bootimg>
Unpack <bootimg> to, if available, kernel, kernel_dtb, ramdisk.cpio,
second, dtb, extra, and recovery_dtbo into current directory.
If '-n' is provided, it will not attempt to decompress kernel or
ramdisk.cpio from their original formats.
If '-h' is provided, it will dump header info to 'header',
which will be parsed when repacking.
Return values:
0:valid 1:error 2:chromeos
repack [-n] <origbootimg> [outbootimg]
Repack boot image components from current directory
to [outbootimg], or new-boot.img if not specified.
If '-n' is provided, it will not attempt to recompress ramdisk.cpio,
otherwise it will compress ramdisk.cpio and kernel with the same format
as in <origbootimg> if the file provided is not already compressed.
If env variable PATCHVBMETAFLAG is set to true, all disable flags will
be set in the vbmeta header.
hexpatch <file> <hexpattern1> <hexpattern2>
Search <hexpattern1> in <file>, and replace with <hexpattern2>
cpio <incpio> [commands...]
Do cpio commands to <incpio> (modifications are done in-place)
Each command is a single argument, add quotes for each command
Supported commands:
exists ENTRY
Return 0 if ENTRY exists, else return 1
rm [-r] ENTRY
Remove ENTRY, specify [-r] to remove recursively
mkdir MODE ENTRY
Create directory ENTRY in permissions MODE
ln TARGET ENTRY
Create a symlink to TARGET with the name ENTRY
mv SOURCE DEST
Move SOURCE to DEST
add MODE ENTRY INFILE
Add INFILE as ENTRY in permissions MODE; replaces ENTRY if exists
extract [ENTRY OUT]
Extract ENTRY to OUT, or extract all entries to current directory
test
Test the current cpio's status
Return value is 0 or bitwise or-ed of following values:
0x1:Magisk 0x2:unsupported 0x4:Sony
patch
Apply ramdisk patches
Configure with env variables: KEEPVERITY KEEPFORCEENCRYPT
backup ORIG
Create ramdisk backups from ORIG
restore
Restore ramdisk from ramdisk backup stored within incpio
sha1
Print stock boot SHA1 if previously backed up in ramdisk
dtb <input> <action> [args...]
Do dtb related actions to <input>
Supported actions:
print [-f]
Print all contents of dtb for debugging
Specify [-f] to only print fstab nodes
patch
Search for fstab and remove verity/avb
Modifications are done directly to the file in-place
Configure with env variables: KEEPVERITY
split <input>
Split image.*-dtb into kernel + kernel_dtb
sha1 <file>
Print the SHA1 checksum for <file>
cleanup
Cleanup the current working directory
compress[=format] <infile> [outfile]
Compress <infile> with [format] (default: gzip), optionally to [outfile]
<infile>/[outfile] can be '-' to be STDIN/STDOUT
Supported formats: gzip zopfli xz lzma bzip2 lz4 lz4_legacy lz4_lg
decompress <infile> [outfile]
Detect format and decompress <infile>, optionally to [outfile]
<infile>/[outfile] can be '-' to be STDIN/STDOUT
Supported formats: gzip zopfli xz lzma bzip2 lz4 lz4_legacy lz4_lg
1|ASUS_I006D:/ #
If Magisk is installed in the Android OS on the phone and the booted TWRP is able to mount the volume for /data the Magisk binary magisk can also be used in an session in TWRP.
For details see the section Using the magisk binary while the phone is booted into TWRP in the post Some hints for using Magisk on Android phones
How to install TWRP into the boot partition using CLI commands from within a booted TWRP?
Use the script
install_twrp_from_within_twrp.sh
Download from here: http://bnsmb.de/files/public/Android/install_twrp_from_within_twrp.sh
How to install TWRP after an OS Upgrade from within the running Android OS?
see How to Install TWRP into the boot partition again after the installation of an OS update
How to add additional files to an existing TWRP image?
see How to add additional files to an TWRP image
How to install TWRP into the boot partition via script?
see How to install TWRP via script
How to build a TWRP image?
seee How to compile TWRP for the ASUS Zenfone 8
How to install an OS image using the twrp command in a script
see How to install an OS image using the TWRP binary twrp?
How to use TWRP if LineageOS 20.x is installed
As of 26.06.2023 booting the phone from the TWRP recovery image using the command
sudo fastboot boot <twrp_image>
Does not work anymore if LineageOS 20.x is installed on the phone.
see How to use TWRP if LineageOS 20.x is installed for a workaroujnd
Spoiler: History / Change log of this entry
02.12.2022 /bs
initial release
17.12.2022 /bs
added infos about how to use the binary twrp to install an OS image
26.12.2022 /bs
added infos about the logile used by TWRP
23.04.2023 /bs
added info about how to decrypt the data partition
30.04.2023 /bs
added infos about the file used for the TWRP settings
19.05.2023 /bs
added infos about how to check if the data partition is encrypted
updated the infos about the log file used by TWRP
added infos about how to install TWRP from within a running Android OS
26.06.2023 /bs
added the infos about how to use TWRP with LineageOS 20.x

How To Guide How to install an OS image using the TWRP binary twrp

The most important step to automate the installation and configuration of the Android OS is the installation of an OS image via script without user intervention. One method to do that is using the binary twrp from the recovery TWRP .
The twrp command to install an OS image with twrp is
Code:
/system/bin/twrp install /path/to/update.zip
The usage for the binary twrp is (see also here)
Spoiler: twrp usage help
Code:
I006D:/ # /system/bin/twrp --help
TWRP openrecoveryscript command line tool, TWRP version 3.7.0_12-0
Allows command line usage of TWRP via openrecoveryscript commands.
Some common commands include:
install /path/to/update.zip
backup <SDCRBAEM> [backupname]
restore <SDCRBAEM> [backupname]
wipe <partition name>
format data
sideload
set <variable> [value]
decrypt <password> [USER ID]
remountrw
fixperms
mount <path>
unmount <path>
listmounts
print <value>
mkdir <directory>
reboot [recovery|poweroff|bootloader|download|edl]
See more documentation at https://twrp.me/faq/openrecoveryscript.html
I006D:/ #
The binary twrp can also be used to wipe the data from the phone using the parameter wipe <partition_name>.
The command twrp install will not change the active boot slot for the next reboot so this must be done manually after installing the OS image. This can be done using the binary bootctl which is also part of TWRP.
The usage for the command bootctl is:
Spoiler: bootctl usage help
Code:
ASUS_I006D:/ # /system/bin/bootctl -h
/system/bin/bootctl - command-line wrapper for the boot HAL.
Usage:
/system/bin/bootctl COMMAND
Commands:
hal-info - Show info about boot_control HAL used.
get-number-slots - Prints number of slots.
get-current-slot - Prints currently running SLOT.
mark-boot-successful - Mark current slot as GOOD.
get-active-boot-slot - Prints the SLOT to load on next boot.
set-active-boot-slot SLOT - On next boot, load and execute SLOT.
set-slot-as-unbootable SLOT - Mark SLOT as invalid.
is-slot-bootable SLOT - Returns 0 only if SLOT is bootable.
is-slot-marked-successful SLOT - Returns 0 only if SLOT is marked GOOD.
get-suffix SLOT - Prints suffix for SLOT.
set-snapshot-merge-status STAT - Sets whether a snapshot-merge of any dynamic
partition is in progress. Valid STAT values
are: none, unknown, snapshotted, merging,
or cancelled.
get-snapshot-merge-status - Prints the current snapshot-merge status.
SLOT parameter is the zero-based slot-number.
64|ASUS_I006D:/ #
Afterwards the phone can be rebooted to activate the new installed OS
So the commands for installing an OS image via twrp are
- boot the phone from the TWRP image
- (optional) use twrp to wipe the data
- copy the OS image file via adb push to the phone
- install the OS image file via the twrp binary
- change the next active boot slot via the binary bootctl.
- reboot the phone
I wrote a simple script to just do that
install_os_via_twrp.sh
The usage of the script is :
Code:
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $ ./install_os_via_twrp.sh -h
install_os_via_twrp.sh version - v1.0.0.0 - install an OS image via the TWRP command twrp
install_os_via_twrp.sh [-h|help|-H] [--reboot|--noreboot] [force] [wipe|wipeall] [wipe_cache] [wipe_data] [wipe_dalvik] [format_data] [format_metadata] [factory_reset] [os_image_file]
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $
Use the parameter --help or -H to view the detailed usage help
Spoiler: Detailed usage help for install_os_via_twrp.sh
Code:
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $ ./install_os_via_twrp.sh -H
install_os_via_twrp.sh version - v1.0.0.0 - install an OS image via the TWRP command twrp
Usage
install_os_via_twrp.sh [-h|help|-H] [--reboot|--noreboot] [force] [wipe|wipeall] [wipe_cache] [wipe_data] [wipe_dalvik] [format_data] [format_metadata] [factory_reset] [os_image_file]
All parameter are optional, except the parameter for the OS image to install "os_image_file".
The parameter can be used in any order.
Use the parameter "help" or "-H" to print the detailed usage help; use the parameter "-h" to print only the short usage help
If the parameter "--reboot" is used the script will reboot the phone after successfully installing the OS image; to disable the automatic reboot use the parameter "--noreboot".
Default is to ask the user for confirmation to reboot the phone.
Use the parameter "wipe" or "wipeall" to wipe /data, /cache, and Dalvik before installing the OS image.
Use one or more of the parameter "wipe_cache", "wipe_data", or "wipe_dalvik" to only wipe some of the partitions used.
Use the parameter "format_metadata" to format the meta data partition; this wipe is NOT included in "wipe_all"
Use the parameter "format_data" to format the data partition; this wipe is NOT included in "wipe_all"
Use the parameter "factory_reset" to do a factory reset before installing the OS image; a factory reset is done by formatting the data and the metadata partitions.
Use the parameter "force" to ignore errors while wiping or formatting the data; without this parameter the script will abort if one of the wipe or format commands fails
To change some of the values used by the script these environment variables can be set before starting the script:
Set the environment variable REBOOT to "yes" before starting the script to automatically reboot the phone after enabling the root access
Set the environment variable REBOOT to "no" before starting the script to disable the automatic reboot after enabling the root access
Set the environment variable UPLOAD_DIR_ON_THE_PHONE to set the upload directory for the OS image file on the phone (default dir is /tmp; /tmp is mounted on a ramdiks)
See also the source code of the script
boot_phone_from_twrp.sh
for environment variables supported by this script
Prerequisites
- the phone must be connected via USB
- there must be a working connection to the phone using fastboot or adb
- a working TWRP image for the phone must exist
The script boot_phone_from_twrp.sh is required by this script -- see the source code of the script
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $
Note:
The script needs the helper script boot_phone_from_twrp.sh.sh (see How to boot a phone from a twrp recovery image)
Spoiler: Sample output of the script installing a new version of the same OS
Code:
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $ REBOOT=yes /data/develop/android/scripts_on_linux/install_os_via_twrp.sh /data/backup/ASUS_ZENFONE8/omnirom/omni-13/omni-13-202212180505-zenfone8-MICROG.zip
install_os_via_twrp.sh version - v1.0.0.0 - install an OS image via the TWRP command twrp
Using the TWRP helper script "/data/develop/android/scripts_on_linux/boot_phone_from_twrp.sh"
The OS image to install is: "/data/backup/ASUS_ZENFONE8/omnirom/omni-13/omni-13-202212180505-zenfone8-MICROG.zip"
Reading the helper script "boot_phone_from_twrp.sh" ...
The script is running as user "xtrnaw7" -- will use "sudo" for the fastboot commands ...
Will use the attached phone with the serial number "M6AIB760D0939LX"
Using the default TWRP image: "/data/backup/ASUS_ZENFONE8/twrp/current_twrp.img"
Using the options " -s M6AIB760D0939LX " for the adb commands
Using the options " -s M6AIB760D0939LX " for the fastboot commands
Checking the script prerequisites ...
Will wait up to 60 second(s) after booting the phone into the bootloader
Will wait up to 60 second(s) after booting the phone from the TWRP image
Will wait up to 10 second(s) until the adb daemon is ready to use
Retrieving the current status of the phone ...
The phone is currently booted into the Android OS
The phone is booted into the Android OS
Booting the phone into the bootloader now ...
Waiting up to 60 seconds for the boot into the fastboot mode ...
The phone is booted into the bootloader
Booting the phone from the TWRP image "/data/backup/ASUS_ZENFONE8/twrp/current_twrp.img" now ...
Sending 'boot.img' (98304 KB) OKAY [ 2.833s]
Booting OKAY [ 10.359s]
Finished. Total time: 13.243s
Waiting up to 60 seconds for the boot of the phone ....
Waiting up to 10 seconds for the adb daemon to get ready ..
... the adb daemon is ready after second(s)
The phone is booted into TWRP: "twrp_I006D" version "3.7.0_12-0"
Waiting up to 10 seconds for the adb daemon to get ready
... the adb daemon is ready after second(s)
Coyping the OS image file "/data/backup/ASUS_ZENFONE8/omnirom/omni-13/omni-13-202212180505-zenfone8-MICROG.zip" to "/tmp/omni-13-202212180505-zenfone8-MICROG.zip" on the phone ...
adb: error: failed to read copy response8-MICROG.zip
/data/backup/ASUS_ZENFONE8/omnirom/omni-13/omni-13-202212180505-zenfone8-MICROG.zip: 1 file pushed, 0 skipped. 201.8 MB/s (1261116637 bytes in 5.959s)
adb: error: failed to read copy response
adb: device 'M6AIB760D0939LX' not found
Copying the image failed -- we will do another try in 5 seconds ...
/data/backup/ASUS_ZENFONE8/omnirom/omni-13/omni-13-202212180505-zenfone8-MICROG.zip: 1 file pushed, 0 skipped. 32.5 MB/s (1261116637 bytes in 37.056s)
Installing the OS image "/tmp/omni-13-202212180505-zenfone8-MICROG.zip" into the slot "_b" ...
Installing zip file '/tmp/omni-13-202212180505-zenfone8-MICROG.zip'
Flashing A/B zip to inactive slot: B
Step 1/2Step 2/2Updating partition details...
...done
Devices on super may not mount until rebooting recovery.
To flash additional zips, please reboot recovery to switch to the updated slot.
Done processing script file
OS image file "/tmp/omni-13-202212180505-zenfone8-MICROG.zip" successfully installed.
Now changing the next active slot to _b ...
... successfully changed the active slot for the next reboot
Rebooting the phone now ...
Booting the Android OS using the command "adb reboot " now ...
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $
Spoiler: Sample output of the script installing another OS in the inactive slot
Code:
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $ /data/develop/android/scripts_on_linux/install_os_via_twrp.sh factory_reset /data/backup/ASUS_ZENFONE8/Lineage-19_Android12/lineage-19.1-20221216-nightly-sake-signed.zip
install_os_via_twrp.sh version - v1.0.0.0 - install an OS image via the TWRP command twrp
Using the TWRP helper script "/data/develop/android/scripts_on_linux/boot_phone_from_twrp.sh"
The OS image to install is: "/data/backup/ASUS_ZENFONE8/Lineage-19_Android12/lineage-19.1-20221216-nightly-sake-signed.zip"
Reading the helper script "boot_phone_from_twrp.sh" ...
The script is running as user "xtrnaw7" -- will use "sudo" for the fastboot commands ...
Will use the attached phone with the serial number "M6AIB760D0939LX"
Using the default TWRP image: "/data/backup/ASUS_ZENFONE8/twrp/current_twrp.img"
Using the options " -s M6AIB760D0939LX " for the adb commands
Using the options " -s M6AIB760D0939LX " for the fastboot commands
Checking the script prerequisites ...
Will wait up to 60 second(s) after booting the phone into the bootloader
Will wait up to 60 second(s) after booting the phone from the TWRP image
Will wait up to 10 second(s) until the adb daemon is ready to use
Retrieving the current status of the phone ...
The phone is currently booted into the Android OS
The phone is booted into the Android OS
Booting the phone into the bootloader now ...
Waiting up to 60 seconds for the boot into the fastboot mode ...
The phone is booted into the bootloader
Booting the phone from the TWRP image "/data/backup/ASUS_ZENFONE8/twrp/current_twrp.img" now ...
Sending 'boot.img' (98304 KB) OKAY [ 2.840s]
Booting OKAY [ 10.406s]
Finished. Total time: 13.286s
Waiting up to 60 seconds for the boot of the phone ....
Waiting up to 10 seconds for the adb daemon to get ready ..
... the adb daemon is ready after second(s)
The phone is booted into TWRP: "twrp_I006D" version "3.7.0_12-0"
Waiting up to 10 seconds for the adb daemon to get ready
... the adb daemon is ready after second(s)
Wiping all data including media ...
Done.
You may need to reboot recovery to be able to use /data again.
TWRP will not recreate /data/media on an FBE device. Please reboot into your rom to create /data/media
Formatting Metadata using mke2fs...
Done.
Done processing script file
Wiping the metadata ...
++ /usr/bin/adb -s M6AIB760D0939LX shell umount /dev/block/by-name/metadata
umount: /dev/block/sda22: Invalid argument
++ /usr/bin/adb -s M6AIB760D0939LX shell mke2fs -F -t ext4 /dev/block/by-name/metadata
mke2fs 1.45.4 (23-Sep-2019)
Discarding device blocks: done
Creating filesystem with 4096 4k blocks and 4096 inodes
Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
Coyping the OS image file "/data/backup/ASUS_ZENFONE8/Lineage-19_Android12/lineage-19.1-20221216-nightly-sake-signed.zip" to "/tmp/lineage-19.1-20221216-nightly-sake-signed.zip" on the phone ...
adb: error: failed to read copy responsey-sake-signed.zip
/data/backup/ASUS_ZENFONE8/Lineage-19_Android12/lineage-19.1-20221216-nightly-sake-signed.zip: 1 file pushed, 0 skipped. 313.7 MB/s (1114300349 bytes in 3.387s)
adb: error: failed to read copy response
adb: device 'M6AIB760D0939LX' not found
Copying the image failed -- we will do another try in 5 seconds ...
/data/backup/ASUS_ZENFONE8/Lineage-19_Android12/lineage-19.1-20221216-nightly-sake-signed.zip: 1 file pushed, 0 skipped. 32.5 MB/s (1114300349 bytes in 32.719s)
Installing the OS image "/tmp/lineage-19.1-20221216-nightly-sake-signed.zip" into the slot "_a" ...
Installing zip file '/tmp/lineage-19.1-20221216-nightly-sake-signed.zip'
Flashing A/B zip to inactive slot: A
Step 1/2Step 2/2Updating partition details...
...done
Devices on super may not mount until rebooting recovery.
To flash additional zips, please reboot recovery to switch to the updated slot.
Done processing script file
OS image file "/tmp/lineage-19.1-20221216-nightly-sake-signed.zip" successfully installed.
Now changing the next active slot to _a ...
... successfully changed the active slot for the next reboot
*** Press return to reboot the phone now
Rebooting the phone now ...
Booting the Android OS using the command "adb reboot " now ...
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $
Testenvironment
I tested the script using this hardware and software:
Hardware:
ASUS Zenfone 8
TWRP
TWRP 3.7.0.12
OS Images installed via script
OmniROM 12
OmniROM 13
LineageOS 19
The script does not work for the images with the original Android from ASUS; the OS installation works but the phone does not boot from the new installation
The script install_os_via_twrp.sh is also available on my home page:
install_os_via_twrp.sh
Trouble Shooting
To update the installed OS to a new version in most cases neither a wipe nor a factory reset is necessary.
To install a different distribution on the phone in most cases a factory reset is required. (e.g installing LIneageOS if the current OS is OmniROM)

Categories

Resources