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.
- Your device’s stock recovery
- TWRP (Download the version according to your approximate screen resolution):
- TWRP 480×850
- TWRP 720×1280
- TWRP 1080×1920
- Android Image Kitchen (Linux version)
- First download and extract the Android Image Kitchen file to its own folder.
- Place your stock recovery.img file inside the extracted AIK folder.
- Right click inside the extracted folder, and choose “Open Terminal here”.
- In the Linux terminal, type the command: ./unpackimg.sh
- Your stock recovery image will be unpacked into two new folders ramdisk and split_img. Do not close the terminal at this point.
- Move the newly created ramdisk and split_img folders outside of the AIK folder.
- Now delete the stock recovery.img inside the AIK folder.
- Copy the twrp_recovery.img file you downloaded from the Requirements section of this guide, into the AIK folder.
- Inside the Linux terminal, type: ./unpackimg.sh
- Now the twrp_recovery.img will be unpacked, as it did with the stock recovery.img
- 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.
- Now copy all the files from the stock split_img folder into the TWRP split_img folder.
- Delete these files from the TWRP ramdisk folder:
- Any other file like ueventd.devicename.rc
- Now copy these files from the stock ramdisk folder to the TWRP ramdisk folder:
default.prop fstab.devicename ueventd.rc
- Now go into the stock ramdisk/etc folder and copy recovery.fstab, and place it in the TWRP ramdisk/etc folder.
- 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
- You need to replace instances of “/sdcard” with “/external_sd”, and “/usb” with “/usb-otg”.
- 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"
- 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
- Back out of the ramdisk folder, and launch the terminal. Enter these commands: ./repackimg.sh
- 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.