Use of F2FS for /data

Search This thread

ss2man44

Senior Member
Aug 31, 2011
56
74
Trenton, GA
Back story:
I bought a Moto X during the $100 off promotion and while I was waiting for it to be delivered, I read reviews and poked around online for interesting things about the phone. As an 8GB Nexus 7 owner, the one thing that caught my eye the most was this section of the Anandtech review discussing internal storage performance. Considering how badly my N7's storage performance degraded and how unbearably slow it has become, I felt like it could make good use of this "flash friendly file system." Some Googling revealed that the F2FS driver was developed by Samsung and actually contributed to the official kernel, where it was implemented somewhere around 3.8. I've done some development for an HTC phone in the past, but never for the Nexus 7, so I went and researched the kernel. Because Google's Tegra 3 kernel is based on 3.1, I had to start working on backporting the driver, when I discovered this repository of backports for F2FS. It provides patches for 3.0 and 3.2, but not for 3.1, so I manually applied appropriate changes from each. When I flashed the kernel and booted, it seemed to work, so I went ahead and injected the kernel into the latest TWRP image as well. I also modified the fstab for both the recovery and ROM and compiled Cyanogenmod's f2fs-tools for Android and statically linked them before injecting them into TWRP as well. I then booted into recovery, formatted /data (TWRP knew to use mkfs.f2fs), and booted back into Android. Success, it worked! I've been using my Nexus 7 like this since Friday evening and it's been so much more usable. Not perfectly "like-new" smooth, but it doesn't hang as often or as long.


I haven't seen anyone actually try this yet so I'm hoping my effort will be able to make a difference for N7 owners fed up with slow performance. Switching to f2fs is as easy as flashing a modified kernel and recovery, then doing a factory reset. Also, any interested developer is more than welcome to use anything I post here.

Basically, I took the official Tegra 3 kernel and did this:

KERNEL PATCH

Then modified the stock ROM's fstab like this:

FSTAB

Then I gave TWRP statically-linked f2fs-tools binaries:

F2FS-TOOLS

Then I reformatted /data and away it went:

SzDwaAi.png


I'm going to reboot into Linux and attach my boot/TWRP images for you guys to test out. Until then, I'd love to have some feedback.
  • What do you think about using f2fs on the Nexus 7?
  • Is it worth it?
  • What kind of impact on performance or battery life do you think this will have?
  • Did I do something seriously wrong with my kernel/fstab?
  • Am I absolutely insane and dangerous to everyone's Nexus 7 tablets and their puppies?

Image Downloads
Android File Host | Google Drive

Instructions:
WARNING: This process obviously will wipe your data. Make a NANDroid backup beforehand and save it to your computer. While I personally use this, I take no responsibility for damage done to your device.
  1. Flash boot and recovery like usual:
    Code:
    $ fastboot flash boot boot-F2FS.img
    $ fastboot flash recovery openrecovery-twrp-2.6.3.1-grouper-F2FS.img
  2. Format Data in TWRP
  3. Reboot
  4. Done!
Note that these are for the latest official 4.4.2 build KOT49H.

Let me know how your performance and battery life change after applying this. Storage performance should noticeably increase and battery life change should be negligible.
 
Last edited:

madd0g

Senior Member
May 8, 2010
2,841
872
Excellent, hope you'll get around and do it for rest of the Nexus line too (greetings from Reddit). :]
 

Erovia

Senior Member
Sep 16, 2012
818
262
This actually looks pretty interesting. Do you have any benchmark result?
I hope some of the kernel devs around here will pick up your idea.
 

sgt. meow

Senior Member
Dec 21, 2011
4,423
2,973
25
Dhaka
The kernel devs can integrate the kernel patch and the fstab patch to some extent but definitely not the recovery patch. I'm going to try this tomorrow or the day after.
Great work.
 

evilspoons

Senior Member
Nov 21, 2010
57
16
Excellent idea - I'm highly interested in the results. My 2012 N7 is starting to look quite pokey alongside my N5, so if this provides an improvement I'm all over it.
 

