[Upgrading, Modifying and Unlocking] C4lculated:
Hello everyone, after struggling for a few hours I managed to finally disable force encryption in my phone (so that TWRP could backup the data partition).

I'd like to write a quick list of what I did in the form of a guide to unlocking the bootloader, installing TWRP and getting root with Magisk. I'm just a user, not a developer and this guide is brief, it's not a detailed tutorial and does not include trivial steps (like how to install drivers for your OS).

Warnings: Although small, there is always the chance this bricks your phone. I take no responsibilities.

This will factory reset your phone so back up everything before you start.

My phone is Lenovo S5 (K520) Global version (see screenshot) I don't know if this will work for other firmwares.

Prerequisites:

Install Phone, ADB and Fastboot drives. You can get ADB and Fastboot binaries from here:

https://xdaforums.com/showthread.php?t=2588979

Download this archive:

http://www.mediafire.com/?4dcvzw1hdmzfn10

It contains all the files used in this guide.

Alternatively, download all the files used from their sources.

You will need an SD card or a USB flash drive with an OTG adapter.

Copy the following files to it:

A. "Disable_Dm-Verity_ForceEncrypt_12.16.2018.zip"

(Downloaded from http://xdaforums.com/showthread.php?t=3817389 )

B. "Magisk-v18.0.zip"

(Downloaded from http://xdaforums.com/showthread.php?t=3473445 )

C. (optional) "\stock\boot.img"

(Downloaded from the global firmware @ 4pda)

If you chose to use Micro SD card, you can insert it now.

Note: I know there is a way to push these files directly to TWRP from PC through USB instead of using SD Card/Flash drive but I've never tried it.

Lets start:

1. Go to 'Settings>About phone' and tap on "Lenovo version" several times until developer options are enabled.

2. Go to 'Settings>System>Developer options' and enable "OEM unlocking" (Note: for me this option was greyed out and I had to connect to wifi and wait for a minute or two).

Optional: Enable "USB debugging" if you wish to enter fastboot via ADB.

3. Turn off the phone and press and hold 'Volume down'+'Power' buttons until you see "fastboot mode" on the phone screen (alternatively, don't turn off the phone and instead enter fastboot mode via ADB (adb.exe reboot bootloader)).

4. Connect the phone to the PC via USB and open a command prompt in the location that you installed fastboot binary to.

Type (after each command press enter):

fastboot devices

To verify that the phone is recognized. And if it is type:

fastboot oem unlock

Now on the phone LCD navigate to "Yes" with volume buttons and press power to select it.

Your phone will factory reset, this will take a few minutes. Let it finish.

5. Put the TWRP image in your fastboot path. I used "recovery-twrp-3.2.3-crn-seoul(v3.2.3-1).img" downloaded from this URL:

https://xdaforums.com/android/development/lenovo-s5-k520-twrps-t3863860

But I included 2 more files that I found (I did not try them).

6. Enter fasboot mode again and type:

fastboot flash recovery recovery-twrp-3.2.3-crn-seoul(v3.2.3-1).img

(Substitute "recovery-twrp-3.2.3-crn-seoul(v3.2.3-1).img" with the recovery filename of you choice)

7. If successful, disconnect the USB cable and enter Recovery mode, do not turn off or reboot the phone because upon restart the phone will revert to stock recovery (I.E. delete TWRP).

To enter Recovery mode press and hold 'Volume down'+'Power' buttons until you see "fastboot mode" and from there choose "Recovery mode" with the volume buttons and confirm with the power button.

(Alternatively, you can try holding 'Volume up'+'Power' to directly enter Recovery mode but I found it a little finicky)

8. In TWRP, swipe to allow changes. Press cancel when asked for a password to decrypt data.

If you chose to use a USB flash drive with an OTG adapter, connect it and mount it (Mount>usb-otg).

9. Go to Wipe>format data, type "yes" and confirm (if you have any data like installed apps, contacts etc., it will be deleted).

10. Go to Install and install "Disable_Dm-Verity_ForceEncrypt_12.16.2018.zip".

The files will be in (/external_sd/ or /usb-otg/).

11. Install "Magisk-v18.0.zip"

Important note: If you want to keep encryption (if you don't care if TWRP can't access /data/) and just obtain root, skip steps 9 and 10.

12. Reboot to system and wait for a few minutes for the initial setup.

If for some reason boot fails (nothing happens after 10 minutes) and you can still enter TWRP (hold 'Volume up'+'Power'), then you can revert the changes by restoring the stock boot image (TWRP>Install>Install image>boot.img - put a checkmark on "boot").

If this worked for you, please tell us by replying to this thread.