[TUTORIAL] Migrate filesystem to F2FS

Search This thread

mickybart

Senior Member
Sep 22, 2014
1,122
5,628
Montreal
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
 
Last edited:

A6ekAK

Senior Member
Many thanks man, it's freakin easy to do! I have some questions:
- I fell dizzy about it, I can't format /system partition to f2fs on nAOSP yet, am I right?
- formatting from ext4 have nothing to do with /data partition size change, yes? (and some off topic question: does increasing data partition size help on Lollipop? Is system feeling more responsive, faster?)
 

mickybart

Senior Member
Sep 22, 2014
1,122
5,628
Montreal
Many thanks man, it's freakin easy to do! I have some questions:
- I fell dizzy about it, I can't format /system partition to f2fs on nAOSP yet, am I right?
- formatting from ext4 have nothing to do with /data partition size change, yes? (and some off topic question: does increasing data partition size help on Lollipop? Is system feeling more responsive, faster?)

no you can't format /system to f2fs on nAOSP. You can take a look on nAOSProm thread but there is no good reason to migrate it to f2fs. /system is mounted in read-only mode. But if I have few request to permit it I will integrate it (really easy to do) but I think that this is more trouble for the end user.

There is no link with /data partition size to migrate to f2fs. Increase /data can be necessary depending your own usage. You can take a look on the TUTORIAL to increase the data partition.
 

vayavalla

Senior Member
Jan 24, 2012
964
281
I'm not able to convert the partitions :(

For those who have tried: is there any improvement?
 
Last edited:

zhackary

Member
Dec 8, 2012
31
19
First i formatted my partitations with twrp to f2fs file system.And then i installed nAOSP rom to my device. Without any problem i'm using my phone but for others Do we need install rom first then backup data before converting partitations and restore data, after formatting f2fs?

Sorry for the noob question but what's the benefit from doing this?

You can check this post for benefits :
http://xdaforums.com/showthread.php?t=2697069
 
  • Like
Reactions: zaidx

SwitzXXL

Member
Dec 16, 2013
34
2
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.
I'm now waiting since 10-20 minutes while "Removing all files under '/data' .... how long does it normally take?
 

mgrinwis

Member
Sep 25, 2013
49
21
Latest version of TWRP works again on Xperia S

The latest version of TWRP, version 2.8.4.1, works great on our Xperia S! Do not add mkfs.f2fs support to TWRP 2.8.4.1 since this comment applies only to version 2.8.0.1. TWRP 2.8.4.1. has build in mkfs.f2fs support.

Flash TWRP version 2.8.4.1 from the adb shell, or with the terminal app in TWRP by using this code:
Code:
dd if=/tmp/twrp-2.8.4.1-nozomi.img of=/dev/block/mmcblk0p11
Please dubble or triple check the correct spelling of "mmcblk0p11".
 
Last edited:

m1st3r1

Senior Member
Aug 15, 2010
890
279
Jakarta
However, do not add mkfs.f2fs support to TWRP 2.8.4.1 since this comment applies only to version 2.8.0.1. TWRP 2.8.4.1. has build in mkfs.f2fs support.
you're kinda wrong. the rom that you have (in your /system) must have mkfs.f2fs /sbin/ . current pure aosp rom doesnt have it, so you need to push the file manually. it doesnt matter what your twrp version. if there's no mkfs.f2fs in the rom, it cant change to f2fs.

if you have current naosp rom installed, you dont need to push mkfs.f2fs.
 
  • Like
Reactions: mgrinwis

mgrinwis

Member
Sep 25, 2013
49
21
you're kinda wrong. the rom that you have (in your /system) must have mkfs.f2fs /sbin/ . current pure aosp rom doesnt have it, so you need to push the file manually. it doesnt matter what your twrp version. if there's no mkfs.f2fs in the rom, it cant change to f2fs.
if you have current naosp rom installed, you dont need to push mkfs.f2fs.
Thanks for your quick corrections/remarks! I figured it was related to the TWRP version because the f2fs option was availible after I installed version 2.8.4.1...
 
Last edited:

mickybart

Senior Member
Sep 22, 2014
1,122
5,628
Montreal
Thanks I will take a look on TWRP 2.8.4.1.

mkfs.f2fs need to be available on the recovery itself.
On the ROM you don't have mkfs.f2fs on nAOPSrom or Pure AOSP lollipop because the mkfs.f2fs is build statically and pushed into the boot.img only (ramdisk part). This is a pure choice and default rule for f2fs-tools (mkfs.f2fs) because format a filesystem from the ROM is not really common.

If TWRP 2.8.4.1 embedded mkfs.f2fs, you will have it out of the box. On nAOSProm and pure AOSP lollipop, the init process push the mkfs.f2fs into TWRP to add the feature (necessary for 2.8.0.1 support of mkfs.f2fs).

EDIT: for pure AOSP lollipop this is include with the last test kernel but not in test11. for nAOSProm you need b15 (or b14c boot.img)
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 50
    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
    4
    Many thanks man, it's freakin easy to do! I have some questions:
    - I fell dizzy about it, I can't format /system partition to f2fs on nAOSP yet, am I right?
    - formatting from ext4 have nothing to do with /data partition size change, yes? (and some off topic question: does increasing data partition size help on Lollipop? Is system feeling more responsive, faster?)

    no you can't format /system to f2fs on nAOSP. You can take a look on nAOSProm thread but there is no good reason to migrate it to f2fs. /system is mounted in read-only mode. But if I have few request to permit it I will integrate it (really easy to do) but I think that this is more trouble for the end user.

    There is no link with /data partition size to migrate to f2fs. Increase /data can be necessary depending your own usage. You can take a look on the TUTORIAL to increase the data partition.
    3
    @mickybart

    If i currently have a SXS with the rom on my signature and another with fresh installation of your rom, f2fs on all 3 partitions, repartitioned and almost operational (meaning for my standards, about 60-70 apps, a lot of customization in minor things etc...)

    is there any tests you would like me to run to check against 4.1 ext4?

    Great job, i just wish you stay around for the 5.1 update which every lollipop user in the universe is waiting for to solve some mysteries, like miscellaneous battery drain!!!

    No it's fine. Thanks schumifer1 :)
    I will be around for 5.1 and I'm waiting it too :)
    3
    Hi,
    What about to convert sdcard (Intenal Storage) to f2fs as well ?
    Christophe

    Yes it's possible. I will wrote the procedure when I will do the test on my side.
    2
    Thanks I will take a look on TWRP 2.8.4.1.

    mkfs.f2fs need to be available on the recovery itself.
    On the ROM you don't have mkfs.f2fs on nAOPSrom or Pure AOSP lollipop because the mkfs.f2fs is build statically and pushed into the boot.img only (ramdisk part). This is a pure choice and default rule for f2fs-tools (mkfs.f2fs) because format a filesystem from the ROM is not really common.

    If TWRP 2.8.4.1 embedded mkfs.f2fs, you will have it out of the box. On nAOSProm and pure AOSP lollipop, the init process push the mkfs.f2fs into TWRP to add the feature (necessary for 2.8.0.1 support of mkfs.f2fs).

    EDIT: for pure AOSP lollipop this is include with the last test kernel but not in test11. for nAOSProm you need b15 (or b14c boot.img)