How to Port TWRP for Android Without Source

TWRP is the most popular custom recovery for Android devices, but unfortunately there is no “generic” TWRP that is guaranteed to work with all devices. In fact there are many devices that do not have a TWRP available, possibly due to (lack of) device popularity.

If you own such a device that does not have an available TWRP port, it is actually really quite easy to port it yourself. In this Appuals guide, we will show you how to port TWRP without source, all you need is your device’s stock recovery and Android Kitchen. We’ll be using Android Kitchen for Linux in this guide, as the procedure in the Windows version is quite a bit trickier (and perhaps prone to error).

If you’d like to try porting TWRP from source, see Appuals guide How to DIY Port TWRP for Android.

Requirements:

  1. First download and extract the Android Image Kitchen file to its own folder.
  2. Place your stock recovery.img file inside the extracted AIK folder.
  3. Right click inside the extracted folder, and choose “Open Terminal here”.
  4. In the Linux terminal, type the command: ./unpackimg.sh
  5. Your stock recovery image will be unpacked into two new folders ramdisk and split_img. Do not close the terminal at this point.
  6. Move the newly created ramdisk and split_img folders outside of the AIK folder.
  7. Now delete the stock recovery.img inside the AIK folder.
  8. Copy the twrp_recovery.img file you downloaded from the Requirements section of this guide, into the AIK folder.
  9. Inside the Linux terminal, type: ./unpackimg.sh
  10. Now the twrp_recovery.img will be unpacked, as it did with the stock recovery.img
  11. Go inside the split_img folder (from the TWRP image we just unpacked, not the one from your stock .img we moved earlier) and delete all of the files inside.
  12. Now copy all the files from the stock split_img folder into the TWRP split_img folder.
  13. Delete these files from the TWRP ramdisk folder:
  14. default.prop
  15. fstab.devicename_or_chipsetname
  16. ueventd.rc
  17. Any other file like ueventd.devicename.rc
  18. Now copy these files from the stock ramdisk folder to the TWRP ramdisk folder:
    default.prop
    fstab.devicename
    ueventd.rc
  19. Now go into the stock ramdisk/etc folder and copy recovery.fstab, and place it in the TWRP ramdisk/etc folder.
  20. Open both the twrp.fstab file and the recovery.fstab file in a text editor, and edit the properties in twrp.fstab to match properly with the properties in recovery.fstab
  21. You need to replace instances of “/sdcard” with “/external_sd”, and “/usb” with “/usb-otg”.
  22. If those partitions are not available in your fstab files, you need to add these lines:
    /external_sd          vfat         /dev/block/mmcblk1p1  flags=removable;storage;display="SDCARD"
    /usb-otg                auto         /dev/block/sda1    flags=removable;storage;display="USB-OTG"
  23. Now you must edit the following lines as displayed in default.prop:
    ro.secure=0
    ro.adb.secure=0
    security.perf_harden=0
    ro.debuggable=1
    persist.sys.usb.config=adb,mtp
  24. Back out of the ramdisk folder, and launch the terminal. Enter these commands: ./repackimg.sh
  25. The TWRP .img will be repacked, and named “image-new.img” by default. You can rename this if you wish.

Instructions for Mediatek Devices

Note: The recovery.fstab file you get after unpacking the stock recovery.img will have some flaws in it, most likely deliberate from the OEM. You need to install DiskInfo app from Play Store, and a root explorer, so that you will known which partition is mounted at which location and device.

Launch the DiskInfo app, and make sure the following Settings are enabled:

  • Show mount path
  • Show partition name
  • Show file system
  • Expert Mode
  • Unmounted partitions
  • Device Mapper partitions
  • Temporary filesystems

Now launch your root explorer app, and find the path of your partitions. Typically, they would be found under /dev, and some other partitions like /system and /cache are located in deeper levels.

If you need to trace their exact locations, you can navigate inside the /dev directory and search for partition names such as “mmcblk0p5”.

Devices Without Recovery.Fstab

If your device does not produce a recovery.fstab file after unpacking the stock recovery.img, there are a few things to try.

First, check in the ramdisk/etc folder, where you might find a dummy recovery.fstab file that has a link symbol.

Right click on the dummy file and choose “Show Target”, which should present you with the location of the original recovery.fstab. Sometimes OEMs place them in other folders, such as /vendor/etc folder.

ABOUT THE AUTHOR

Kamil Anwar


Kamil is a certified MCITP, CCNA (W), CCNA (S) and a former British Computer Society Member with over 9 years of experience Configuring, Deploying and Managing Switches, Firewalls and Domain Controllers also an old-school still active on FreeNode.