[GUIDE]Porting TWRP without source

Search This thread

Lucas VT

Member
Nov 17, 2015
34
4
OnePlus One
Moto 360
Hello,

I hope someone can lend me a hand.

I'm trying to port TWRP to Red Magic 7 Pro (NX709J).

I extracted the recovery.img and everything from the official rom provided on their website and i'm using the nexus6 twrp image.

I'm following all the steps but the recovery never works, the phone boots stright to the system.

The fstabs are in a completely different format and most of the paths are dependant on symlinks on the folders inside the ramdisk, i tried at first just following the steps and also I tried adding all the folders with symlinks to the ramdisk, but does not seem to make any difference.

On step 19 and 20 i dont think i really understand the objective.
-Should i modify the "twrp.fstab" paths to match the ones in the "recovery.fstab" and leave the ones that dont exist in this file alone?
-Should i replace everything by the paths on the "recovery.fstab"?
-Should i modify "/sdcard" and "/usb" on both "recovery.fstab" and "twrp.fstab"?

I see that the examples on the steps show a lot of files with the device name on them, in the official recovery the device name cannot be found once on any file name, so i dont know what should i name those files, i tried using ".recovery" and other names.

Also on the original ramdisk path there is no "ueventd.rc" but it can be found on "ramdisk/etc", I tried to put it in the twrp etc folder, in the ramdisk folder and on both, nothing works.

I also noticed that the magisk patched "boot.img" does not work when i use the failed twrp recovery, the magisk app does not detect the patch, but works flawlessly with the default recovery, i dont know if this can give any clue on what is happening.
 
Last edited:

Prowindows62

Member
Oct 10, 2020
13
0
Samsung Galaxy J2
Yes, I know XDA is filled with such guides.
But you can only port a TWRP if you implement parts of all the guides.
This guide is a summation of all those guides.

NOTE:
I would be using AIK-Linux in this tutorial, since I don't recommend Windows for all this, who knows what problems you will get into.

REQUIREMENTS:
1.Download these TWRP recoveries in accordance with your screen resolution.
A. If your screen resolution is 480x850, 480x854; download
https://twrp.me/lg/lgnexus4.html
B. If your screen resolution is 720x1280, 800x1280 or 720xsomething; download
https://twrp.me/asus/asusnexus720123g.html
C. If your screen resolution is 1080x1920, download
https://twrp.me/motorola/motorolanexus6.html
2. Download Android Image Kitchen-Linux from this thread:
https://forum.xda-developers.com/showthread.php?t=2073775

LET'S BEGIN:
1. Unzip Android Image Kitchen zip file.
3. Now, navigate to the unzipped folder of AIK (Android Image Kitchen).
4. Just Right Click and select "Open Terminal here".
5. Copy and paste your stock recovery.img and paste it in AIK folder.
6. In the terminal, type the command
Code:
su
Enter your root password, then type
Code:
./unpackimg.sh
7. This will unpack your stock recovery.img. Do not close the terminal.
8. Cut the new folders, ramdisk and split_img, and paste them somewhere outside of AIK folder.
9. Remove the stock recovery.img in AIK folder.
10. Now, copy and paste the twrp_recovery.img according to your screen resolution in the AIK folder.
11. Now, revert back to the terminal and type
Code:
./unpackimg.sh
12. This will unpack your twrp_recovery.img
13. Delete all the files in the new split_img folder we got by unpackimg twrp_recovery.img
14. Copy and paste all the files in stock split_img folder to the new split_img folder.
15. Delete following files from new ramdisk folder.
A. default.prop
B. fstab.devicename_or_chipsetname
C. ueventd.rc
D. Any other file like ueventd.devicename.rc
16. Copy and paste these files from stock ramdisk folder to new ramdisk folder.
Code:
default.prop
fstab.devicename
ueventd.rc
17. Now go into stock ramdisk/etc folder and copy recovery.fstab
18. Paste the recovery.fstab file in new ramdisk/etc folder.
19. Edit the twrp.fstab file according to the newly pasted recovery.fstab
20. You will have to replace"/sdcard" with "/external_sd" and "/usb" with "/usb-otg".
21. If the partitions stated above are not available in your fstab files then add these lines. Order may change on the format in which the files are written.
Code:
/external_sd          vfat         /dev/block/mmcblk1p1  flags=removable;storage;display="SDCARD"
/usb-otg                auto         /dev/block/sda1    flags=removable;storage;display="USB-OTG"
22. Edit the following lines as shown in default.prop
Code:
ro.secure=0
ro.adb.secure=0
security.perf_harden=0
ro.debuggable=1
persist.sys.usb.config=adb,mtp
23. Now, come out of the ramdisk folder and open the terminal.
24. Type
Code:
./repackimg.sh
25. Your new TWRP img would be generated and named as image-new.img by default. You may change the name later.

