OnePlus 5: Unlock Bootloader | Flash TWRP | Root | Nandroid & EFS Backup & More !!

Search This thread

Funk Wizard

Forum Moderator
Staff member
Nov 8, 2014
4,790
17,448
New Delhi
OnePlus 8 Pro
OnePlus 9 Pro
OnePlus 5: Unlock Bootloader | Flash TWRP | Root | Nandroid & EFS Backup & More !!

qz9h9NZ.jpg



Q9IP5VP.png



3RVsG8v.png


Before you start, OTA up to the latest System Update available.
Settings > System Updates > Download & Install the latest available
 
Last edited:

Funk Wizard

Forum Moderator
Staff member
Nov 8, 2014
4,790
17,448
New Delhi
OnePlus 8 Pro
OnePlus 9 Pro
2a7O1JW.jpg


Introduction​

Rooting this device is actually quite a simple and easy process. Before you begin, it is recommended that you at least try to understand what each part of the process will do. Although this guide will elongate each step in order to show all of the details, the method used can be broken up into 3 main steps: ​

Unlocking the Bootloader
Installing a Custom Recovery
Gaining Root Access


Each new step relies on the previous step so please follow the entire process and a basic summary of each part is described as below:

Unlocking Bootloader​
Opens the door to the internal memory of the device to be written on to. This allows you to flash images onto the main partitions of the phone.​

Installing a Custom Recovery​​
A custom recovery is flashed onto the recovery partition of the device and overwrites the stock recovery that exists by default. Custom recoveries bring lots of functionality and give you the ability to perform wipes, install flashable zips, create full backups of your device (Nandroid backup), and various other features. An unlocked bootloader is needed to install a custom recovery.

Gaining Root Access​​
You can gain root by either flashing via recovery a pre-rooted custom rom, or flashing a zip containing the SuperSU binaries or by Flashing Magisk Zip for a system less root. A custom recovery is necessary to do this.

After completing these steps your phone will be rooted, the phone will have a custom recovery installed and an unlocked bootloader. This, in my opinion, is the a practical and beneficial method for rooting your phone. It will give you some basic adb/fastboot knowledge, and should hopefully help you have a decent understanding of the entire process. This method will work regardless of any android version on the phone.

If you are confused by anything in this guide, I highly suggest getting it clarified being before moving on. Ask your question in this thread and I or someone else will likely answer. Also we would suggest that you read over the whole thread a few times before actually doing anything to the phone.​
 
Last edited:

Funk Wizard

Forum Moderator
Staff member
Nov 8, 2014
4,790
17,448
New Delhi
OnePlus 8 Pro
OnePlus 9 Pro
Setup, Preparation & Prerequisites​​
Basic tasks that may be referred to throughout this guide:​
Open Command Prompt: Press Shift + Right Click anywhere on the screen and select Open Command Window here

Enter Fastboot/Bootloader Mode: Turn the phone off. Hold volume up + power until the "fastboot" screen appears. [Alternatively, if Advanced Reboot is enabled, you can press Reboot > Bootloader from the power menu.]

Enter Recovery Mode: Turn the phone off. Hold volume down + power until the "OnePlus Logo" screen appears. [Alternatively, if Advanced Reboot is enabled, you can press Reboot -> Recovery from the power menu.]

ADB and Fastboot Installation​
1. Download the ADB For Windows from here Credits @Snoop05 his Original XDA Thread Here

Or You can manually update Fastboot and ADB binaries here Credits @lj50036 his Original XDA Thread Here

2. Run the .exe file downloaded from above as Administrator.
3. Press 'Y' every time the installer asks for.
4. Continue Driver Installation.

Now, ADB and Fastboot have been installed on your PC and should be Working as desired.

Things To Remember​
Show File Extensions :good:
Open a command prompt window and run "Control folders" (without the quotes). Go to the View tab and uncheck the "Hide extensions for known file types" option. This will help avoid confusion when renaming files.

Battery :good:
Ensure that your phone has at least 60% battery remaining, and that your PC is plugged in and wont shut down spontaneously during the process. The procedure doesn't take very long , but its best to have enough charge in case something goes wrong.

