[Nexus 6  General] GuestK0087:
This guide is for the safe procedure for re-locking your bootloader with the new security features of Android 5.1 on the Nexus 6

The purpose of re-locking your bootloader should solely be used for RMA or resale of your device. Also if you have flashed a factory image and want the added security of a locked bootloader. Or possibly it is required by your employer. If you're required by your employer, then I suggest you reconsider unlocking in the first place. If you're returning to stock, to simply fix problems on your device, then I also strongly suggest leaving the bootloader unlocked. To put it in simple terms, if you want to keep a custom recovery and ROM, mod, root, etc, then leave your bootloader unlocked. Re-locking the bootloader on the Nexus 6 will cause your device to be wiped.

Please read this post by [MENTION=1566190]efrant[/MENTION] for more clarification:

http://xdaforums.com/showthread.php?p=60128929

Thanks [MENTION=1566190]efrant[/MENTION] [MENTION=3209971]cam30era[/MENTION] [MENTION=2872010]rootSU[/MENTION] [MENTION=6235459]clairez[/MENTION] for collaboration and advice.

This is based on a 100% stock, encrypted, un-modded Nexus 6

Due to significant security changes in Android 5.1, there are some specific steps that must be taken in order to safely re-lock your bootloader during and after installing a factory image.

WARNING! These steps are confirmed working but there is still risk involved. If you do not ABSOLUTELY need to re-lock then I strongly suggest leaving the bootloader unlocked.

FOLLOWING THESE STEPS WILL WIPE YOUR DEVICE SO BACKUP YOUR DATA!

This is based on you (the user) having already read and followed instructions on downloading the factory image and having it ready to install.

STEP 1

Disable all security locks on your phone.

On your phone, go into your settings, click Security. In Screen security, click on Screen lock, enter your passcode/pin/pattern then select none.

You will get a prompt that Device protection features will no longer work. Click OK.

STEP 2

**OPTIONAL**

Thanks [MENTION=2743227]gee2012[/MENTION]

This step is optional because successful installation of the factory image will remove this info anyway.

Remove your Google account.

In settings, click Accounts, click Google then click on your account name. (your gmail address)

Click the 3 dot menu button in top right of screen and select Remove account. You will get a prompt That this will delete all messages, contacts and other data from your phone. Click REMOVE ACCOUNT.

STEP 3

This step is optional and may or may not be needed but I recommend doing this.

Preform a factory reset from your phone settings.

Open settings and click on Backup & reset. Click Factory data reset.

You will receive a prompt stating that this will erase all data from your phone's internal storage, click RESET PHONE.

The reset takes quite a while to complete, approximately 10 to 15 or more minutes for a 32gb model and 20 minutes or more for a 64gb model, so BE PATIENT!

Your phone will reboot when completed.

STEP 4

IMPORTANT!!

When your phone reboots, you will have to skip all account set up and ABSOLUTELY do not set any security features up. Skip EVERYTHING!

Go to settings and enable Developer options. (About phone>tap build number 7 times)

Once you have developer options enabled, enable USB Debugging and tick the box to allow OEM unlock.

I suggest preforming a reboot here to verify that OEM unlock sticks. After the reboot enter developer options to verify OEM unlock is still ticked.

If it is, we will proceed. If not, ensure you have followed the previous steps correctly. If you have and for some reason the setting won't stick, DO NOT PROCEED OR YOU MAY END UP STUCK IN A BOOT LOOP WITH NO CURRENT WAY TO FIX!

STEP 5

If setting has stuck, you are ready to unlock your bootloader and install the factory image using one of the ways outlined elsewhere in this forum.

After installation is complete, reboot to recovery and again preform a factory reset. Reboot to Android.

STEP 6

IMPORTANT!

Upon completion of factory reset from recovery and reboot to Android, it is important to follow this procedure so you may now safely lock your bootloader.

SKIP ALL ACCOUNT AND SECURITY SET UP AGAIN! Go to settings and enable developer options again. Enable USB debugging and tick allow OEM unlock.

Again, I recommend a reboot at this point to verify the settings stick.

Use the button combo or ADB to reboot to bootloader.

Use the command fastboot oem lock

Your device will wipe again and reboot.

CONGRATULATIONS! You now have a locked bootloader and you may proceed to restore your phone.

See here for info from Google about the new security features:

https://support.google.com/nexus/answer/6172890?hl=en

Thanks [MENTION=1566190]efrant[/MENTION] for finding this link.

Thanks also to all of those who helped to confirm this process works consistently.

Thanks to [MENTION=6235459]clairez[/MENTION] for this thread: http://xdaforums.com/nexus-6/help/update-to-5-1-lock-bootloader-t3058480

*Disclamer*

I am not responsible if your device bricks, loops or causes mass world hysteria.