In this tutorial, I will guide you on how to unlock the bootloader, install TWRP recovery, disable forced-encryption (optionally), and simultaneously root the Huawei Nexus 5X (codename: bulkhead) using Magisk.

Released in 2015, the Nexus 5X and Nexus 6P were the last devices from Google’s infamous Nexus lineup. Apart from offering powerful hardware at a suitable price point, Nexus devices are pretty well known for their flexibility when it comes to software modification, primarily because the bootloader is easily unlockable. The phone also received official support for TWRP soon after its launch. This means you can also easily root it.

Both TWRP and Root are two tools that can open the gateway to tons of possibilities when it comes to software modding. You can install custom ROMs, kernels, mods like ViPER4Android, use root applications, and do much more.

The process of rooting the Nexus 5X is extremely plain and simple. The first step is to unlock the bootloader, which will allow you to flash the phone’s partitions. This is followed by the second step which is to install TWRP (a custom recovery). Then the third step is optional, where you can decrypt the phone’s /data partition and disable forced-encryption. And finally, the fourth step is to flash the Magisk ZIP file through TWRP to root your Nexus 5X.

The instructions below will take you through each of these steps in detail. So with any further ado now, let’s begin.

Also Recommended: A Possible Fix for Nexus 5X’s Bootloop Issue

How to Unlock Bootloader, Install TWRP Recovery, and Root LG Nexus 5X

Table of Contents


  • All the data on your phone will be erased during this process, including the installed apps, contacts, messages, as well as, everything on the internal storage. So, make sure that you take a complete backup before you proceed. You can take a look at our detailed guide here on how to backup.
  • Charge your Nexus 5X to at least 60% battery to avoid any kind of interruptions during the process.
  • Download the latest Google USB drivers from here and install them on your Windows PC. If you’re working on a macOS/Linux PC, you will not need any drivers.
  • Download the latest platform-tools (ADB and fastboot) package and install it on your PC using the instructions here.
  • When asked to launch the command-line on your PC, do the following:
    • On Windows: Go to the folder on your PC where the Android platform-tools are installed (e.g. C:\platform-tools). Then hold the SHIFT key on the keyboard and right-click on any empty space inside that folder. Finally, select ‘Open PowerShell window here’.
    • On macOS/Linux: Launch the ‘Terminal’ and change its directory using the ‘cd’ command to the folder where the platform-tools are installed. For instance, if the tools are installed in Documents/platform-tools’, then the command should be:
      cd Documents/platform-tools


A few notes

  • The official TWRP recovery is only to be used if you’re going to use the rooted stock environment.
  • The 4-Core TWRP supports FBE (File-based Encryption) and is to be used on devices affected with the infamous Bootloop-of-Death (BLOD) issue.

Unlock the Bootloader

In order to perform any sort of modification (like installing TWRP or rooting in this case), you must first unlock the bootloader on your LG Nexus 5X. To do this, follow the steps that follow.

Step 1: First, go to ‘Settings’ > ‘System’ > ‘About phone’ on your phone. Then scroll down and find the ‘Build number’ section. Tap continuously on it for five (5) times until you see the ‘You’re now a developer!’ message. You have just enabled the hidden Developer options on your phone.

Enable Hidden Developer Options on LG Nexus 5X


Step 2: Now, go to ‘Settings’ > ‘System’ > ‘Developer options’ and turn on the ‘OEM unlocking’ toggle. Select ‘ENABLE’ when prompted to finally enable OEM unlocking on your Nexus 5X.

Enable OEM Unlocking on LG Nexus 5X


Step 3: With OEM unlocking enabled, you can now unlock the bootloader via fastboot. To do this, power off your phone completely. Then boot it into Bootloader Mode by holding the Volume Down and Power buttons together. Once your Nexus 5X is in Bootloader Mode, connect it to the PC via a USB cable.

LG Nexus 5X Bootloader Mode


Step 4: Now launch the command-line window on your PC and execute the following command to ensure that your PC can recognize your phone over fastboot:

fastboot devices

The command should return your device’s unique ID. If it doesn’t, then make sure that you have installed the proper USB drivers on your PC (Check the ‘Prerequisites’ section’ above).

Step 5: Now enter the following fastboot command to finally unlock the bootloader on your Nexus 5X.

fastboot flashing unlock

Enter 'fastboot flashing unlock' command to Unlock LG Nexus 5X Bootloader


As soon as you enter the command, you will be prompted by a confirmation message on your phone’s screen. Use the Volume keys of your phone to move the selector to ‘YES’ and then press the power button to confirm the selection.