Backup (Optional) :good:
Unlocking the bootloader will/should completely wipe all data from the device. This includes apps, settings and even the contents of the internal sdcard (pictures, music, etc.). Copy all important files off the phone onto a PC or upload them to a cloud.

USB Debugging :good:
On your phone go to Settings > About phone > Tap on Build number 7 times. This will enable Developer options. Now go back to Settings > Developer options > Enable USB debugging

Enable OEM Unlocking :good:
On your phone go to Settings > Developer options. Then enable the 'OEM Unlocking' option. Also make sure that from now on, OEM unlocking option is enabled before you reboot as sometimes, it might get disabled itself.

Enable Advanced Reboot :good:
On your phone go to Settings > Developer options. Then enable the 'Advanced Reboot' option.
 
Last edited:

Funk Wizard

Forum Moderator
Staff member
Nov 8, 2014
4,790
17,448
New Delhi
OnePlus 8 Pro
OnePlus 9 Pro
Unlocking Bootloader


Turn the phone off. Then boot it into fastboot mode by holding volume up + power or select reboot to bootloader if advanced reboot is activated via developer options. The phone will display "fastboot" text indicating that it has successfully entered fastboot mode.

Plug the phone into your PC, then open a command prompt window on the desktop (Shift + Right Click -> Open Command Window here) and type:

Code:
fastboot devices

This command will list the connected devices. If your phones serial number shows up you are good to go and may continue. If the phone is NOT listed this indicates that your drivers are not installed correctly. In order for you to continue you must fix your drivers so that your phone is listed under fastboot devices.

If the phone has been recognized by the command above, proceed to unlocking the bootloader with the following command:

Remember this Step will WIPE EVERYTHING off the phone so Backup all your Data

Code:
fastboot oem unlock

x6hqaHU.jpg


You would be greeted with a Unlock Bootloader Warning page, Hit the Vol button to select Yes and turn it Blue and Hit the Power Button to Execute the selection

R9phbUg.jpg


Your device will reboot, show you a Secure boot warning, reboot into stock recovery and wipe all data. Once done, your phone will reboot into the OS.

Please continue and follow the next post to install Custom Recovery
 
Last edited:

Funk Wizard

Forum Moderator
Staff member
Nov 8, 2014
4,790
17,448
New Delhi
OnePlus 8 Pro
OnePlus 9 Pro
Flashing TWRP Recovery
w2sXTi1.png

Downloads:

Recovery:
Codeworkx TWRP | Blu_Spark TWRP


Magisk

Wait until the phone has fully booted up into android, then adjust the following settings on the phone:
wBXVbVz.png

USB Debugging:
On your phone go to Settings > About phone > Tap on Build number 7 times. This will enable Developer options. Now go back to Settings > Developer options > Enable USB debugging
IE5ox1y.png

Enable OEM Unlocking:
On your phone go to Settings > Developer options. Then enable the 'OEM Unlocking' option and make sure that from now on, OEM unlocking option is enabled before you reboot. Sometimes, it might get disabled itself.
9uWeJLs.png

Enable Advanced Reboot:
On your phone go to Settings > Developer options. Then enable the 'Advanced Reboot' option.

Download all the files, place SuperSU or Magisk on Device Internal Memory and TWRP img in the Android Folder under the Platform Tools folder in C Drive

Then boot it into fastboot/bootloader mode by holding volume up + power or selecting the reboot to bootloader via advanced reboot options.

Open a new command prompt in the same location and run the following commands:

Code:
fastboot flash recovery (file name).img
weogW1R.jpg

Once the flash has completed, Don't use the "Fastboot Reboot" Command Instead Unplug Your phone then Manually boot it into recovery by keeping Power + Volume Down button pressed or you can also use the command:

Code:
fastboot boot recovery.img

PS: DO NOT BOOT IN OS JUST YET & CONTINUE TO THE ROOTING POST
 
Last edited:

Funk Wizard

Forum Moderator
Staff member
Nov 8, 2014
4,790
17,448
New Delhi
OnePlus 8 Pro
OnePlus 9 Pro
Gaining Root Access

This is a continued post from the above post...


For Users who want to remain Encrypted: :fingers-crossed:

