[Nexus 4 Q&A, Help & Troubleshooting] mesaj:
First of all

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 must have TWRP Recovery with F2FS support.

As far as I know, multirom-twrp works (but keep in mind to not add multirom support patch on M ROMs) or use

twrp-2.8.7.0-mako_f2fs_otg_multi.zip for flashable zip by [MENTION=5311064]txuki2005[/MENTION] or either extract img file from it and flash using fastboot or

openrecovery-twrp-2.7.0.0-mako-All-F2FS.img for fastboot image from CallMeAldy thread (in this thread you can also find script to do all formatting for you, but if you want to have more control just continue with my guide :) it's also place where I found F2FS description at). It's also possible to auto-convert to f2fs using Quanta Tweaks app for Quanta Kernel users.

Few things to know before starting:

Kernel and rom must support f2fs, if it doesn't your device will stop on lockscreen asking for unknown password, for list of supported kernels and roms I'd suggest going to CallMeAldy thread again but I will add some more supported kernels here

Always do a backup (despite different filesystems it is possible to restore your /data)

If you made a backup copy it somewhere else before you continue because there's a risk your internal storage including your previously made backup will vanish

rm -rf is a linux command that removes files without making changes to partitions filesystem (you can see the difference in step2 in restore guide)

Format removes files and changes filesystem usually to default if not specified (which is ext4) (you can see the difference in step3 in restore guide)

Formatting /system as f2fs will cause device to not boot, probably bootloader doesn't recognize it even if supported in kernel

Step by step guide starts here:

Make a backup and copy it on other storage than phone, copy your internal storage files as well if you wish to keep them!

[*]Got to TWRP settings menu and make sure 'Use rm -rf instead formatting' is DISABLED

[*]Go to TWRP Wipe menu and select Advanced wipe settings

[*]Select desired partitions ONE at a time - /data and /cache then continue to "repair or change filesystem"

[*]Then go to Change File System (mine says it's already f2fs in Current File system line on top, if you didn't do this before, it will say ext4)

[*]Verify your partition is f2fs by checking Current file system line on top that said ext4 before is now saying f2fs. If it's still ext4 you probably forgot to uncheck step 2.

[*]If you made it for /data first then repeat steps 5 and 6 for /cache and vice versa

[*]If both partitions are f2fs now, ENABLE 'Use rm -rf instead formatting'

[*] Install your ROM and Kernel

If you wish to restore your /data from previous installation

Go to TWRP settings menu and make sure 'Use rm -rf instead formatting' is ENABLED

Go to TWRP restore menu and select your backup (if it's empty after changing to f2fs then better you've done as I advised to copy backup from phone somewhere else). If it's working you will see confirmation and "Removing all files" under partition that is being restored. It will not change filesystem back to ext4.

To compare when 'Use rm -rf instead formatting' is DISABLED it will say "Formatting using mkfs.ext4" function and partitions will be back again ext4

Kernels and ROMs supporting f2fs

with Android Marshmallow 6.0

Quanta V9 M and newer (it's possible to auto-convert to f2fs using Quanta Tweaks app with this kernel)

TaUrUs R37 and newer

if you know about more kernels supporting it, let me know :)

ROMs (Marshmallow):

Chroma - probably will need other kernel from above

PureNexus Project

SAOSP - Simple AOSP

with older Android releases

They can be found in CallMeAldy thread post #2 and #3