Skip to content

Instantly share code, notes, and snippets.

@ergoithz
Last active August 30, 2021 20:35
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ergoithz/29d18bc41a45f1c61bc708deffd479d2 to your computer and use it in GitHub Desktop.
Save ergoithz/29d18bc41a45f1c61bc708deffd479d2 to your computer and use it in GitHub Desktop.
LG G5 MAGISK-ROOT HOWTO

LG G5 (H850) TWRP & MAGISK (ROOT)

This tutorial shows the entire process of oficially unlocking, TWRP recovery flashing, and Magisk rooting your european LG G5.

Important

  • Unlocking bootloader wipes all your phone data, backup first.
  • Do not flash no-verity-opt-encrypt.zip, it causes random issues and it's not needed unless you want a writable system partition, and you probably don't (it prevent stock roms from being updated).
  • DO NOT WIPE data partition: As long user-data partition is encrypted with a key stored there, it will be no longer available.
  • If you have working root support, remove it (binary and application) before installing Magisk.
  • Root APPs with Magisk-related issues:
    • All non-magisk root managers.
    • Xposed (it has an unofficial magisk-compatible version at its own post on xda-developers forums).
    • AFWall+ (use a root-less alternative like NetGuard or Opera Max).

Installing Android-SDK

  1. Install Android-SDK, open AVD Manager and make sure you have the last platform-tools version installed.
  2. Head to your Android-SDK installation directory, head to platform-tools directory, adb and fastboot commands are there.

Enabling Developer options

  1. On your phone, head to Settings > About phone > Software info.
  2. Tap 7 times on Build number.
  3. Head to Settings > Developer options.
  4. Enable USB debugging.
  5. Activate Enable OEM unlock.

Getting IMEI

IMEI (International Mobile Station Equipment Identity) is an unique ID given to every cell-phone-related device.

You have two options:

  • On your phone dialer, enter *#06#.
  • Request it from your carrier, as the IMEI is sent to them everytime you connect to a cell network, useful if your phone is bricked.

Getting Device ID

  1. Go to device bootloader (fastboot), you have two options:
  • Using adb command adb reboot bootloader (see Installing Android-SDK).
  • Turn off phone, unplug USB, wait 10 seconds, hold Volume key up while plugin USB.
  1. Use fastboot command fastboot oem device-id, some lines will be shown.
  2. Copy lines showing an hexadecimal code (alphanumerical characters ranging from 0 to 9 and A to F), remove console prompts, whitespace, linebreaks in order to get a code like CD58B679A38D6B613ED518F37A05E013F93190BD558261DBBC5584E8EF8789B1.
  3. Optional: You can use fastboot command fastboot reboot to reboot your device.

Unlocking bootloader

IMPORTANT: this procedure will WIPE ALL YOUR PHONE DATA, EVERYTHING (files, configuration, apps...). BACKUP your data first elsewhere.

LG provides an official method to unlock european G5/H850 fastboot bootloaders for developers (they also allow to unlock european G4/H815 and V10/H960A devices).

  1. Register at developer.lge.com.
  2. Head to http://developer.lge.com/resource/mobile/IssueDeviceInfo.dev (their full instructions are at http://developer.lge.com/resource/mobile/RetrieveBootloader.dev).
  3. Complete all data (including IME and Device ID), accept terms, and continue.
  4. Head to your email inbox, you should receive an email containing the bootloader unlock key.
  5. One email arrives, download the unlock.bin attachment file.
  6. Boot to device's bootloader (see Getting Device ID section).
  7. Use fastboot command (see Installing Android-SDK section) fastboot flash unlock unlock.bin, making sure unlock.bin refers to downloaded unlock.bin path.
  8. Your phone will be wiped and a warning message will be shown on every boot from now on.
  9. Optional: You can use fastboot command fastboot reboot to reboot your device.

Installing TWRP

TWRP is one of the best recoveries out there.

  1. Download TWRP from here https://twrp.me/devices/lgg5h850.html (you will end with a .img file)
  2. Boot to device's bootloader (see Getting Device ID section).
  3. Use fastboot command (see Installing Android-SDK section) fastboot flash recovery recovery.img, making sure recovery.img refers to downloaded TWRP .img path.
  4. Optional: You can use fastboot command fasboot reboot to reboot your device.

Installing Magisk

Magisk provides root with fast root-unroot switching for root-incompatible apps like Pokemon Go or Android Pay, automatically thanks to AutoMagisk.

  1. Download Magisk and phh-superuser flashable zip files from the official Magisk post at xda-developers forum.
  2. Boot to TWRP:
    1. Shut down phone, unplug, wait 10 seconds.
    2. Hold volume down.
    3. Hold power until LG logo show up, quickly release and hold again.
  3. Ignore TWRP encryption-related messages (it's not working for this device yet), and DO NOT enable system partition write support (it causes random problems with stock rom).
  4. Head to advanced options and enable sideload.
  5. Use adb command (see Installing Android-SDK section) adb sideload magisk.zip, making sure magisk.zip refers to downloaded Magisk zip path.
  6. Head to advanced options and enable sideload again.
  7. Use adb command (see Installing Android-SDK section) adb sideload phh-superuser.zip, making sure phh-superuser.zip refers to downloaded phh-superuser zip path.
  8. Head to reboot and choose System.
  9. You phone should boot normally.
  10. Enable Unknown sources in Settings > Security.
  11. Install Magisk Manager apk, phh-superuser apk, both also available at the official Magisk post at xda-developers forum (phh-superuser apk is also available on Google Play).
  12. Install AutoMagisk apk, optional but highly recommended as it disables root automatically while using conflictive apps, from the official AutoMagisk post at xda-developers forum.

Troubleshoot

  • If TWRP does not survive across reboots, you can use Flashify (available at Google Play) to flash and boot-to-recovery only when needed.
  • If some app suffers force-closing, try ONE of this (from easier to harder):
    • Go to Settings > Applications (use the menu to show it if it's a system one) and wipe its data and cache.
    • Wipe cache from TWRP, but DO NOT WIPE DATA (see Important section above).
    • Flash a clean stock ROM, and do everything above, again, as some issues may arise with previously modded system partitions.
@ShamSung
Copy link

PLEASE HELP!! -

C:\Users$h4mDr!v3\Desktop\4nDr01d\adbfastboot>adb reboot bootloader

C:\Users$h4mDr!v3\Desktop\4nDr01d\adbfastboot>fastboot flash recovery recovery.img
sending 'recovery' (19076 KB)...
OKAY [ 0.576s]
writing 'recovery'...
FAILED (remote: unknown command)
finished. total time: 0.596s

C:\Users$h4mDr!v3\Desktop\4nDr01d\adbfastboot>

  • HOW IS IT FAILING?? yes, my bootloader is unlocked and on nougat 7.0 update 20a

@odyright
Copy link

Is it available for LG-H860?

@Liyanado
Copy link

Liyanado commented Jun 6, 2018

Download Magisk Root - https://www.magiskroots.com/

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