1. Boot into TWRP Recovery and allow system modifications.
2. Swipe right and enable modifications.
3. Select your preferred Language, Tap “Never show this screen on boot again,” and Swipe allow modification.
4. Navigate to Install and select Magisk Or SuperSU to root OnePlus 5.
5. Swipe to confirm the flash
6. Reboot System

Keep in mind that the first boot after wiping the phone may take longer than usual, as the phone will need to rebuild the dalvik cache and initialize other first boot and would reboot a few times due to SuperSU Flash.

For Users who want to Decrypt Data have to Format Data & Flash No Verity OP5 Zip :fingers-crossed:

1. Boot into TWRP Recovery and allow system modifications.
2. Swipe right and enable modifications.
3. Select your preferred Language, Tap “Never show this screen on boot again,” and Swipe allow modification.

Go to “Wipe” section and tap “Format Data”, and type “yes” to mount internal storage

4. Download & Transfer no_verity_op5.zip to the device over MTP from here Credits @snowwolf725
5. Go to “Install” section, select no_verity_op5.zip, and swipe to confirm the flash
6. Transfer latest Magisk/SuperSU to the device over MTP to your Oneplus 5 & Swipe to confirm the flash
7. Reboot System

* MTP, known as Media Transfer Protocol, is the same way you transfer files from your PC to your device when booted into system.

Congrats! That is all! Your Device now has an unlocked bootloader, a custom recovery installed and is rooted along with your preference of staying encrypted or decrypted.

Warning: Do not flash partial update OTAs (under 1 GB) on a modified device! If you want to use partial OTAs, you must first flash a full OTA that it applies to, and then flash the partial OTA from stock recovery. Flashing partial OTAs from TWRP will either fail or soft brick your device. You can return to a usable state by flashing full zips in recovery.

Enjoy :fingers-crossed:
 
Last edited:

Funk Wizard

Forum Moderator
Staff member
Nov 8, 2014
4,790
17,448
New Delhi
OnePlus 8 Pro
OnePlus 9 Pro
Making a Nandroid Backup
Warning: before you make a backup with TWRP you must remove all Lockscreen Security. If you do not do this you will not be able to unlock your device after restoring your backup (entering your pin/pattern/password will result in an "incorrect pin/pattern/password" message), you'll be forced to perform a factory reset to boot into Android.

To remove lockscreen security go to
Settings > Security > Screen Lock and set it to Swipe/None.


A Nandroid Backup is a very important thing to have before installing any custom software on your device. It's basically a backup of your stock system that you can fall back on if anything goes wrong or if you just want your stock ROM back.

You can also use Nandroid Bckup to create a backup of your favorite ROM set up exactly the way you like it. The backup you create can be easily restored using the restore tool in TWRP recovery.

To Create Nandroid Backup:

1. Boot into TWRP Recovery .
2. Go to Backup Menu and select all the listed partitions.
3. Name the Backup if needed (Optional)
4. Swipe to take Backup.
This proces should take 4 to 8 minutes depending upon the size of data.
5. Reboot System when done.

Your Nandroid will be stored in the Backup Folder inside TWRP Folder /sdcard/TWRP/BACKUPS
 
Last edited:

Funk Wizard

Forum Moderator
Staff member
Nov 8, 2014
4,790
17,448
New Delhi
OnePlus 8 Pro
OnePlus 9 Pro
Restoring a Nandroid Backup

1. Boot into TWRP Recovery
2. Go to Restore Menu and select the backup you want to restore.
3. Select the partitions you want to restore.
4. Swipe to Restore. The process will take 6 to 10 minutes.
5. Reboot system once done

Note: If you happened to forget to remove lockscreen security (PIN/Pattern/Password) before creating your backup, and you cannot get into your OS after restoring, you can do the following to fix the issue.

Boot into TWRP
Use the TWRP File Manager and Navigate to /data/sytem/ and delete the following files:

locksettings.db
locksettings.db-shm
locksettings.db-wal.
gatekeeper.password.key
gatekeeper.pattern.key


You may or may not have all the above files so delete the ones you have.

