[Lenovo P2 ROMs, Kernels, Recoveries, & Other Devel] Kielbek:
WARNING: I am not responsible if you brick your device or lose any data. I personally heavely tested these releases myself and have not encountered any problems.

These are built on official sources and nothing more should be broken but remember to always make backups before installing any mods, kernels etc.!

You should read everything I wrote in this thread before taking any steps unless you know exactly what are doing.

About:

Okay, so I was tired of almost not usable Magisk on official builds because of outdated Moto F2FS implementation, so I built new LOS15.1 kernel and Treble-compatible TWRP with newer version of it for myself and I want to share this with you.

You may ask why I did it and what does it change, so here's the list of features:

This combo may be solution for smooth transition from 15.1 --> 16 without losing data (Without this you will need to reformat your /data partition before flashing when the day of 16 comes - confirmed by Mike). I cannot say 100% that it give you this ability but I'm pretty sure it will!

This Kernel and TWRP applies to LineageOS 15.1, all LOS15.1-based ROMs (like RRemix) and all Treble GSI's.

F2FS loopback fix module is not needed anymore, you can directly install modules from Magisk Manager app.

Magisk modules are persistent now. They will never disappear, even when cache is cleared.

Magisk hide settings are persistent now. They will not reset after reboot.

You can now use systemless hosts properly (No ads and SafetyNet is still passing!).

Filesystem R/W speeds may and should be slightly better (I haven't tested this myself so feel free to do before-after benchmark comparisions).

Don't need to start from zero. You can restore your /data backup after formatting device and it will work just fine.

TWRP is updated to version 3.2.3-0 so it may fix OTA's on "enter pin to boot" encrypted devices.

In TWRP there's written "Lineage" next to it's version to avoid confusion, especially for newbs (Lineage because everyone's talking about LOS TWRP and it's also built on Lineage source)

"Format Data" button in "Wipe" screen is temporarily removed until I/we find fix to make it work. This feature is still broken and causing bootloops (Like on TWRP from LOS Wiki). You still need to use official one for decryption.

That's all I think. I will edit this thread If missed something.

Instructions:

* This instruction applies to new and existing LOS-based ROMs users *

* This tutorial I wrote for someone may be useful if you need help with bootloader mode(fastboot) *

Important: If you don't care about porting your /data to newer F2FS (not talking about Internal data) and willing to start from "zero" then you just should typical LOS installation steps + changing kernel (Steps 1 - 8 and 14 eventually if you're going to restore some pictures or something)

1. Do /data partition and/or Internal Storage backups if you didn't already. Pull them to your computer or SD card.

2. Flash TWRP 3.2.3-0 Lineage build (lineagetwrp.img) from the download section using method you want (fastboot one is recommended).

3. Flash latest official build of LOS15.1 (If you have it already then you can skip this step).

4. Flash bootimage (f2fs_boot.img): Install > Install Image > f2fs_boot.img and check "Boot"

5. Download latest official TWRP from HERE

6. Boot to bootloader mode (fastboot) and use this command "fastboot boot [OFFICIAL_TWRP_IMAGE.img]" to boot into official TWRP without flashing it.

7. When in official TWRP: Wipe > Format Data > type "yes". If it fails then reboot to bootloader mode (Main menu > Reboot > Bootloader) and boot it once again as in point 3 (It happens very often).

8. If formatting went fine then go to: Reboot > Recovery to boot to recovery flashed before. After it boots just make sure that it says "3.2.3-0 Lineage" on top bar like in attachment screnshot

9. Wipe > Advanced Wipe > check "Data" > Repair or Change File System > Change File System > F2FS (This step is not really necessary but it confirms that everything is set up if no errors was throwed here).

10. Reboot to recovery and put your TWRP /data backup on your Internal Storage via PC - Skip if on SD card.

11. Restore your TWRP backup.

12. Don't exit yet if you haven't restored from SD card. There's a little bug(?) where your data from Internal Storage will stay in /data/media directory but MTP will switch to /data/media/0/ after first boot so you will be not able to see that data via PC. Make sure you've deleted these files before rebooting to system. You can do this after first start too but these files will extend encypting time at least twice.

13. Finally you can reboot. In case you were using any lockscreen when doing a backup you should check THIS

14. You can put back your internal storage data right when ROM successfully booted.

Download:

DOWNLOAD - 12.01.2019

Troubleshooting:

If you encounter any problems in any of these steps you will probably need to start from step 6.

Still not able to do this or messed something up very badly so u can't enter TWRP? Try entering bootloader mode and type "fastboot erase userdata", then proceed to step 6.

Remember: After doing an OTA you will need to flash "f2fs_boot.img" once again before booting into system. Else you will end in constant reboots until you do this. Kernel will be updated when some changes will be pushed into it (not often)

Any support for this will be probably instantly dropped after first stable enough release of LineageOS 16.

Have Fun!​

All thanks goes to [MENTION=3839575]mikeioannina[/MENTION] for commiting to kuntao sources which I used here.

Kernel source

Recovery source​