Javascript required
Skip to content Skip to sidebar Skip to footer

How Easy is It to Compile Twrp

In this comprehensive guide, we will show you the steps to create and port TWRP Recovery to any Android device. When it comes to custom development, the involvement of a custom recovery becomes among the most important prerequisites. This is because your stock recovery isn't designed to carry out advanced functionalities. Hence right after a user unlock the device's bootloader, flashing the TWRP Recovery is probably the first step that they usually do.

The benefits of this recovery stand aplenty. For example, you could easily flash ZIP and IMG files, create and restore Nandroid backups, mount external devices, and carry out other advanced functionalities. While some of these functionalities could be carried out without TWRP Recovery as well, but that requires way too much effort. Hence getting hold of the TWRP Recovery for your device is the top-most requirement,

However, this recovery isn't yet available for every Android device. All the official TWRP builds are hosted on their servers whereas the unofficial ones could be found from XDA. Even then, there are quite a few devices that don't belong to any of these two lists. And for them, this guide shall come in handy. Given here are the detailed steps to create and port TWRP Recovery to any Android device.

As of now, it is limited to Android devices running the Qualcomm chipset. With MediaTek devices, there are quite a few issues, majorly with the recovery's recovery.fstab file. As and when I am able to rectify that issue, will create a separate guide for MTK devices as well. With that said, here are the detailed instructions to create and port TWRP Recovery to Android devices with Qualcomm as the underlying chip. Follow along.


  • How to Fix Soft brick/Bootloop after installing TWRP Recovery
  • Copy Move Rename Delete Files and Folders via TWRP Recovery
  • How to Fix TWRP 0MB Internal Memory Issue
  • Update TWRP Recovery on any Android Device

How to Create and Port TWRP to any Android Device

The below instructions have been segregated into separate sections for ease of understanding. Follow along in the exact same sequence as mentioned. Warning! The below process is quite risky and could brick your device and make it unusable. Droidwin and its members wouldn't be held responsible in case of a thermonuclear war, your alarm doesn't wake you up, or if anything happens to your device or your data by performing the below steps.

STEP 1: Enable Linux Shell on Windows 10

To carry out all such Android related tweaks, Linux is the go-to choice. However, I didn't wish to leave my Windows OS at the same time. So I enabled the Linux Bash Shell Command inside Windows 10 only. It is a Developer Mode feature present inside Windows 10 for a few years, but not many seem to have an idea of this. The biggest advantage of this feature is the fact that you don't have to use any Virtual Machine or a third-party app like Cygwin.

install linux inside windows 10

Everything is taken care of by the Windows OS itself. And I have tried out the entire instructions to create and port TWRP Recovery on Android using this Shell Command on Windows 10, so there is no reason why it shouldn't work for you. With that said, refer to this guide to use Linux on your Windows 10 PC: How to Run Linux Commands in Windows 10 [without Virtual Machine].

STEP 2: Install Android Image Kitchen

Once you have enabled Linux Shell Command on your Windows 10, the next step is to install the Android Image Kitchen. This is where we would be cooking the TWRP Recovery for your device. So download the AIK-Linux-v3.7-ALL.tar.gz. Credits: goes to XDA Senior Recognized Developer / Recognized Contributor osm0sis. Do keep in mind that this is a Linux build as we would be working inside the Linux ecosystem (on a Windows 10 OS!).

install android image kitchen linux windows 10

Moving on, once you have downloaded it, use an extracting software such as WinRAR to open it. Then extract its contents to any convenient location on your PC. While downloading or extracting it, Windows Defender will identify it as a Trojan. So you might have to temporarily disable it while downloading and extracting Android Kitchen. Once the download/extraction is complete, then make sure to re-enable the Defender again. Then move to the next step to create and port TWRP Recovery to any Android device.


  • How to Root Android Devices via TWRP Recovery
  • TWRP: fastboot flash vs fastboot boot: Which command to use
  • How to use USB OTG or Pen Drive to Flash File via TWRP Recovery
  • How to Fix Soft brick/Bootloop after installing TWRP Recovery

STEP 3: Download TWRP for Screen Resolution

You will now have to download the required TWRP recovery in accordance with the desired screen resolution. Thanks to XDA Senior Member Augustoandro for the below piece of valuable information.

  • If your screen resolution is 480 x 850 or 480 x 854; then download LG Nexus 4 TWRP.
  • Likewise, if your screen resolution is 720 x 1280, or 800 x 1280 or 720 x 'something'; then download Asus Nexus 7 TWRP
  • On the other hand, if your screen resolution is 1080×1920, then download the Motorola Nexus 6 TWRP. As for this guide, I have downloaded this one only.

Once you have downloaded the required recovery file, move to the next step to create and port TWRP Recovery to any Android device.

STEP 4: Get the Stock Recovery.img File

Now you will have to get a hold of the stock recovery.img file. This would be present inside the stock firmware itself. So download the firmware for your device and region (corresponding to your current build number). Once downloaded, extract it. Now if you have a Pixel device, then its partition files are present in ZIP format. So just extract it and get the stock recovery.img file.

On the other hand, OnePlus and a bunch of other OEMs have all its partition files under the payload.bin file. Realme on the other hand has its firmware files under OZIP format. So to extract these files, please refer to our detailed reference guides:

  • How to Extract payload.bin and get stock boot image file
  • Extract Stock Boot.img from OnePlus OxygenOS Stock ROM
  • How to Extract OZIP Realme Stock ROM (Firmware)