When you have successfully built the TWRP, or if you want to request one instead of creating yourself, contact me on this thread:
https://forum.xda-developers.com/android/general/unofficial-twrps-devices-source-code-t3833338


SPECIAL INSTRUCTIONS FOR MEDIATEK DEVICES:
1. The recovery.fstab you will get after unpacking your stock recovery.img would be flawed in most cases. I believe OEMs do this deliberately.
2. In order to know which partition is mounted at which location and at which device, you'll need DiskInfo (Install it from Play Store) and a root explorer.
3. Enable the following Diskinfo settings:
Code:
Show mount path
Show partition name
Show file system
Expert mode
Unmounted partitions
Device Mapper partitions
Temporary filesystems

4. Use the root explorer to find the path of your partitions. They would be located under /dev (mtk devices have bootimg and recovery here generally) and some other partitions like /system, /cache would be deeper inside.
5. You can trace their exact locations by navigating within the /dev directory for partition names like mmcblk0p5.


SPECIAL INSTRUCTIONS FOR DEVICES THAT DON'T HAVE RECOVERY.FSTAB WITHIN STOCK RECOVERY.IMG
1. In the ramdisk/etc folder, there might be a dummy recovery.fstab file with the symbol of link on it.
2. Right click on the file and select "Show Target". You'll get to know the path of original recovery.fstab file. It might be within the unpacked recovery or inside some other partition on your phone.
For example: Honor 7C devices have their recovery.fstab in /vendor/etc folder.

TROUBLESHOOTING INSTRUCTIONS:
1. If you get a dm-verity error or facing an encryption problem, go to this thread and flash the "dm-verity and forceencrypt disabler zip".
https://forum.xda-developers.com/android/software/universal-dm-verity-forceencrypt-t3817389
2. If you encounter a bootloop while booting into your new TWRP, please consult post #20 of this thread.
3. At times, the path of partitions during recovery boot is not the same as those during normal boot. That's why you may get errors like
Code:
Updating partitions details...
Failed to mount '/cache' (Invalid argument)
Failed to mount '/system' (Invalid argument)
Failed to mount '/data' (Invalid argument)
Failed to mount '/metadata' (Invalid argument)
...done
Unable to mount storage
Failed to mount '/data' (Invalid argument)
To resolve this, in your TWRP terminal type the following command
Code:
find /dev/block -name by-name
Replace the paths of the partitions in your fstab files with the ones you get as output using the command above (only the partitions which failed to mount).

If there are some bugs or you need some assistance in porting TWRP, contact me by mentioning in your post, for example @Augustoandro, we'll work on it to make it bug-free.

Special thanks to @aIecxs for his troubleshooting instructions of bootloop, "Failed to mount /partition_name (invalid argument)" error and also @inguna for guiding me on how to fix the "SDCARD not detected by the TWRP" problem and also fixing the MTP, ADB not working issue.
Another thanks to @seanybiker and @avirus for their troubleshooting instructions on "DM-Verity and forceencrypt" errors.

CREDITS:
@HostZero for his porting guide.
@osm0sis for his awesome Android Image Kitchen
@Zackptg5 for his "DM-Verity and Forceencrypt disabler zip".
Thank you, I ported CWM recovery to old turkish phone :D
 

doc.K

Member
Apr 12, 2022
48
9
Stucked on default.prop edited.
File is not opening and it's 0kb
Any idea?
 
Last edited:

aIecxs

