How to Unlock/Relock Nexus 6P or Nexus 5X Bootloader

Your new Nexus device (Nexus 6P or Nexus 5X) comes from the factory with a locked bootloader. While unlocking it is trivial, it’s important to remember that an unlocked bootloader is very unsecure, and makes your personal data more vulnerable to threats.

Sometimes we feel the need to mod our phone to spice things up. So if you’re with us in this Nexus bootloader unlocking process then here’s how to do it.

Prerequisites to unlock your Nexus device’s bootloader

You’ll need a working installation of fastboot on your computer.

Install the Android SDK and the official Google USB drivers.

You’ll need a suitable data cable.

Developers options enabled.

USB debugging enabled.

OEM unlocking option checked.

Process to unlock bootloader of your Nexus device:

Firstly, you need to give permission for the bootloader to be unlocked. To make things easy, enable USB debugging on your phone. Go to Settings >> About phone and find the entry labeled build number. Tap it five times, read the pop up telling you that you’re a developer now, then go back to the main settings page. Near the bottom, you’ll see a new entry labeled Developer options. Tap it to get in there, and toggle the switch to allow OEM unlocking, then enable USB debugging.

Now connect your device to the computer, and fire up the command line on your Windows computer or a terminal program on your Mac or Linux computer. Make sure your phone is unlocked and the screen is on because you’ll be asked to authorize the computer and give it permissions to communicate with your Nexus device over a wire. Once that’s done and sorted, it’s time to do some command typing.

On your computer, at the command prompt type:

adb devices

If everything goes right, you’ll see your phone’s serial number in your command line window. If you do this on a Mac or Linux computer, remember your dot and slash: “./adb devices” for example.

Once you have things sorted, it’s time to reboot to the bootloader:

adb reboot-bootloader

When you get to this stage, you will need to use fastboot to communicate instead of adb. If you’re working out of the folder where the fastboot command is located, remember that dot and slash if you’re using a Mac or Linux computer. Try this command to see if everything is working:

fastboot devices

See the serial number like we did with the adb command? If so, you’re good to go. If not, you need to troubleshoot. If you’re using Windows and having issues, chances are it’s the driver.

Up until now, things are the same here as they have always been with Nexus phones. But the command to actually unlock the bootloader has changed. When you’re ready, at your command line, type:

fastboot flashing unlock

Remember, this will erase everything on your phone and restore it to the way it came out of the box.

You’ll need to confirm this action on your phone’s screen, using the volume and power keys. Follow the instructions on your screen.

Let it do its thing, and when it’s done send one more command to make things final:

fastboot reboot

After recovery erases everything and you’ve booted back to Android (at the device setup screen) you can unplug your cable and use your phone normally.

Process to relock bootloader of your Nexus device:

If you ever decide to relock your bootloader, you can do so with this command:

fastboot flashing lock

Remember, if you need to unlock your bootloader again, things will get erased again.