Preface
My Nexus 4 was really slow because the sequential write speed of the filesystem was around 3MB/s. Random write speed was nearly zero…
Fstrim (or LagFix) didn’t help at all 🙁 I think a lot of you already know about F2FS the flash friendly file system from Samsung. Benchmarks show that it really boosts I/O Performance. So time for me to try it and see whether it will fix my performance issues.
F2FS (Flash-Friendly File System) is a flash file system created by Kim Jaegeuk at Samsung for the Linux operating system kernel. The motive for F2FS was to build a file system that from the start takes into account the characteristics of NAND flash memory-based storage devices (such as solid-state disks, eMMC, and SD cards), which are widely used in computer systems ranging from mobile devices to servers.
You can format your /data and /cache partition to F2FS. Normally you’ll loose all data in this process and have to reinstall everything. But this small howto will show you how to recover your data so you can continue where you left off. Just like a “dirty” ROM flash.
Note: In my mind it doesn’t make much sense to format/system to F2FS because you would need a modified ROM to use it. Everytime you update your ROM you would have to modify it to use /system as F2FS. On top of that there shouldn’t be a real performance gain with a F2FS /system partition because it’s read-only. And reading operations are fast with ext4, too. The difference is non-existent or very low. In my humble opinion the so called All-F2FS is pretty useless.
This following method should work with all devices which have FSFS compatible TWRP recovery, rom and kernel available.
Prerequisites
- PC with ADB installed for SD backups
- F2FS compatible ROM (all major 4.4 or 5.x ROMs like CyanogenMod 11/12, Omni, Paranoid, Carbon, … newer than 07/2014 should work) – Update your ROM before if it’s too old!
- I’ve used cm-11-20141003-NIGHTLY-mako.zip
- F2FS compatible Kernel
- I’ve used SaberMod franco.Kernel
- F2FS compatible TWRP Recovery (this recovery has F2FS support, too)
- sdcard Fix Permissions script (scroll down a little bit)
Procedure
- Flash the F2FS compatible TWRP Recovery with Flashify for example
- Boot into Recovery
- Backup > Data
- Save your internal SD card with one of the following options
- Either reboot to system and copy files to your PC via USB (MTP)
- Or pull files via adb (adb pull /data/media sd_backup)
- Copy the kernel and the sdcard fix script to your created backup folder
- Wipe > Advanced Wipe > Data > Repair or Change File System > Change File System > F2FS
- Wipe > Advanced Wipe > Cache > Repair or Change File System > Change File System > F2FS
- Copy the saved SD card content back to your device with: adb push sd_backup /data/media/0/
Afterwards the folder structure should look like this: /data/media/0/…Folders like DCIM, Music, Downloads, …
You can check with: adb shell ls -R /data/media - Restore > Choose backup > Data (the warning about ext4 backup doesn’t matter)
- Advanced > Fix Permissions
- Flash the sdcard Fix Permissions script with: Install > Choose sdcard fix zip
- Wipe > Advanced Wipe > Cache & Dalvik Cache
- Flash a F2FS compatible kernel with: Install > Choose kernel zip
- Reboot to system
Now your Android device should fly again 🙂
I followed these instructions but while restoring the data backup, I received an error in TWRP, something like “createTarFork() process ended with ERROR=255”. After booting into system, and of course not all of the data was restored so things were in a weird state, I booted back into the recovery and found that the /sdcard had been emptied. So I then wiped /data again and restored /data from backup, this time without an error. Then I ran the permission fix steps and copied /sdcard back over. Now everything is fine. Nexus 4, Quanta Kernel v6test3, CM12.1 nightly 8/26, TWRP 2.8.7.
I would think you would have to edit your ROM’s fstab to show the partitions as F2FS
So by “In my mind it doesn’t make much sense to format/system to F2FS because you would need a modified ROM to use it. ” you’re implying that I need a modified ROM only for All-f2fs. If I have stock lollipop on my N4 and have f2fs compatible kernel and recovery, can I simply convert my data and cache partitions to f2fs?
Yes should work