***New features added! Dynamic Fsync replaces the Fsync toggle (credits to author Paul Reioux aka Faux123 <[email protected]>), and Boeffla Wakelock blocker 1.1.0 (credits to author: andip71 <[email protected]>) has been added. Download the new zip things are simplified! 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 (to use, uninstall the Optimal settings one in Magisk Manager, reboot, install battery savings one in Magisk Manager, reboot 2x after all apps fully load and you login. That way changes will stick. The new update includes less files and is a TWRP restore only variant already patched with Magisk 19.3. TWRP fstab flash files to auto mount F2FS /vendor/etc/fstab.qcom are included as well. ***
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 that work for you.
MOD-KERNEL-TOOLS_v2.zip -> kernel and all software to use the features of the kernel [DOWNLOAD FIRST and UNZIP to your computer]:
GitHub Source: https://github.com/mrslezak/Xiaomi_Kernel_OpenSource branch: cepheus-p-oss
Telegram Group: https://t.me/joinchat/NNTe_E9G4ZcZKXCUrajFYQ
Telegram Name: MattoftheDead
PayPal donations: [email protected] (added upon XDA forum user request)
M.O.D. Kernel (MattoftheDead). This is a kernel project that has been going on for months now behind the scenes. It is STABLE, everything works, it runs on any MIUI based ROM (MIUI Global Dev, MIUI China Dev, MiGlobe, Xiaomi.eu, AOSP, etc.). Android 9 (Pie) only since Android 10 source code has not been released and Xiaomi decided to change the kernel components. ***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 Modules (2 choices) will enable the max 830mhz clock for you. Or you can go without if you have a dialcode supported GPU MaxFreq OC mode *#*#8106#*#*
FSync toggle (enable/disable) - disable gives higher memory speed at the risk of data corruption if a system crash occurs. Note I've used this 4 months with no issues, if you use stable software you are less likely to run into problems. Dynamic Fsync has been added (writes to disk when screen is off, safer than just disabling fsync).
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 @mauronofrio 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 @mauronofrio 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, here is the Telegram Link: https://t.me/joinchat/NNTe_E9G4ZcZKXCUrajFYQ -> XDA MI9 Optimization and Overclocking
Step 1: [KERNEL REQUIRED FILES]
First download the Mega.nz zip file at the beginning of this post which comes with a bunch of tools and the kernel so you can get up and running. It comes with the modified fstab.qcom file for encrypted F2FS support, fstab_patch_F2FS_MI9.zip for most devices (encrypted partitions) which will automatically patch that file for you from TWRP, as well as fstab_patch_F2FS_unencrypted_MI9.zip for the few who use it (developers mostly), the Mauronofrio TWRP version required for F2FS twrp-3.3.1-41-cepheus-mauronofrio.img, Magisk-v19.3, MagiskManager-v7.3.2.apk, SmartPack Kernel Manager SmartPack_Kernel_Manager_v8.7.apk to set tweaks - just follow the pictures in this thread to setup SP in 5 minutes, or use the Magisk Module of your choice. As mentioned, a Magisk Module [Magisk-Module]MOD-Kernel-Optimal-Settings-GPU830.zip can be flashed in Magisk Manager under Modules to give you the best performance settings everything up on boot for you! (credit goes to PapaSmurf OP7 dev XDA eoghan2t7 for assistance with the GPU commands to make 830mhz possible without a kernel manager or dial code) and a new [Magisk-Module]MOD-Kernel-OC-Battery-Saver-Settings-GPU830.zip for optimal battery life with still great performance (422.5K AnTuTu). A Franco Kernel Manager CPU Profile is included FK_Kernel_Manager_Profile-Maxfreq-CPUs if you use FK, as well as a more battery friendly FK_Kernel_Manager_Profile-Maxfreq-Less-Aggressive-CPUs. Also the latest Windows Minimal ADB and Fastboot minimal_adb_fastboot_v1.4.3_setup.exe is included. And there is only 1 TWRP restore file to make installation easier [TWRP-Restore]830GPUMaxReg-DynamicFsync-BOEFFLA-WL-Blocker.zip that is already patched with Magisk 19.3.
Step 2: [ROM SELECTION]
If you already have a MIUI based ROM installed, you can continue to use it. If you want to use a new MIUI based ROM, download it and setup the device. 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. Now to get your [deviceID] and to ensure you can reflash the original files in case of any issues with installing the kernel, in TWRP select Backup, check mark Boot, DTBO, and Vendor. Then create a backup. You can call it STOCK or whatever you'd like.
Step 4: [FLASHING THE M.O.D. KERNEL]
In the MOD-KERNEL-TOOLS zip file, unzip [TWRP-Restore]830GPUMaxReg-DynamicFsync-BOEFFLA-WL-Blocker.zip to internal storage: \TWRP\BACKUPS\[deviceID]\ or to an OTA SD card or USB drive with the same directory structure. This can be done from your PC directly once TWRP is booted - it should let you copy and paste to the internal device. Then click Restore, and click restore boot and dtbo. It is already patched with Magisk (you have root access). Next you need to install the fstab.qcom which will enable you to boot either EXT4 or F2FS. So flash the next zip file from the MOD-KERNEL-TOOLS file - copy fstab_patch_F2FS_MI9.zip to internal storage , select Install in TWRP, and flash the zip file. If you are on an unencrypted partition (very few, usually developers), use the fstab_patch_F2FS_unencrypted_MI9.zip instead. Now reboot and ensure you get back to your startup screen / welcome screen etc.
Step 5: [CONVERT EXT4 TO F2FS}:
Converting EXT4 data and cache partitions to F2FS:
***Note flashing TWRP / Install / fstab_patch_F2FS_MI9.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. Now for the best settings, go to Modules in Magisk Manager, click the + button, select and flash the included MOD-Kernel-Optimal-Settings.zip. This is the best setup for performance. Pictures are included below. EVEN THE GPU CLOCKS TO THE MAX 830MHZ NOW WITH NO KERNEL MANAGER INSTALLED!
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.
Links to XDA files included in the MOD-KERNEL-TOOLS_v2.zip:
SmartPack Kernel Manger
FK Kernel Manager CPU Profile
Minimal ADB and Fastboot
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 @smeroni68 and @mauronofrio 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 @ilia1985 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***