Reboot the phone and (if you've set a PIN) enter it to decrypt the storage one more time. After that you can simply unlock your phone with a swipe.

Upon Boot > Go into Settings > Security > set your preferred unlock method

Android will ask you if you want to set a boot-time code too so select as per convenience.
 
Last edited:

Funk Wizard

Forum Moderator
Staff member
Nov 8, 2014
4,790
17,448
New Delhi
OnePlus 8 Pro
OnePlus 9 Pro
Making an EFS Backup
All too often, we've seen folks who have a corrupted or missing EFS Partition. This results in your IMEI being lost and no cellular activity on the device at all. This can be a royal PITA to fix, and some folks haven't been able to fix it at all. You can take a precautionary measure to safeguard yourself against this by taking a couple of minutes to back up your modemst files.

Download & Open up Terminal Emulator on your phone from here

Once it's open you'll be greeted with a command line prompt, in which you can enter text commands, the first thing you need to do is enable root access by entering this line (press the enter key on your on-screen keyboard after each command to issue it):

Code:
su
If this is the first time you've used Terminal Emulator a Superuser or SuperSU popup will appear, make sure you grant root access.

Now enter these two commands:

Code:
dd if=/dev/block/sdf1 of=/sdcard/modemst1.bin bs=512

Code:
dd if=/dev/block/sdf2 of=/sdcard/modemst2.bin bs=512

This will place two files (modemst1.bin & modemst2.bin) on your internal storage.

Make sure you copy them to your PC and Cloud immediately so that you have a backup there to use if you need to restore it in future.

That's it !! In case you ever need to restore Nanroid or EFS Backups, please continue and follow the next post...

Restoring an EFS Backup​
If by chance you end up with a corrupt EFS partition all you need to do is flash the files back to your device using fastboot.

Boot into fastboot mode (power + volume up) and connect your phone to your PC via usb cable.

Keep modemst1.bin and modemst2.bin (backed up earlier) on your desktop and open command window there.

These fastboot commands will restore the files:

Code:
fastboot flash modemst1 modemst1.bin

Code:
fastboot flash modemst2 modemst2.bin

Reboot your device.

Code:
fastboot reboot

Now disconnect phone from PC. Your IMEI should be back.

That's it for this guide, Enjoy :highfive:
 
Last edited:

jmazzamj

Senior Member
Nov 19, 2013
117
13
Theoretically unlocking the bootloader and flashing TWRP should be identical to the OnePlus 3/3T and previous devices, i.e. just like a Nexus (R.I.P.).
 

rickysidhu_

Senior Member
Apr 1, 2016
1,894
833
Vancouver
Indeed its similar. Just making it clear for the new users here in one thread so there is no confusion.

Thank you for this! I'm going to get this device as soon as it's back in stock. It will be my first ever OnePlus device (coming from a Pixel XL). I'll still be using that but the dev support seems to be the highest with these devices.

Definitely going to use this guide to get all setup, so thanks again!

Just wondering though, I've never dealt with this dm-verity thing, what is this exactly?

Also, the day I decide to sell this phone for the next generation OnePlus (6), is it relatively simple to get back to stock and relock the bootloader?

Sorry for all the questions, just want to be thorough before doing all of this and potentially bricking my new device lol
 

Funk Wizard

Forum Moderator
Staff member
Nov 8, 2014
4,790
17,448
New Delhi
OnePlus 8 Pro
OnePlus 9 Pro
Thank you for this! I'm going to get this device as soon as it's back in stock. It will be my first ever OnePlus device (coming from a Pixel XL). I'll still be using that but the dev support seems to be the highest with these devices.

Definitely going to use this guide to get all setup, so thanks again!

Just wondering though, I've never dealt with this dm-verity thing, what is this exactly?

Also, the day I decide to sell this phone for the next generation OnePlus (6), is it relatively simple to get back to stock and relock the bootloader?

Sorry for all the questions, just want to be thorough before doing all of this and potentially bricking my new device lol

First of all Welcome to the Oneplus Community Buddy, hope your get the device soon, i am also waiting for my unit likewise :fingers-crossed:

DM Verity is just another screen warning just like the secure boot screen, which depicts an unlocked bootloader and a modified recovery, it can be taken care off easily and even if you dont it wont harm in any way just take some addition 5 to 7 seconds on boot. I am here to help so it will be taken care off.

Also its easy to get back to stock as all full zips and both TWRP and Stock Recovery Flashable so just a process of 5 minutes to be precise once you have the required downloads and once stock bootloader can also be locked again via fastboot command.

If you just follow the steps on the guide, everything will be fine. Just wait for the official TWRP source to be released, should not be long though.

Thanks again for supporting Oneplus and Welcome to the Community :highfive:
 
  • Like
Reactions: rickysidhu_

igotroot

Senior Member
Dec 4, 2010
1,253
157
Hey, many thanks for the guide.
I will be coming from an LG G6.

Question: since there is no external SD card, if we place SuperSU, DM-Verify etc on our internal memory...when we unlock the bootloader will the phone also wipe the internal sd memory??
 

Top Liked Posts

  • There are no posts matching your filters.
  • 134
    OnePlus 5: Unlock Bootloader | Flash TWRP | Root | Nandroid & EFS Backup & More !!

    qz9h9NZ.jpg



    Q9IP5VP.png



    3RVsG8v.png


    Before you start, OTA up to the latest System Update available.
    Settings > System Updates > Download & Install the latest available
    83
    2a7O1JW.jpg


    Introduction​

    Rooting this device is actually quite a simple and easy process. Before you begin, it is recommended that you at least try to understand what each part of the process will do. Although this guide will elongate each step in order to show all of the details, the method used can be broken up into 3 main steps: ​

    Unlocking the Bootloader
    Installing a Custom Recovery
    Gaining Root Access


    Each new step relies on the previous step so please follow the entire process and a basic summary of each part is described as below:

    Unlocking Bootloader​
    Opens the door to the internal memory of the device to be written on to. This allows you to flash images onto the main partitions of the phone.​

    Installing a Custom Recovery​​
    A custom recovery is flashed onto the recovery partition of the device and overwrites the stock recovery that exists by default. Custom recoveries bring lots of functionality and give you the ability to perform wipes, install flashable zips, create full backups of your device (Nandroid backup), and various other features. An unlocked bootloader is needed to install a custom recovery.

    Gaining Root Access​​
    You can gain root by either flashing via recovery a pre-rooted custom rom, or flashing a zip containing the SuperSU binaries or by Flashing Magisk Zip for a system less root. A custom recovery is necessary to do this.

    After completing these steps your phone will be rooted, the phone will have a custom recovery installed and an unlocked bootloader. This, in my opinion, is the a practical and beneficial method for rooting your phone. It will give you some basic adb/fastboot knowledge, and should hopefully help you have a decent understanding of the entire process. This method will work regardless of any android version on the phone.

    If you are confused by anything in this guide, I highly suggest getting it clarified being before moving on. Ask your question in this thread and I or someone else will likely answer. Also we would suggest that you read over the whole thread a few times before actually doing anything to the phone.​
    78
    Gaining Root Access

    This is a continued post from the above post...


    For Users who want to remain Encrypted: :fingers-crossed:

    1. Boot into TWRP Recovery and allow system modifications.
    2. Swipe right and enable modifications.
    3. Select your preferred Language, Tap “Never show this screen on boot again,” and Swipe allow modification.
    4. Navigate to Install and select Magisk Or SuperSU to root OnePlus 5.
    5. Swipe to confirm the flash
    6. Reboot System

    Keep in mind that the first boot after wiping the phone may take longer than usual, as the phone will need to rebuild the dalvik cache and initialize other first boot and would reboot a few times due to SuperSU Flash.

    For Users who want to Decrypt Data have to Format Data & Flash No Verity OP5 Zip :fingers-crossed:

    1. Boot into TWRP Recovery and allow system modifications.
    2. Swipe right and enable modifications.
    3. Select your preferred Language, Tap “Never show this screen on boot again,” and Swipe allow modification.

    Go to “Wipe” section and tap “Format Data”, and type “yes” to mount internal storage

    4. Download & Transfer no_verity_op5.zip to the device over MTP from here Credits @snowwolf725
    5. Go to “Install” section, select no_verity_op5.zip, and swipe to confirm the flash
    6. Transfer latest Magisk/SuperSU to the device over MTP to your Oneplus 5 & Swipe to confirm the flash
    7. Reboot System

    * MTP, known as Media Transfer Protocol, is the same way you transfer files from your PC to your device when booted into system.

    Congrats! That is all! Your Device now has an unlocked bootloader, a custom recovery installed and is rooted along with your preference of staying encrypted or decrypted.

    Warning: Do not flash partial update OTAs (under 1 GB) on a modified device! If you want to use partial OTAs, you must first flash a full OTA that it applies to, and then flash the partial OTA from stock recovery. Flashing partial OTAs from TWRP will either fail or soft brick your device. You can return to a usable state by flashing full zips in recovery.

    Enjoy :fingers-crossed:
    69
    Setup, Preparation & Prerequisites​​
    Basic tasks that may be referred to throughout this guide:​
    Open Command Prompt: Press Shift + Right Click anywhere on the screen and select Open Command Window here

    Enter Fastboot/Bootloader Mode: Turn the phone off. Hold volume up + power until the "fastboot" screen appears. [Alternatively, if Advanced Reboot is enabled, you can press Reboot > Bootloader from the power menu.]

    Enter Recovery Mode: Turn the phone off. Hold volume down + power until the "OnePlus Logo" screen appears. [Alternatively, if Advanced Reboot is enabled, you can press Reboot -> Recovery from the power menu.]

    ADB and Fastboot Installation​
    1. Download the ADB For Windows from here Credits @Snoop05 his Original XDA Thread Here

    Or You can manually update Fastboot and ADB binaries here Credits @lj50036 his Original XDA Thread Here

    2. Run the .exe file downloaded from above as Administrator.
    3. Press 'Y' every time the installer asks for.
    4. Continue Driver Installation.

    Now, ADB and Fastboot have been installed on your PC and should be Working as desired.

    Things To Remember​
    Show File Extensions :good:
    Open a command prompt window and run "Control folders" (without the quotes). Go to the View tab and uncheck the "Hide extensions for known file types" option. This will help avoid confusion when renaming files.

    Battery :good:
    Ensure that your phone has at least 60% battery remaining, and that your PC is plugged in and wont shut down spontaneously during the process. The procedure doesn't take very long , but its best to have enough charge in case something goes wrong.

    Backup (Optional) :good:
    Unlocking the bootloader will/should completely wipe all data from the device. This includes apps, settings and even the contents of the internal sdcard (pictures, music, etc.). Copy all important files off the phone onto a PC or upload them to a cloud.

    USB Debugging :good:
    On your phone go to Settings > About phone > Tap on Build number 7 times. This will enable Developer options. Now go back to Settings > Developer options > Enable USB debugging

    Enable OEM Unlocking :good:
    On your phone go to Settings > Developer options. Then enable the 'OEM Unlocking' option. Also make sure that from now on, OEM unlocking option is enabled before you reboot as sometimes, it might get disabled itself.

    Enable Advanced Reboot :good:
    On your phone go to Settings > Developer options. Then enable the 'Advanced Reboot' option.
    69
    Unlocking Bootloader


    Turn the phone off. Then boot it into fastboot mode by holding volume up + power or select reboot to bootloader if advanced reboot is activated via developer options. The phone will display "fastboot" text indicating that it has successfully entered fastboot mode.

    Plug the phone into your PC, then open a command prompt window on the desktop (Shift + Right Click -> Open Command Window here) and type:

    Code:
    fastboot devices

    This command will list the connected devices. If your phones serial number shows up you are good to go and may continue. If the phone is NOT listed this indicates that your drivers are not installed correctly. In order for you to continue you must fix your drivers so that your phone is listed under fastboot devices.

    If the phone has been recognized by the command above, proceed to unlocking the bootloader with the following command:

    Remember this Step will WIPE EVERYTHING off the phone so Backup all your Data

    Code:
    fastboot oem unlock

    x6hqaHU.jpg


    You would be greeted with a Unlock Bootloader Warning page, Hit the Vol button to select Yes and turn it Blue and Hit the Power Button to Execute the selection

    R9phbUg.jpg


    Your device will reboot, show you a Secure boot warning, reboot into stock recovery and wipe all data. Once done, your phone will reboot into the OS.

    Please continue and follow the next post to install Custom Recovery