1

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)?

1

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 <path-to-magiskboot> /sbin/magiskboot
mkdir /data/local/tmp/twrp
cd /data/local/tmp/twrp
/sbin/magiskboot --unpack <path-to-boot.img>
cat <path-to-[ramdisk-twrp.cpio]> > 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.