FORUMS
Remove All Ads from XDA

[TUTORIAL] Migrate filesystem to F2FS

1,078 posts
Thanks Meter: 5,476
 
By mickybart, Senior Member on 16th January 2015, 08:46 PM
Post Reply Email Thread
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
The Following 45 Users Say Thank You to mickybart For This Useful Post: [ View ] Gift mickybart Ad-Free
 
 
16th January 2015, 09:37 PM |#2  
Senior Member
Thanks Meter: 69
 
More
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?)
16th January 2015, 09:50 PM |#3  
OP Senior Member
Flag Montreal
Thanks Meter: 5,476
 
Donate to Me
More
Quote:
Originally Posted by A6ekAK

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.
The Following 4 Users Say Thank You to mickybart For This Useful Post: [ View ] Gift mickybart Ad-Free
16th January 2015, 10:13 PM |#4  
Senior Member
Thanks Meter: 69
 
More
Thanks for clarification
16th January 2015, 10:15 PM |#5  
darknessmc's Avatar
Senior Member
Thanks Meter: 118
 
More
Thanks for this tut. Put it in Sony Cross-Device General
17th January 2015, 08:44 PM |#6  
Senior Member
Flag Nilai
Thanks Meter: 236
 
More
Deleted
18th January 2015, 06:39 PM |#7  
Senior Member
Flag ERBIL
Thanks Meter: 97
 
More
Sorry for the noob question but what's the benefit from doing this?
19th January 2015, 05:50 PM |#8  
OP Senior Member
Flag Montreal
Thanks Meter: 5,476
 
Donate to Me
More
Quote:
Originally Posted by zaidx

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

f2fs is faster when you have to write on a SD card for example. This is a filesystem build for this kind of storage in mind.

https://en.wikipedia.org/wiki/F2FS
The Following 2 Users Say Thank You to mickybart For This Useful Post: [ View ] Gift mickybart Ad-Free
19th January 2015, 09:40 PM |#9  
Member
Flag Paris
Thanks Meter: 6
 
More
Hi,
What about to convert sdcard (Intenal Storage) to f2fs as well ?
Christophe
19th January 2015, 11:30 PM |#10  
vayavalla's Avatar
Senior Member
Thanks Meter: 229
 
More
I'm not able to convert the partitions

For those who have tried: is there any improvement?
20th January 2015, 08:55 PM |#11  
Member
Flag Skopje
Thanks Meter: 19
 
More
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?

Quote:
Originally Posted by zaidx

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

You can check this post for benefits :
http://forum.xda-developers.com/show....php?t=2697069
The Following User Says Thank You to zhackary For This Useful Post: [ View ] Gift zhackary Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes