[Xiaomi Mi 9 ROMs, Kernels, Recoveries, & Other Dev] mslezak:
[M.O.D. KERNEL Q]

*** NOTE: a dev has posted on TG the FOD fix for beta/ MIUI 12 forked from my code, download there! I asked for GitHub source to comply with XDA and will post once I have it and provide a link to the file link "Mi9/Mi9T Pro Optimization and Overclocking" Telegram has it now: https://t.me/joinchat/NNTe_E9G4ZcZKXCUrajFYQ ***

MIUI 11 Mi9/ 9T Pro MOD 1.5

MOD-Q 1.5 is for stable MIUI 11 variants for Mi9 only - Xiaomi.eu 11.0.5 stable is what it was built for, runs best on, just use it. The Mi9T Pro version supports MIUI 11 variants plus many AOSP builds. If you use an official MIUI 11 Xiaomi version you will get a warning message "Contact device manufacturer." You can ignore that, it means nothing. But I highly suggest using Xiaomi.eu 11.0.5, or another MIUI 11 variant like MiRoom or some use Revolution OS.

***DO NOT USE ANY PERFORMANCE (CPU/GPU/ETC) MAGISK MODULES WITH THIS FOR BEST PERFORMANCE!!! IT INSTALLS IT'S OWN OPTIMIZED MAGISK MODULE AUTOMATICALLY***

FP scanner will only work up to 11.0.5. Xiaomi keeps changing the code and not releasing it to made Dev builds not work. There were "patches" that worked until a few weeks back, but Xiaomi has yet again changed their FP scanner code. So I will not update the FP code, do not ask, it is a complete waste of time. Sorry, but Xiaomi.eu 11.0.5 and MOD 1.5 work very very well together.

Features:

835mhz GPU, Adreno Boost, Dynamic Fsync, Boeffla WL blocker (better battery idle), F2FS optimizations, LZ4 ZRAM. EXFAT USB/SDCard support added. Sultan Boost + PapaSmurf's Op7Pro tweaks, Dynamic Overclocking + Underclocking with frequency boost for smooth, fast, clean performance and fluid scaling. Many thanks to PapaSmurf who greatly influenced this kernel; portions are ported from his Op7 Pro Repo.

Mi9T Pro version also reported to work on AOSP ROMs using the original FOD implementation (Derpfest, MSM, CRDroid, Havoc, LOS).

Just use the Magisk Module it installs for you automatically when you flash the zip from TWRP, likely the best results will be obtained. SmartPack can be installed to choose between profiles under Performance Tweaks - battery / balanced / performance / gaming, although the default installed Magisk module is highly recommended by itself for optimal performance and good battery drain.

Github source has been added for MOD 1.5 here. Please read the Readme that's why it's there.

https://github.com/mrslezak/MODQ1.5

Releases are available here: Download them for your device and follow the instructions there. If you already have TWRP and Magisk, it will be easy. Just read please it will answer your questions.

https://github.com/mrslezak/MODQ1.5/releases/tag/MOD1.5

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[M.O.D. KERNEL PIE] Mi9 Android9 GPU830mhz F2FS data/cache Dynamic Fsync LZ4 WLblocker V2 [STABLE]

MOD Pie notes:

***New features added! Dynamic Fsync replaces the Fsync toggle (credits to author Paul Reioux aka Faux123 <reioux@gmail.com>), and Boeffla Wakelock blocker 1.1.0 (credits to author: andip71 <andreasp@gmx.de>) has been added. The GPU830mhz runs on a higher regulator now so even 3DMark runs without issue, this is as stable as it gets. A battery saving Magisk Module has been added for longer life and scored 422.5K still on AnTuTu! It will throttle and hotplug (idle) cores as needed to save battery ***

Super tweaked kernel for the Mi 9. Best AnTuTu Benchmark 432K thus far, expect 420K-430K in daily operation with good battery life. This will vary based on the ROM selected. Stock AnTuTu is 370K. So you can run your phone faster than any production 855+ at the moment. This kernel is setup on purpose to allow anything from stock to maximum performance, you can set parameters as you like in a kernel manager.

GitHub Source: https://github.com/mrslezak/MODKernel-V2-Cepheus

Releases are available here:

https://github.com/mrslezak/MODKernel-V2-Cepheus/releases/tag/V2

TG Name: MattoftheDead

M.O.D. Kernel (MattoftheDead). This kernel is STABLE, everything works, it runs on any MIUI based ROM (MIUI Global Dev, MIUI China Dev, MiGlobe, Xiaomi.eu, AOSP, etc.). ***If you install this kernel and don't follow the tweak instructions, it runs exactly like stock. There is now a Magisk module that will run with the optimal settings to make this easy! *** So read up. You can apply any tweaks you'd like. These include:

GPU 830mhz overclock - stable and smooth. The GPU will throttle down when not being used to a lower mhz. The Magisk Module will enable the max 830mhz clock for you. Or you can go without if you have a dialcode supported GPU MaxFreq OC mode *#*#8106#*#*

ZRAM LZ4 data encryption enabled - fastest encryption method, smaller ZRAM sizes (512mb is good) work very well [2GB is the stock ZRAM default, LZO is the default kernel compression which is slow]. ZRAM is in-memory swap so it is ultra fast. This allows you to have more free RAM for apps to run.

F2FS data and cache partition support - full ICE AES 256bit encryption. Note only [MENTION=4712355]mauronofrio[/MENTION] TWRP 3.3.1-39 + supports F2FS partition mounting so you MUST use this TWRP recovery!!!

F2FS has been tested on MIUI Global Dev 9.6.27 and Xiaomi.eu 9.7.22, 9.8.1, MiGlobe, RevOS, AOSP, Havoc thus far (more added daily) and read/write speeds and app access are definitely fast. Support was enabled by working directly with [MENTION=4712355]mauronofrio[/MENTION] on XDA (thanks Mauro) so we originated F2FS support for Mi9 - there are also F2FS kernel tweaks that help the speed in the kernel.

BOEFFLA Wakelock Blocker 1.1.0 - blocks wakelocks and allows you to change what gets blocked that is waking up your phone and preventing deep sleep. There are defaults blocked already in this build that are known to be blockable safely. If you want to add more, use SmartPack Kernel manager under Wakelocks. It will also show you what apps are causing them and the frequency so you can disable the ones that are not needed.

If you want to join in the discussion and see updates in realtime, World MI9 & Mi9T Pro Optimization and Overclocking is a TG group which has many things related to MOD and any other kernels, mods for the phone, Magisk Modules, all types of things for the devices.

Step 1: [KERNEL REQUIRED FILES]

Go to the releases page posted earlier and download everything.

Step 2: [ROM SELECTION]

If you already have a Pie MIUI based DEV ROM installed, you can continue to use it. Global Dev 9.6.27 is recommended. But this supports up to Xiaomi.eu 9.8.1. If you want to use a new MIUI based ROM, download it and setup the device (between these ranges of releases - some like MiRoom, some like stock, some like Xiaomi.eu). If you are clean flashing everything, don't bother restoring all the apps - they will be deleted when you switch to F2FS. Just set it up so you can login and get to the default menu with the default apps displayed. Either way, you will have to setup the device as a new phone. So back up all your user data (photos, downloads, etc), apps, etc. using Google Drive, Xiaomi Cloud, Titanium Backup Pro, or any other app that backs up apps and settings. It's often easiest to put them on your PC since you will be plugged into it during this install process with your USB cable.

Step 3: [MAURO TWRP INSTALLATION FOR F2FS SUPPORT]:

Boot Mi9 holding Power + Volume Down

Hook up to your phone to the PC with the charging cable

Open a command prompt. Go to your Minimal ADB and Fastboot folder.

Type: fastboot devices

And hopefully you see your device ID pop up. If not you don't have the right driver, the cable is bad, or something else is wrong. Search Google.

Next flash Mauro TWRP:

fastboot flash recovery twrp-3.3.1-41-cepheus-mauronofrio.img (or use his latest from the link at the bottom of this thread)

Hopefully you see it flash to the device in a few seconds successfully and it's ready to go.

Booting to TWRP:

Turn off your phone. Now hold down power + volume up. Once the boot Logo appears, let go of the power button but keep holding volume up. TWRP should boot. If not, try again. I usually have to remove the phone case. Now enter your password and proceed to the next section. If it asks you if you want to keep the system read only SAY NO! You will be modifying system components, keep it writable to avoid installation issues.

Step 4: [FLASHING THE M.O.D. KERNEL]

Check the releases page posted above. Just unzip the file there and flash via TWRP as an image to boot. It's patched with Magisk already.

Step 5: [CONVERT EXT4 TO F2FS}:

Converting EXT4 data and cache partitions to F2FS:

Check the releases page posted above for fstab_patch_F2FS_MI9_Cache_NoBarrier.zip required to enable F2FS. You MUST flash this in TWRP or your OS will NOT be able to boot an F2FS data partition!!!! This file has been kanged all over the internet, it was created here. Feel free to use it, everyone already is.

***Note flashing TWRP / Install / fstab_patch_F2FS_MI9_Cache_NoBarrier.zip MUST be repeated any time you change ROMs or you won't have access to your data!!! So back this up!!!!***