extract stock recovery oneplus

While these guides focus on stock boot.img file, the process is exactly similar for recovery.img file. Just follow the guide as it is and you will get the desired file. Once you get this stock recovery.img file, move it inside the Android Image kitchen folder on your PC (see the below image in STEP 5). Then proceed to the next step to create and port TWRP Recovery to any Android device.

STEP 5: Get Root Privileges in Linux Shell on Windows 10

It's now time to go to SuperUser Mode and get root access on Linux! For that, you will have to open Ubuntu inside the same directory where you have extracted the Android Image Kitchen (AIK).

  1. So go to the AIK folder, and while pressing the Shift key, right-click in an empty location and select Open Linux Shell here.
    open linux shell inside android image kitchen
  2. By doing so, Ubuntu will automatically pick up the directory of AIK.
  3. Now type in the below code and hit Enter:
    su
  4. It will now ask you to enter the password. Enter the same password that you had input in STEP 1 while setting up Linux for the first time.
    gain root linux shell command windows 10
  5. That's it. You have now got the Root Privileges. Move over to the next step to create and port TWRP Recovery to any Android device.

STEP 6: Creating TWRP Recovery

  1. First off, start by unpacking the stock recovery.img file via the following command:
    ./unpackimg.sh

    unpack twrp recovery android image kitchen

  2. You will now get two 2 folders: ramdisk and split_img. Move them outside the Android Image Kitchen (AIK) folder. Likewise, also move the stock recovery.img file outside the AIK folder.
    move ramdisk split_img recovery outside Android image kitchen
  3. Now move the downloaded TWRP Recovery (from STEP 3) to this AIK folder.
    move twrp recovery inside android image kitchen
  4. Use the below command to unpack this TWRP Recovery (earlier we had unpacked stock recovery, this time we are unpacking TWRP):
    ./unpackimg.sh

    unpack twrp recovery using android image kitchen

  5. As soon as the unpacking is completed, go to the split_img folder. You will see a few TWRP files, delete all those files.
    delete twrp recovery split img files
  6. Now copy all the files from the stock recovery split_img folder (that you have moved outside the AIK folder) to the new empty split_img folder (from where you have just deleted the twrp files).
  7. When that is done, delete the following files from the new ramdisk folder (that is created by TWRP Recovery):
    • default.prop
    • fstab.devicename_or_chipsetname
    • ueventd.rc
    • Any other file like ueventd.devicename.rc
      delete twrp recovery ramdsik files
  8. Now copy and paste these files from the stock ramdisk folder (that we got from stock recovery) to the new ramdisk folder (that we got from TWRP):
    • default.prop
    • fstab.devicename [if you can't find this file, don't forget to check out the /vendor/etc folder as well].
    • ueventd.rc [you may check the ramdisk > system > etc folder for this file].
      move files to new ramdisk twrp recovery folder
  9. Now copy the recovery.fstab file from stock ramdisk > system > etc folder and move it to new ramdisk > etc folder. Again, stock ramdisk is the folder that you got via stock recovery whereas the new ramdisk is linked to the TWRP recovery.
    move recovery.fstab to new ramdisk etc folder
  10. Open both the recovery.fstab and twrp.fstab via Notepad++. Then edit the twrp.fstab file according to the newly pasted recovery.fstab.
  11. Make sure to replace"/sdcard" with "/external_sd" and "/usb" with "/usb-otg". However, if you don't find these partitions inside the fstab files, then manually add these lines:
    modify twrp recovery fstab file
  12. /external_sd          vfat         /dev/block/mmcblk1p1  flags=removable;storage;display="SDCARD" /usb-otg                auto         /dev/block/sda1    flags=removable;storage;display="USB-OTG"
  13. Finally, open the default.prop file via Notepad++ and make the following changes:
    ro.secure=0 ro.adb.secure=0 security.perf_harden=0 ro.debuggable=1 persist.sys.usb.config=adb,mtp

    edit default prop file

  14. Finally, it's time to repack all these pieces of stuff. So come out of the ramdisk folder and inside the main Android Image Kitchen folder, open the Linux shell window (if you already have the previously opened one, continue in that only).  Now type in the below command to repack all the files:
    ./repackimg.sh

    new twrp recovery img created using android image kitchen

  15. The new TWRP will now be created inside the Android Image Kitchen folder and will be named as image-new.img.
    new twrp.img recovery created

That's it. These were the steps to create and port TWRP Recovery for any Android device. You may flash it onto your device and reap the rewards. With that said, if you have any queries, do let us know in the comments section below. I will try my best to address all your queries in as much detail as possible.


  • How to Replace LineageOS Recovery with TWRP
  • Root Android 11 via Magisk Patched boot.img (without TWRP)
  • How to Root Android Devices via TWRP Recovery
  • How to Pass Magisk SafetyNet on Rooted Android 11

Other Useful TWRP Resources

  • Now that you have created the TWRP Recovery for yourself, it's time to flash it onto your device. For that, you may refer to our comprehensive guide: TWRP: fastboot flash vs fastboot boot: Which command to use.
  • Then upon flashing the TWRP, if you end up in a bootloop, then refer to our guide: How to Fix Soft brick/Bootloop after installing TWRP Recovery
  • Likewise, if you get unable to mount data partition error, or internal storage shows 0MB, then this guide will help you out: How to Fix TWRP 0MB Internal Memory Issue.

stoddarddoely1980.blogspot.com

Source: https://www.droidwin.com/create-port-twrp-recovery-android/