I unlocked the bootloader in my OnePlus 5 right after it was delivered, so there was nothing to erase. Then I flashed TWRP and SuperSU. It comes with DM-Verity (and /data force encrypted). I tried re-locking, but later I have to erase all data again before unlocking bootloader. So the questions are:

  • Why is it required to erase all data when unlocking bootloader? Even with device encryption on?
  • Can I avoid the erase?
  • And you second question, no you can't avoid it... that would defeat the whole purpose of why it is.
    – acejavelin
    Nov 27 '17 at 3:17
  • @acejavelin I edited my question
    – iBug
    Nov 27 '17 at 3:18
  • The answer linked doesn't change and still applies... If you unlock the bootloader, the first or hundredth time, regardless of encryption, it will wipe the device.
    – acejavelin
    Nov 27 '17 at 3:28
  • @Izzy Never heard of device-dependent cases! You broadened my horizons.
    – iBug
    Nov 27 '17 at 8:09
  • To clarify that last comment (on an exchange in chat): One usually cannot avoid the erase. But I know of one single exception: For the LG P880, some XDA dev wrote an app to unlock the bootloader. This was a very specific case, permitting the user to unlock/relock up to 8 times while the normal procedure wouldn't allow that: the P880 uses "fuses" for this. Once burned, they're gone.
    – Izzy
    Nov 27 '17 at 19:13