Monday, February 18, 2019

recovery mode - Install TWRP to only one slot or offline boot.img file, not both


I want to install TWRP on my phone that uses the A/B partition schema. The official TWRP installer ZIP by default installs to both boot_a and boot_b. This always breaks the system in the inactive slot because I install Magisk after flashing/OTA.


Can I install TWRP to only one slot, or an offline boot.img file (like Magisk Manager supports)?



Answer



So this way, I ended up creating a script on my own.


Lucky enough, installing TWRP to boot.img isn't hard at all. The install script in TWRP just replaces ramdisk.cpio with the one ramdisk-twrp.cpio provided in the ZIP.


The effective part of the script is as following, root is of course required.


ln -s /system/bin/linker64 /sbin/linker
cp /sbin/magiskboot

mkdir /data/local/tmp/twrp
cd /data/local/tmp/twrp
/sbin/magiskboot --unpack
cat > ramdisk.cpio
/sbin/magiskboot --repack boot.img
cp new-boot.img /sdcard/new-boot.img

Now the TWRP-installed new-boot.img is located at /sdcard/.


To install to a single slot, dd the boot image out and apply the same process as shown above and dd the new image back.


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...