LG Nexus 5X Bootloader Unlock Prompt


Your phone’s bootloader should be unlocked now. From now onwards, you should see the bootloader unlocked warning message on the screen whenever you reboot the phone. Do not worry, this is completely normal and you can safely ignore it.

LG Nexus 5X Unlocked Bootloader Warning Message

Install TWRP Recovery

Now that the bootloader is unlocked, you can flash the partitions and install TWRP recovery on your Nexus 5X.

Step 1: First, download the TWRP recovery image for the Nexus 5X from the ‘Downloads’ section. Copy the download .img file to the folder where the Android platform-tools are installed (e.g. ‘C:\platform-tools’ on Windows or ‘Documents/platform-tools’ on macOS/Linux).

Step 2: Connect your phone to the PC while it is in Bootloader Mode.

Step 3: Now launch the command-line window on your PC and enter the following command to verify the device-PC connection over fastboot:

fastboot devices

Step 4: Now, flash the TWRP recovery image to your Nexus 5X by entering the command mention below.

fastboot flash recovery twrp-3.4.0-0-bullhead.img

Remember, if you’re using the unofficial build of TWRP or the one patched for 4-cores, then please replace “twrp-3.4.0-0-bullhead.img” with the actual filename of the recovery you’re using.

Step 5: TWRP has now been installed on your phone. For carrying on the rooting procedure, you will need to boot your Nexus 5X straight into the TWRP recovery mode. To do this, simply tap either of the Volume buttons until ‘Recovery Mode’ shows up on the Fastboot screen. Then press the power button to confirm.

When your phone boots into TWRP for the first time, it should prompt you with the ‘Unmodified System Partition’ screen prompting you whether to allow modifications or keep the /system partition read-only.

Nexus 5X Unmodified System Partition Prompt in TWRP


Decrypt Data Partition

Earlier, TWRP didn’t support proper decryption of the /data partition, which means that it couldn’t mount the internal storage. This was a problem only with older builds of TWRP. But since you’ve installed and are using TWRP v3.4, this shouldn’t be a problem. However, if you plan on flashing custom ROMs, you might want to consider decrypting your phone’s data partition.

Format Data Partition in TWRP on LG Nexus 5X

The process to do so is actually quite simple. Just go to the ‘Wipe‘ menu in TWRP and press ‘Format Data‘. Input ‘yes‘ in the provided field and press the enter button of the keyboard. The recovery will completely format the data partition and decrypt it.

Once the formatting finishes, go to ‘Reboot’ and press the ‘Recovery’ button. This will reboot your phone back into TWRP.

Root Huawei Nexus 5X using Magisk

Till now, you have unlocked the bootloader, install TWRP custom recovery, and decrypted the data partition on your phone. Well now, you’re now at the part that requires the least amount of effort. Follow the instructions listed below to finally flash the Magisk root package and root your Nexus 5X.

  1. First, download the Magisk flashable ZIP file on your PC. Although you can still use SuperSU, I would personally recommend using Magisk, since it is more efficient, works on the latest Android version, and is still under active development.
  2. Once you have downloaded the zip package, connect your Nexus 5X to the PC while it is in TWRP recovery. Your PC should recognize your phone instantly and mount its internal storage. If it doesn’t do that automatically, go to the ‘Mount’ menu in TWRP and verify that MTP is enabled.
  3. Now transfer the downloaded root zip package (let’s say to your phone’s internal storage. Once transferred, disconnect the phone from the PC.
  4. Then go to the TWRP main screen and press the ‘Install’ button. Navigate to your phone’s internal storage and select the root package (e.g. Finally, swipe the button on the screen to flash the file and root your Nexus 5X.
    Flash Magisk through TWRP Recovery to Root LG Nexus 5X

When the flashing process finishes, hit the ‘Reboot System’ button to boot your phone into the system (OS).

Your phone should now be rooted. To verify, go to the app drawer and launch the Magisk Manager application. With TWRP installed on your phone, you can flash custom ROMs, kernels, and mods. You can also use it to take NANDroid backups of the complete OS, which can really be helpful especially when switching ROMs.

If you’re new to the scene and looking for custom ROMs, then please visit the Nexus 5X section at XDA forums.

That’s it! If you have any questions regarding the instructions mentioned here or feel stuck at any point, feel free to let me know.

Post a Comment

Comment Policy: We welcome relevant and respectable comments. Only input your real first name and valid email address if you want your comment to appear. Read our comment policy fully before posting a comment.