Senior Member
Feb 17, 2016
1,888
536
gitlab.com
use prop.default
 

Attachments

  • Screenshot_2022-07-01-17-31-05-108_jackpal.androidterm.jpg
    Screenshot_2022-07-01-17-31-05-108_jackpal.androidterm.jpg
    314.5 KB · Views: 18
  • Like
Reactions: doc.K

Skorpion96

Senior Member
Aug 28, 2014
229
37
Palermo
I can't add
ro.secure=0
ro.adb.secure=0
security.perf_harden=0
ro.debuggable=1
persist.sys.usb.config=adb ,mtp

Because the file is a symlink what I have to do?
 

shaman79

Member
May 20, 2009
11
22
Hello, I went through the process and successfully created TWRP image for latest 7.1.2 Nougat firmware for Minix NEO-U9H. I was also able to install Magisk root.


For anyone looking to root your NEO-U9H Minix:
- Download recovery.img from this link: https://mega.nz/file/TbAgiLbI#j0tCGZkmaX0f7xBz1XGtHViUtAxyqU2yDdKgka2C4q4
- Download Magisk: https://mega.nz/file/baYHFAyS#dPYwIflz9ADmuhPcXS7VKOcTBtdBZhnSDYzbG3bYhSc
- Place both files to root of your SD card
- Unplug power cable from Minix
- Hold Power On button and plug in power cable
- Wait for TWRT logo to appear
- Install Magisk from the zipfile
- Reboot and enjoy


Thanks to OP for providing the guide.

Edit: fixed the links
 
Last edited:

xinulhacker

Member
Jul 19, 2022
21
4
Hello,

I hope someone can lend me a hand.

I'm trying to port TWRP to Red Magic 7 Pro (NX709J).

I extracted the recovery.img and everything from the official rom provided on their website and i'm using the nexus6 twrp image.

I'm following all the steps but the recovery never works, the phone boots stright to the system.

The fstabs are in a completely different format and most of the paths are dependant on symlinks on the folders inside the ramdisk, i tried at first just following the steps and also I tried adding all the folders with symlinks to the ramdisk, but does not seem to make any difference.

On step 19 and 20 i dont think i really understand the objective.
-Should i modify the "twrp.fstab" paths to match the ones in the "recovery.fstab" and leave the ones that dont exist in this file alone?
-Should i replace everything by the paths on the "recovery.fstab"?
-Should i modify "/sdcard" and "/usb" on both "recovery.fstab" and "twrp.fstab"?

I see that the examples on the steps show a lot of files with the device name on them, in the official recovery the device name cannot be found once on any file name, so i dont know what should i name those files, i tried using ".recovery" and other names.

Also on the original ramdisk path there is no "ueventd.rc" but it can be found on "ramdisk/etc", I tried to put it in the twrp etc folder, in the ramdisk folder and on both, nothing works.

I also noticed that the magisk patched "boot.img" does not work when i use the failed twrp recovery, the magisk app does not detect the patch, but works flawlessly with the default recovery, i dont know if this can give any clue on what is happening.
You need to modify the twrp.fstab to match the mount points in your stock boot image fstab.

You don't need ueventd.rc from your stock boot image.
 

xinulhacker

Member
Jul 19, 2022
21
4
Hello, I went through the process and successfully created TWRP image for latest 7.1.2 Nougat firmware for Minix NEO-U9H. I was also able to install Magisk root.


For anyone looking to root your NEO-U9H Minix:
- Download recovery.img from this link: https://mega.nz/file/TbAgiLbI#j0tCGZkmaX0f7xBz1XGtHViUtAxyqU2yDdKgka2C4q4
- Download Magisk: https://mega.nz/file/baYHFAyS#dPYwIflz9ADmuhPcXS7VKOcTBtdBZhnSDYzbG3bYhSc
- Place both files to root of your SD card
- Unplug power cable from Minix
- Hold Power On button and plug in power cable
- Wait for TWRT logo to appear
- Install Magisk from the zipfile
- Reboot and enjoy


