Skip to content

Instantly share code, notes, and snippets.

@aldur
Created November 14, 2017 19:44
Show Gist options
  • Save aldur/b785257ac26d23bce648cad3ce2f6dc8 to your computer and use it in GitHub Desktop.
Save aldur/b785257ac26d23bce648cad3ce2f6dc8 to your computer and use it in GitHub Desktop.
OnePlusRoot

Root OnePlus5 without unlocking the bootloader

Gain adb root.

$ adb shell am start -n com.android.engineeringmode/.qualcomm.DiagEnabled --es "code" "angela"

Download Magisk-v14.0 and extract it somewhere. Download MagiskManager.

Now, open a shell (adb shell).

OnePlus5:/ # mkdir /data/magisk
OnePlus5:/ #

Push the required file to the device:

adb push {arm64/*,common/*} /data/magisk/
arm64/magisk: 1 file pushed. 6.7 MB/s (192736 bytes in 0.027s)
arm64/magiskboot: 1 file pushed. 20.2 MB/s (316536 bytes in 0.015s)
common/boot_patch.sh: 1 file pushed. 3.1 MB/s (7732 bytes in 0.002s)
common/init.magisk.rc: 1 file pushed. 0.3 MB/s (675 bytes in 0.003s)
common/magisk.apk: 1 file pushed. 21.6 MB/s (3311368 bytes in 0.147s)
common/util_functions.sh: 1 file pushed. 2.5 MB/s (6688 bytes in 0.003s)
6 files pushed. 17.9 MB/s (3835735 bytes in 0.205s)

Download busybox for arm. Extract it and push it to the device:

adb push busybox-armv6l/system/xbin/busybox /data/magisk/

Install MagiskManager:

adb install ../MagiskManager-v5.4.0.apk

Back on the ADB shell (adb shell):

OnePlus5:/ # cd /data/magisk/
OnePlus5:/data/magisk # ls
boot_patch.sh busybox init.magisk.rc magisk magisk.apk magiskboot util_functions.sh
OnePlus5:/data/magisk # ./magisk --createimg magisk.img 64
Creating filesystem with parameters:
    Size: 67108864
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 4096
    Inode size: 256
    Journal blocks: 1024
    Label:
    Blocks: 16384
    Block groups: 1
    Reserved block group size: 7
Created filesystem with 11/4096 inodes and 1294/16384 blocks
OnePlus5:/data/magisk # mv magisk.img ..
OnePlus5:/data/magisk # ./magisk --createimg xbin.img 64
Creating filesystem with parameters:
    Size: 67108864
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 4096
    Inode size: 256
    Journal blocks: 1024
    Label:
    Blocks: 16384
    Block groups: 1
    Reserved block group size: 7
Created filesystem with 11/4096 inodes and 1294/16384 blocks
OnePlus5:/data/magisk # ./magisk --mountimg xbin.img xbin
/dev/block/loop0
OnePlus5:/data/magisk # cp /system/xbin/* xbin/
OnePlus5:/data/magisk # cp magisk xbin
OnePlus5:/data/magisk # umount xbin
OnePlus5:/data/magisk # rmdir xbin
OnePlus5:/data/magisk # ./magisk --mountimg xbin.img /system/xbin
/dev/block/loop0
OnePlus5:/data/magisk # magisk --post-fs
OnePlus5:/data/magisk # magisk --post-fs-data
OnePlus5:/data/magisk # magisk  --service

That's it, your phone is now rooted and Magisk modules should work too. After a reboot you'll need to repeat the last steps:

$ adb shell
OnePlus5:/ # cd /data/magisk/
OnePlus5:/data/magisk # ./magisk --mountimg xbin.img /system/xbin
/dev/block/loop0
OnePlus5:/data/magisk # magisk --post-fs
OnePlus5:/data/magisk # magisk --post-fs-data
OnePlus5:/data/magisk # magisk  --service
@gbesh
Copy link

gbesh commented Feb 10, 2018

is there anyway to unroot after using this method?

@dalfaand
Copy link

Does this method still work? I have my OPO with the stock rom and updated. I don't see EngineerMode app so I guess it doesn't work.
Should I install an outdated rom for this to work? One that still has EnginnerMode apk?

@lukavia
Copy link

lukavia commented Sep 16, 2019

@doegox nope not yet

guys for latest open beta on oneplus 3t you should run this command
adb shell am start -n com.oneplus.factorymode/.qualcomm.DiagEnabled --es "code" "angela"

In seams that with the stable release that is not working anymore. Either they have removed it, or changed the password :(

@JulesLassara
Copy link

Hello, do you think this is working on other OnePlus devices ? Like OnePlus 7 pro ? Open beta does matter ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment