[Sony Xperia S, Acro S, Ion] mickybart:
Migrate filesystem to F2FS

Prerequisite

This tutorial is based on TWRP 2.8.0.1

You need mkfs.f2fs support into TWRP 2.8.0.1

Your kernel needs to support f2fs

Your boot.img should have an fstab that permit to mount f2fs filesystem.

Important: contact the ROM maintainer if you are not sure about which partition you can format into f2fs

Download

for F2FS: mkfs.f2fs

You need to download mkfs.f2fs only if your TWRP doesn't include it. Simply push mkfs.f2fs into /sbin when you are on the recovery (eg: adb push mkfs.f2fs /sbin/).

Migrate /data

On this tutorial, we will show you how to migrate /data to f2fs without data lost (you need of course a valid backup).

Convert /data to F2FS :

Reboot into TWRP (push mkfs.f2fs if needed)

Backup the ROM

Go to Wipe/Advanced Wipe

Select Data

Select "Repair or Change File System"

Select "Change File System"

Select "F2FS" (Swipe to change will format the filesystem.)

Restore /data :

Go to Settings

Select "Use rm -rf instead of formatting"

Go to Restore

Select your backup and check ONLY "Data"

Swipe to restore

When the restore is done, go to Settings and uncheck "Use rm -rf instead of formatting"

(Use rm -rf instead of formatting) only necessary if you want to restore a filesystem backup done with another filesystem format. (eg: restore an ext4 backup to an f2fs target). If you don't check it, TWRP will revert the change and format the partition to the filesystem used during the backup of the filesystem.

Migrate /cache

Convert /cache to F2FS :

Reboot into TWRP (push mkfs.f2fs if needed)

Go to Wipe/Advanced Wipe

Select Cache

Select "Repair or Change File System"

Select "Change File System"

Select "F2FS" (Swipe to change will format the filesystem.)

Migrate /system

You need to follow the same procedure than "Migrate /data" but of course you need to format system and to restore system.

Migrate /sdcard

If you want to do a backup, run into recovery and from your computer run "adb pull -p /sdcard backup_folder/".

To restore just do adb push -p backup_folder/ /sdcard

Convert /sdcard to F2FS :

Reboot into TWRP (push mkfs.f2fs if needed)

Go to Wipe/Advanced Wipe

Select Internal SDCard

Select "Repair or Change File System"

Select "Change File System"

Select "F2FS" (Swipe to change will format the filesystem.)

Select terminal and run:

chown -R 1023.1023 /sdcard

chmod -R 770 /sdcard

Boot the ROM

Now it's time to reboot the ROM.

You can check that every partition migrate to f2fs are available by doing that during the "bootanimation" :

Connect with adb shell

Tape the command "mount" (You should see for example "/data f2fs" somewhere in the output)

You can have a long long long reboot if /cache is not available.

You can have a message relative to encrypt device if /data is corrupted or unavailable.

On both case, simply restart into the recovery and check the procedure again.

Rolback procedure

Just do the same migration procedure but of course reformat to ext4 (or what's you want that is supported by your ROM)

ROM known to be supported:

Pure AOSP lollipop (/data and /cache supported) - (mkfs.f2fs not available)

nAOSProm 5.0 (/data, /cache and /sdcard supported)

Any other ? Let me know and I will update the post

Thanks

Thanks to frantisekz and mirhl that permit me to improve the procedure