ss2man44

Senior Member
Aug 31, 2011
56
74
Trenton, GA
Excellent, hope you'll get around and do it for rest of the Nexus line too (greetings from Reddit). :]
Unless I get distracted, the plan is to do this for the Nexus 4. My goal is to expose this sort of thing to existing developers and let them handle the logistics. I've always been terrible about sticking to a project.


This actually looks pretty interesting. Do you have any benchmark result?
Not yet. This is what I had to sat about benchmarks in the Reddit thread:
ss2man44 said:
The only problem is that the Nexus 7 performs at its worst after the media has been used for a while and filled with data. I'm hoping others will provide their experiences under these conditions, but if need be, I'll do some benchmarks of my own when I have time.


The kernel devs can integrate the kernel patch and the fstab patch to some extent but definitely not the recovery patch. I'm going to try this tomorrow or the day after.
Great work.
This is exactly what I hoped for when I posted this. Kernel developers can merge this patch and if it gains enough attention, perhaps conventions could be established around specifying which filesystem a kernel/recovery is designed for. Built-from-source recoveries with F2FS support would be nice as well.
 
  • Like
Reactions: sgt. meow

sgt. meow

Senior Member
Dec 21, 2011
4,423
2,973
25
Dhaka
Unless I get distracted, the plan is to do this for the Nexus 4. My goal is to expose this sort of thing to existing developers and let them handle the logistics. I've always been terrible about sticking to a project.



Not yet. This is what I had to sat about benchmarks in the Reddit thread:




This is exactly what I hoped for when I posted this. Kernel developers can merge this patch and if it gains enough attention, perhaps conventions could be established around specifying which filesystem a kernel/recovery is designed for. Built-from-source recoveries with F2FS support would be nice as well.