Thanks to OP for providing the guide.
Links broken 😢
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Now a symlink to prop.default.
    Someone ported twrp to my device
  • 37
    Yes, I know XDA is filled with such guides.
    But you can only port a TWRP if you implement parts of all the guides.
    This guide is a summation of all those guides.

    NOTE:
    I would be using AIK-Linux in this tutorial, since I don't recommend Windows for all this, who knows what problems you will get into.

    REQUIREMENTS:
    1.Download these TWRP recoveries in accordance with your screen resolution.
    A. If your screen resolution is 480x850, 480x854; download
    https://twrp.me/lg/lgnexus4.html
    B. If your screen resolution is 720x1280, 800x1280 or 720xsomething; download
    https://twrp.me/asus/asusnexus720123g.html
    C. If your screen resolution is 1080x1920, download
    https://twrp.me/motorola/motorolanexus6.html
    2. Download Android Image Kitchen-Linux from this thread:
    https://forum.xda-developers.com/showthread.php?t=2073775

    LET'S BEGIN:
    1. Unzip Android Image Kitchen zip file.
    3. Now, navigate to the unzipped folder of AIK (Android Image Kitchen).
    4. Just Right Click and select "Open Terminal here".
    5. Copy and paste your stock recovery.img and paste it in AIK folder.
    6. In the terminal, type the command
    Code:
    su
    Enter your root password, then type
    Code:
    ./unpackimg.sh
    7. This will unpack your stock recovery.img. Do not close the terminal.
    8. Cut the new folders, ramdisk and split_img, and paste them somewhere outside of AIK folder.
    9. Remove the stock recovery.img in AIK folder.
    10. Now, copy and paste the twrp_recovery.img according to your screen resolution in the AIK folder.
    11. Now, revert back to the terminal and type
    Code:
    ./unpackimg.sh
    12. This will unpack your twrp_recovery.img
    13. Delete all the files in the new split_img folder we got by unpackimg twrp_recovery.img
    14. Copy and paste all the files in stock split_img folder to the new split_img folder.
    15. Delete following files from new ramdisk folder.
    A. default.prop
    B. fstab.devicename_or_chipsetname
    C. ueventd.rc
    D. Any other file like ueventd.devicename.rc
    16. Copy and paste these files from stock ramdisk folder to new ramdisk folder.
    Code:
    default.prop
    fstab.devicename
    ueventd.rc
    17. Now go into stock ramdisk/etc folder and copy recovery.fstab
    18. Paste the recovery.fstab file in new ramdisk/etc folder.
    19. Edit the twrp.fstab file according to the newly pasted recovery.fstab
    20. You will have to replace"/sdcard" with "/external_sd" and "/usb" with "/usb-otg".
    21. If the partitions stated above are not available in your fstab files then add these lines. Order may change on the format in which the files are written.
    Code:
    /external_sd          vfat         /dev/block/mmcblk1p1  flags=removable;storage;display="SDCARD"
    /usb-otg                auto         /dev/block/sda1    flags=removable;storage;display="USB-OTG"
    22. Edit the following lines as shown in default.prop
    Code:
    ro.secure=0
    ro.adb.secure=0
    security.perf_harden=0
    ro.debuggable=1
    persist.sys.usb.config=adb,mtp
    23. Now, come out of the ramdisk folder and open the terminal.
    24. Type
    Code:
    ./repackimg.sh
    25. Your new TWRP img would be generated and named as image-new.img by default. You may change the name later.

    When you have successfully built the TWRP, or if you want to request one instead of creating yourself, contact me on this thread:
    https://forum.xda-developers.com/android/general/unofficial-twrps-devices-source-code-t3833338


    SPECIAL INSTRUCTIONS FOR MEDIATEK DEVICES:
    1. The recovery.fstab you will get after unpacking your stock recovery.img would be flawed in most cases. I believe OEMs do this deliberately.
    2. In order to know which partition is mounted at which location and at which device, you'll need DiskInfo (Install it from Play Store) and a root explorer.
    3. Enable the following Diskinfo settings:
    Code:
    Show mount path
    Show partition name
    Show file system
    Expert mode
    Unmounted partitions
    Device Mapper partitions
    Temporary filesystems

    4. Use the root explorer to find the path of your partitions. They would be located under /dev (mtk devices have bootimg and recovery here generally) and some other partitions like /system, /cache would be deeper inside.
    5. You can trace their exact locations by navigating within the /dev directory for partition names like mmcblk0p5.


    SPECIAL INSTRUCTIONS FOR DEVICES THAT DON'T HAVE RECOVERY.FSTAB WITHIN STOCK RECOVERY.IMG
    1. In the ramdisk/etc folder, there might be a dummy recovery.fstab file with the symbol of link on it.
    2. Right click on the file and select "Show Target". You'll get to know the path of original recovery.fstab file. It might be within the unpacked recovery or inside some other partition on your phone.
    For example: Honor 7C devices have their recovery.fstab in /vendor/etc folder.

    TROUBLESHOOTING INSTRUCTIONS:
    1. If you get a dm-verity error or facing an encryption problem, go to this thread and flash the "dm-verity and forceencrypt disabler zip".
    https://forum.xda-developers.com/android/software/universal-dm-verity-forceencrypt-t3817389
    2. If you encounter a bootloop while booting into your new TWRP, please consult post #20 of this thread.
    3. At times, the path of partitions during recovery boot is not the same as those during normal boot. That's why you may get errors like
    Code:
    Updating partitions details...
    Failed to mount '/cache' (Invalid argument)
    Failed to mount '/system' (Invalid argument)
    Failed to mount '/data' (Invalid argument)
    Failed to mount '/metadata' (Invalid argument)
    ...done
    Unable to mount storage
    Failed to mount '/data' (Invalid argument)
    To resolve this, in your TWRP terminal type the following command
    Code:
    find /dev/block -name by-name
    Replace the paths of the partitions in your fstab files with the ones you get as output using the command above (only the partitions which failed to mount).

    If there are some bugs or you need some assistance in porting TWRP, contact me by mentioning in your post, for example @Augustoandro, we'll work on it to make it bug-free.

    Special thanks to @aIecxs for his troubleshooting instructions of bootloop, "Failed to mount /partition_name (invalid argument)" error and also @inguna for guiding me on how to fix the "SDCARD not detected by the TWRP" problem and also fixing the MTP, ADB not working issue.
    Another thanks to @seanybiker and @avirus for their troubleshooting instructions on "DM-Verity and forceencrypt" errors.

    CREDITS:
    @HostZero for his porting guide.
    @osm0sis for his awesome Android Image Kitchen
    @Zackptg5 for his "DM-Verity and Forceencrypt disabler zip".
    3
    Can't find fstab.devicename in stock ramdisk folder. btw phone is samsung a41 (sm-a415f) @Augustoandro
    This happens sometimes. Some devices directly reference the recovery.fstab file instead of fstab.devicename.
    Edit the rest of the files and proceed further.

    HIT THANKS IF FOUND USEFUL
    2
    SuperSU or Magisk won't install into system but into boot and data

    in TWRP you have a terminal. type
    Code:
    ls -ld $(find /dev/block -name by-name)/*
    you can manually mount, all you need is a folder as mount point
    Code:
    mkdir /system_root
    mount /dev/block/bootdevice/by-name/system /system_root
    mount
    2
    Pls brother help me port twrp for my device. Here is my stock recovery image link : https://drive.google.com/file/d/1dqBU4f0ZXK8Ot0V9t-4Tw6f_60UHg7ca/view?usp=drivesdk.
    My phone's resolution : 720 x 1280 pixel.
    This is not a TWRP request thread. I have included a link in the guide which takes you to a TWRP request thread. Post your request over there.

    HIT THANKS IF FOUND USEFUL
    2
    Hi I tried to Port a Recovery for my H96 Max RK3399 TV Box .
    I used TWRP From My RK3328 TVBox.
    I can Boot in Recovery, but its not Mounting any Partition (everywhere 0MB)
    I Think the problem is in .Fstab File but I am Not sure.
    I would appreciate help

    Sorry for my poor English
    Partitions not being recognized means the problem is in fstab files. Both recovery.fstab and twrp.fstab need to be edited.
    I am sure of it.

    HIT THANKS IF FOUND USEFUL