Boot back into TWRP. You will need to go to Wipe, Advanced Wipe, Click Data, Repair or Change File System, Change File System, and click F2FS. Swipe to change. It will format and you'll have nothing on your data partition. Next format cache. Go to Wipe, Advanced Wipe, Click Cache, Repair or Change File System, Change File System, now click F2FS. Swipe to change. Again it will format and be wiped.

Step 6: [SETTING UP YOUR "NEW" PHONE]:

Next, reboot to System. The device should boot up and welcome you to your "new" device. It has no data apps so it has to be new. You will have to login to your Xiaomi account if it is associated with the device. Then you can choose to restore from a Google Backup and next from Xiaomi Cloud. You can do either one to get your apps back. I would suggest Xiaomi Cloud after Google completes all its downloads - it will place icons in the right places and install your root apps if you had them. And after setting up your apps, now boot back to TWRP and make a Backup. Now for this Nandroid backup you should backup data, boot, dtbo, and vendor partitions (vendor has the fstab.qcom file that allows your F2FS supported partition to boot now). Even if you save to your internal device initially, be sure to put it on a PC for safe keeping. Then If you accidentally wipe your partition later, you can skip importing, get to the main screen after minimal setup completes, enable file transfer from the connected PC, and then copy the Nandroid backup to your Internal Memory. Boot into TWRP and restore the backup and you're back in business.

Step 7: [INSTALLING MAGISK MANAGER AND KERNEL MANAGER]:

So now you install the MagiskManager-v7.3.2.apk to enable all root functions. If you want Google Pay and anything else setup posts are here in the Mi9 forum that show you how. Generally hide all banking apps, trading apps, Google Pay, GMS, etc. And I suggest installing GMS doze for better battery life and the Mi9 Auto Brightness fix.

In addition, to have the MOD kernel setup for the best performance, go into Magisk Manager, Modules, and flash the (Magisk)MOD-Battery-Saver+_v2.zip from the releases page. It will auto set all the parameters the kernel features, and does a great job with extending battery life at the same time.

This is the best setup for performance. Pictures are included below.

If you would like to change the settings, you need a kernel manager. So next you can install the Smart Pack APK SmartPack_Kernel_Manager_v8.7.apk to enable or disable all the tweaks you desire.

Pictures are attached below to show the TWRP screens for flashing and F2FS partition conversion. Also the settings of best performance using Smart Pack kernel manager are here. If you want to change any of the best settings after flashing the Magisk Module, do it in the kernel manager of your choice and set on boot - where to change those options is in the pictures below for SmartPack.

Enjoy!

Mauro TWRP

https://xdaforums.com/Mi-9/development/recovery-unofficial-twrp-xiaomi-mi-9-t3905825

SmartPack Kernel Manger

https://xdaforums.com/android/apps-games/app-smartpack-kernel-manager-t3854717

FK Kernel Manager CPU Profile

https://play.google.com/store/apps/details?id=com.franco.kernel&hl=en_US

Magisk

https://xdaforums.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445

Minimal ADB and Fastboot

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

And one last thing. I have been working with some of the most well known devs out there on XDA on Telegram, Private Messaging, and other channels to get this kernel where it is - but I have no XDA presence. I've helped hundreds of people on Telegram setup their systems or diagnose their issues. If you find this post useful, helpful, innovative, or install my kernel and like it, please click the Thanks button to acknowledge the work that I've done to get the Mi9 to this point. It would be greatly appreciated to get some thank yous for all the hours I've put into this development work for the Mi9, and provides some motivation to keep improving. Other kernels are on the way as well for more Xiaomi / Redmi devices if I feel some love from the community. Much appreciated!

Thanks goes out to [MENTION=3545504]smeroni68[/MENTION] and [MENTION=4712355]mauronofrio[/MENTION] for helping fix the fstab.qcom zip that cost several hours of pain yesterday for users and I on Telegram that did not have the Vendor partition mounted when flashing the old fstab.zip file - it will flash now mounted or not from TWRP. And thanks to [MENTION=3053815]ilia1985[/MENTION] for providing a Magisk Module template for the kernel manager settings, now OC setup doesn't even need a kernel manager!

***DISCLAIMER - APPLYING ANY ROOT MODS IS ALWAYS AT YOUR OWN RISK! I AM NOT RESPONSIBLE FOR BRICKED DEVICES, DAMAGE OR OTHER THAT MAY OTHERWISE OCCUR. THIS HAS BEEN TESTED EXTENSIVELY BUT USE AT YOUR OWN RISK***