The patch applied cleanly (the second time I've ever seen a patch do that). Good job.
I'll compile and flash to see if it boots (there are issues with my kernels) and if all goes well I'll switch completely to F2FS.
 

sgt. meow

Senior Member
Dec 21, 2011
4,423
2,973
25
Dhaka
The patch applied cleanly (the second time I've ever seen a patch do that). Good job.
I'll compile and flash to see if it boots (there are issues with my kernels) and if all goes well I'll switch completely to F2FS.

Well it booted on one ROM that has no issues with SELinux and the other didn't boot although the same config without F2FS boots fine. Strange.

Sent from my Nexus 7 using Tapatalk
 

buggatti

Senior Member
Aug 24, 2011
152
15
OMG

At first when I tried this I wasn't expecting this great deal of performance just by a file system change but boy was I wrong

The benchmark aren't higher but the the system performance is quite noticeable when using


This combines with FSync Off and nexus 7 will be flying
 
f2fs implementation on the note2 and s3 on all partitions: kernel & recovery and a compatible rom for the s3...perhaps you might get some help from those devs. using it on my s3 and the performance has been great. not entirely sold on benchmarks but on ext4 i was getting 14-15k on antutu. w/ f2fs on the same cpu/gpu speeds, i'm getting 18-19k. HTH

would really like to see this implementation on our beloved n7
 

ss2man44

Senior Member
Aug 31, 2011
56
74
Trenton, GA
f2fs implementation on the note2 and s3 on all partitions: kernel & recovery and a compatible rom for the s3...perhaps you might get some help from those devs. using it on my s3 and the performance has been great. not entirely sold on benchmarks but on ext4 i was getting 14-15k on antutu. w/ f2fs on the same cpu/gpu speeds, i'm getting 18-19k. HTH

would really like to see this implementation on our beloved n7

Using it on all partitions is very trivial and doesn't need any more kernel modifications. I just limited it to /data/ because that's what Motorola did and it seems to work very well for them. I also didn't know whether or not it would cause any problems in the long run.
 

alifa

Senior Member
Jun 5, 2012
84
3
/home
Feedback

1. What do you think about using f2fs on the Nexus 7?
2. Is it worth it?
3. What kind of impact on performance or battery life do you think this will have?
4. Did I do something seriously wrong with my kernel/fstab?
5. Am I absolutely insane and dangerous to everyone's Nexus 7 tablets and their puppies?
1. It's about time I ditch ext4!
2. it doesn't matter, you're learning new stuff:highfive:
3. Only the benchmark wil tell the troth:eek:
4. why did you add discard? doesn't android automaticlly trim partitions?
 

elnahir

Senior Member
Jan 24, 2012
121
9
Sofia
OMG

At first when I tried this I wasn't expecting this great deal of performance just by a file system change but boy was I wrong

The benchmark aren't higher but the the system performance is quite noticeable when using


This combines with FSync Off and nexus 7 will be flying

Do you mind sharing your results.. perhaps with a youtube video? I'm highly interested in trying _anything_ that might speed up my 2012 Nexus 7.
 
  • Like
Reactions: alifa

qu3becker

Senior Member
Sep 15, 2011
617
344
Laval
Next logical step is formatting system in F2FS format and see if its worth it.

Sent from my Nexus 4 using Tapatalk
 

SkOrPn

Senior Member
Jun 3, 2007
2,994
948
Albuquerque, NM
www.planetamd64.com
Can fstab be copied from a ROM that is already using f2fs to a rom that is not using f2fs? Or is this something that needs to be coded properly and built normally on a linux machine?

I just want to have /data formatted to f2fs (maybe even /cache). My /data partition is already f2fs, but the ROM I want does not support it, so I am sure it would not boot until I can modify fstab.
 

HypoTurtle

Senior Member
May 5, 2011
1,970
1,257
Can fstab be copied from a ROM that is already using f2fs to a rom that is not using f2fs? Or is this something that needs to be coded properly and built normally on a linux machine?

I just want to have /data formatted to f2fs (maybe even /cache). My /data partition is already f2fs, but the ROM I want does not support it, so I am sure it would not boot until I can modify fstab.

fstab is part of the ramdisk in the boot.img. You would need the fstab file and a f2fs supported kernel for it to work with the other rom. Have you tried just flashing the boot.img-f2fs from OP?
 

SkOrPn

Senior Member
Jun 3, 2007
2,994
948
Albuquerque, NM
www.planetamd64.com
fstab is part of the ramdisk in the boot.img. You would need the fstab file and a f2fs supported kernel for it to work with the other rom. Have you tried just flashing the boot.img-f2fs from OP?

Um no I haven't. I did try and use osmosis's kitchen and I swaped the fstab for the correct one. I was going to just edit it with my favorite notepad program but decided I wasn't sure I'd get it right.

It did not work. Not sure why.

Sent from my Nexus 7 using Tapatalk
 

Top Liked Posts

  • There are no posts matching your filters.
  • 36
    Back story:
    I bought a Moto X during the $100 off promotion and while I was waiting for it to be delivered, I read reviews and poked around online for interesting things about the phone. As an 8GB Nexus 7 owner, the one thing that caught my eye the most was this section of the Anandtech review discussing internal storage performance. Considering how badly my N7's storage performance degraded and how unbearably slow it has become, I felt like it could make good use of this "flash friendly file system." Some Googling revealed that the F2FS driver was developed by Samsung and actually contributed to the official kernel, where it was implemented somewhere around 3.8. I've done some development for an HTC phone in the past, but never for the Nexus 7, so I went and researched the kernel. Because Google's Tegra 3 kernel is based on 3.1, I had to start working on backporting the driver, when I discovered this repository of backports for F2FS. It provides patches for 3.0 and 3.2, but not for 3.1, so I manually applied appropriate changes from each. When I flashed the kernel and booted, it seemed to work, so I went ahead and injected the kernel into the latest TWRP image as well. I also modified the fstab for both the recovery and ROM and compiled Cyanogenmod's f2fs-tools for Android and statically linked them before injecting them into TWRP as well. I then booted into recovery, formatted /data (TWRP knew to use mkfs.f2fs), and booted back into Android. Success, it worked! I've been using my Nexus 7 like this since Friday evening and it's been so much more usable. Not perfectly "like-new" smooth, but it doesn't hang as often or as long.


    I haven't seen anyone actually try this yet so I'm hoping my effort will be able to make a difference for N7 owners fed up with slow performance. Switching to f2fs is as easy as flashing a modified kernel and recovery, then doing a factory reset. Also, any interested developer is more than welcome to use anything I post here.

    Basically, I took the official Tegra 3 kernel and did this:

    KERNEL PATCH

    Then modified the stock ROM's fstab like this:

    FSTAB

    Then I gave TWRP statically-linked f2fs-tools binaries:

    F2FS-TOOLS

    Then I reformatted /data and away it went:

    SzDwaAi.png


    I'm going to reboot into Linux and attach my boot/TWRP images for you guys to test out. Until then, I'd love to have some feedback.
    • What do you think about using f2fs on the Nexus 7?
    • Is it worth it?
    • What kind of impact on performance or battery life do you think this will have?
    • Did I do something seriously wrong with my kernel/fstab?
    • Am I absolutely insane and dangerous to everyone's Nexus 7 tablets and their puppies?

    Image Downloads
    Android File Host | Google Drive

    Instructions:
    WARNING: This process obviously will wipe your data. Make a NANDroid backup beforehand and save it to your computer. While I personally use this, I take no responsibility for damage done to your device.
    1. Flash boot and recovery like usual:
      Code:
      $ fastboot flash boot boot-F2FS.img
      $ fastboot flash recovery openrecovery-twrp-2.6.3.1-grouper-F2FS.img
    2. Format Data in TWRP
    3. Reboot
    4. Done!
    Note that these are for the latest official 4.4.2 build KOT49H.

    Let me know how your performance and battery life change after applying this. Storage performance should noticeably increase and battery life change should be negligible.
    4
    f2fs implementation on the note2 and s3 on all partitions: kernel & recovery and a compatible rom for the s3...perhaps you might get some help from those devs. using it on my s3 and the performance has been great. not entirely sold on benchmarks but on ext4 i was getting 14-15k on antutu. w/ f2fs on the same cpu/gpu speeds, i'm getting 18-19k. HTH

    would really like to see this implementation on our beloved n7

    Using it on all partitions is very trivial and doesn't need any more kernel modifications. I just limited it to /data/ because that's what Motorola did and it seems to work very well for them. I also didn't know whether or not it would cause any problems in the long run.
    3
    f2fs implementation on the note2 and s3 on all partitions: kernel & recovery and a compatible rom for the s3...perhaps you might get some help from those devs. using it on my s3 and the performance has been great. not entirely sold on benchmarks but on ext4 i was getting 14-15k on antutu. w/ f2fs on the same cpu/gpu speeds, i'm getting 18-19k. HTH

    would really like to see this implementation on our beloved n7
    2
    So, to make a rom ALL-f2fs compatible, we just have to change /system and /data partitions format on fstab.grouper from ext4 to f2fs? Off course, on a device with already modified twrp recovery with f2fs tools....
    Would interest me as well...

    Well, there is more to that.
    First, you have to have a kernel with the driver for F2FS compiled in. Next, you need to edit the fstab.grouper and change the format of /system, /cache and /data to F2FS. And then, in some cases, you need to modify the updater-script of the ROM so it won't format /system during the install as EXT4, but rather as F2FS.
    The last thing is the reason I'm still on Data-F2FS instead of ALL-F2FS. I can still update my ROM via CMUpdater and then just install the kernel again, no need to unzip, change the updater-script and then zip again.
    2
    Newest TWRP doesnt need any hack, just add TARGET_USERIMAGES_USE_F2FS := true
    I used your patch on cm11's kernel, working flawlessly, thanks!