yashsingh1/xdaforums huggingface dataset:
[Nexus 5 Original Android Development] dechronic:
Just to clarify a misconception about ElementalX. It does support F2FS without any modification. However, since ElementalX, like a handful of other kernels, do not have a pre-existing ramdisk. It modifies the ramdisk of the currently installed kernel. How do I know?

Excerpt from the updater-script of ElementalX 2.10

ui_print("Customizing ramdisk");
run_program("/tmp/busybox", "dd", "if=/dev/block/platform/msm_sdcc.1/by-name/boot", "of=/tmp/boot.img");
run_program("/tmp/unpackbootimg", "-i", "/tmp/boot.img", "-o", "/tmp/");
run_program("/tmp/cmdline.sh");
run_program("/tmp/editramdisk.sh");
run_program("/tmp/makebootimg.sh");
ui_print("Installing Kernel");
run_program("/tmp/busybox", "dd", "if=/tmp/newboot.img", "of=/dev/block/platform/msm_sdcc.1/by-name/boot");

In summary, what was done in the above script was to:

backup the kernel to /tmp/boot.img

extract the contents of it to /tmp

edits certain files in the ramdisk (editramdisk.sh, see below), with it's own entries

creates the kernel using the ElementalX image and the modified ramdisk of the previous kernel Installs on the phone.

The contents of the editramdisk.sh file

#!/sbin/sh

mkdir /tmp/ramdisk
cp /tmp/boot.img-ramdisk.gz /tmp/ramdisk/
cd /tmp/ramdisk/
gunzip -c /tmp/ramdisk/boot.img-ramdisk.gz | cpio -i
rm /tmp/ramdisk/boot.img-ramdisk.gz
rm /tmp/boot.img-ramdisk.gz

#Start elementalx script
if [ $(grep -c "import /init.elementalx.rc" /tmp/ramdisk/init.rc) == 0 ]; then
sed -i "/import \/init\.trace\.rc/aimport /init.elementalx.rc" /tmp/ramdisk/init.rc
fi

#copy elementalx scripts
cp /tmp/elementalx.sh /tmp/ramdisk/sbin/elementalx.sh
chmod 755 /tmp/ramdisk/sbin/elementalx.sh
cp /tmp/init.elementalx.rc /tmp/ramdisk/init.elementalx.rc

if [ $(grep -c "seclabel u:r:install_recovery:s0" /tmp/ramdisk/init.rc) == 0 ]; then
sed -i "s/seclabel u:r:install_recovery:s0/#seclabel u:r:install_recovery:s0/" /tmp/ramdisk/init.rc
fi

if ! grep -qr init.d /tmp/ramdisk/*; then
echo "" >> /tmp/ramdisk/init.rc
echo "service userinit /system/xbin/busybox run-parts /system/etc/init.d" >> /tmp/ramdisk/init.rc
echo " oneshot" >> /tmp/ramdisk/init.rc
echo " class late_start" >> /tmp/ramdisk/init.rc
echo " user root" >> /tmp/ramdisk/init.rc
echo " group root" >> /tmp/ramdisk/init.rc
fi

echo "xprivacy453 u:object_r:system_server_service:s0\n" >> /tmp/service_contexts

cp /tmp/hammerhead.rc /tmp/ramdisk/init.hammerhead.rc

find . | cpio -o -H newc | gzip > /tmp/boot.img-ramdisk.gz
rm -r /tmp/ramdisk

So in short. You can use a kernel with f2fs entries already inserted, recommended for use with custom ROMs with their own custom kernels with f2fs entries, however it may not always work as certain custom scripts installed from a custom kernel may conflict with the ElementalX kernel.

Recommended method for Stock ROM: Use one of the dummy stock kernels I created with the F2FS entries in the ramdisk.
[Nexus 5 Original Android Development] nunojsa:
Thank you for your excellent explanation. Just a final question/curiosity, what would happen if i just format my storage partition(/data for example) to f2fs and then try to boot with a kernel without f2fs support and without the ramdisk entries? It simply wouldn't boot or would brick the device or it would change back the storage partition format?

Thank you in advance!!
[Nexus 5 Original Android Development] desalesouche:
F2FS and LVM

hi i would like to know if someone is aware of the use of lvm and F2FS.

the problem i have is that whatever i do about system and f2fs change in fstab.qcom and fstab.lvm device boots with system in ext4 instead F2fs.

here is link device tree :https://github.com/Blefish/android_device_huawei_msm7x30-common/tree/cm-12.0/lvm

https://github.com/Blefish/android_device_huawei_msm7x30-common/tree/cm-12.0/rootdir

some may reply me that thread is for nexus 5, i am not aware of another good thread about f2fs like that one...

thank you all.
[Nexus 5 Original Android Development] dechronic:
If you formatted the /data to f2fs with a kernel that does not support f2fs, when it boots the ROM, it will ask you for a password to unencrypt the phone as it incorrectly assumes that it can't read the /data partition because it is encrypted. A reboot can still be done into the bootloader, by holding the power button for 10 seconds until the screen goes blank, release it and then hold the down volume button to boot back into your favourtie custom recovery to repair/change it.

See this post for common problems when trying to use f2fs for the first time -> http://xdaforums.com/showpost.php?p=57615686&postcount=588

---------- Post added at 07:14 AM ---------- Previous post was at 07:07 AM ----------

1. Are you sure you are using a kernel that supports f2fs? Just changing the ramdisk entries of any kernel alone will not work if the kernel image isn't built with f2fs tools.

For example see this particular github repository for ElementalX kernel -> https://github.com/flar2/ElementalX-N5/tree/ElementalX-2.00/fs/f2fs

2. The ramdisk entries for the Nexus 5 are specific to the Qualcomm chipset mount points, etc.

For example, my wife's Nexus 7 2012 uses these entries as it has a Tegra 3 chipset

# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK

/dev/block/platform/sdhci-tegra.3/by-name/APP /system f2fs noatime,nosuid,nodev,discard,nodiratime,inline_xattr,errors=recover wait
/dev/block/platform/sdhci-tegra.3/by-name/CAC /cache f2fs noatime,nosuid,nodev,discard,nodiratime,inline_xattr,errors=recover wait,check
/dev/block/platform/sdhci-tegra.3/by-name/UDA /data f2fs noatime,nosuid,nodev,discard,nodiratime,inline_xattr,flush_merge,errors=recover wait,nonremovable,encryptable=/dev/block/platform/sdhci-tegra.3/by-name/MDA
/dev/block/platform/sdhci-tegra.3/by-name/MSC /misc emmc defaults defaults
/dev/block/platform/sdhci-tegra.3/by-name/LNX /boot emmc defaults defaults
/dev/block/platform/sdhci-tegra.3/by-name/SOS /recovery emmc defaults defaults
/dev/block/platform/sdhci-tegra.3/by-name/USP /staging emmc defaults defaults

/devices/platform/tegra-ehci auto vfat defaults voldmanaged=usbdisk:auto
[Nexus 5 Original Android Development] desalesouche:
[MENTION=5594433]dechronic[/MENTION]

yes kernel sis suppporting F2FS : https://github.com/Blefish/android_...mmit/14367c5b8d2a15ebc395cc18799600ac97ee93b1

here is change i did to get data and F2fS working.

fstab.qcom http://pastebin.com/aCtxNzKa

fstab.qcom.lvm http://pastebin.com/2hrDWaB7

any change i do about system and f2fs lead me to a booting rom with data= F2FS but system remain in ext4? :rolleyes:

twrp got F2Fs support...
[Nexus 5 Original Android Development] davidshen84:
Hi dennse544,

Does this kernel compatible with all CM version for Nexus 5? I am confused. I think one kernel can only work with one ROM.

Thanks,

David
[Nexus 5 Original Android Development] francescobabbaro:
Hi guys, sorry, but this is the first time I read about F2FS, and I would change my formattation to this one. I have searched, but I haven't found anything, and I ask to you:

1) The OP guide is usable with lollipop?

2) Which kernel should I use?

3) Could I come back to EXT4 if I would?

Thanks a lot, and sorry again for these stupid questions.
[Nexus 5 Original Android Development] Pretoriano80:
First make sure you have latest official TWRP installed, it supports F2FS by default.

Then on the previous page you can find an explanation on how to start using F2FS (by dechronic).

You can switch back to EXT 4 anytime but make sure you backup your data first because the internal partition will be completely wiped.
[Nexus 5 Original Android Development] francescobabbaro:
Ah, thanks. A final question, more in general: I have to format in F2FS /system too, to have a better result? Or /data and /cache are enough? Thanks a lot.
[Nexus 5 Original Android Development] dechronic:
I have been told and seen test scores that show that there is no real advantage to changing the /system partition to f2fs as it used only for reading and not writing too. All the writing is usually done on the /cache and /data partitions. In addition, if you do change to the /system to f2fs you may find out like I did that the stock Lollipop rom will no longer fit on the partition, only custom roms with smaller than full GApps package.
[Nexus 5 Original Android Development] davidshen84:
I have a Nexus 5, oem unlocked.

I flashed the latest TWRP: http://techerrata.com/file/twrp2/hammerhead/openrecovery-twrp-2.8.5.2-hammerhead.img

Wipe data, and format both system and data to F2FS

And flashed CM nightly: cm-12-20150302-NIGHTLY-hammerhead.zip

Then I flashed you CM_F2FS.zip

Reboot the system...

My phone will show the Google logo, then reboot into recovery boot...can you help?

Thanks,

David

---------- Post added at 02:18 PM ---------- Previous post was at 01:36 PM ----------

This is odd...when doing sidelide, I saw this:

detected filesystem f2fs .../by-name/system

(after some time)

detected filesystem ext4 .../by-name/system

So installing CM will automatically format /system to ext4. Is it correct? I read some other post, and I think /system should also be f2fs.

Thanks,

David
[Nexus 5 Original Android Development] dechronic:
I used to format my /system to f2fs when the OS could still fit with all the GApps. However some further reading and seeing test results there is no noticeable improvement to a read only partition like /system so it is not necessary but a preference to convert it to f2fs and only if your OS and system apps have the available space.

Most, if not all custom ROMs usually format the /system partition to their desired file system for the particular device. For the Nexus 5 it is EXT4. To get around that the procedure was to edit the updater-script to format the partition(s) to f2fs and to mount them with busybox so the files could placed in the relevant partitions. However, while using a ROM (Beanstalk) based on CM12 that didn't always work because on the first boot the /cache partition was formatted as EXT4 which caused crashes on first boot.

To get around that I left all partitions as EXT4 for the first or until everything was setup the way I wanted and then made a Nandroid backup, copied it to my PC, formatted the /data and / cache partitions to f2fs, copied back the nandroid backup to the SD card and restore everything, which just gave a warning from TWRP that the previous data was from a EXT4 partition.

It will then boot and run normally without crashes.

Note: For f2fs is recommended that the /data and /cache partitions be formatted as f2fs as f2fs speed improvements are seen with writing, exactly what those two partitions do a lot of.
[Nexus 5 Original Android Development] davidshen84:
Hi dechronic,

Thanks, but my real problem is that my system won't boot if any partition is F2FS format. I tried a lot situations, and here's what I got:

- format /data to f2fs

- format /cache to f2fs

- install official CM 12

- DO NOT install CM_F2FS.zip

- **system boot to CM logo and stay forever**

- format /data to f2fs

- format /cache to EXT4

- install official CM 12

- DO NOT install CM_F2FS.zip

- **system boot and ask me for password**, according to what internet says, it is because it cannot read /data and think it is encrypted

- format /data to f2fs

- format /cache to EXT4

- install official CM 12

- install CM_F2FS.zip

- **system auto reboot to recovery**

What am I missing?

Thanks,

David
[Nexus 5 Original Android Development] cocchiararo:
Am i blind, or you skipped the correct way (format both to f2fs, install ROM and the f2fs stuff, check partitions are still f2fs, reboot.

Nexus 5 - Tapatalk
[Nexus 5 Original Android Development] dechronic:
Situation 1. No kernel with F2FS support installed.

Situation 2. No kernel with F2FS support installed.

Situation 3. Kernel with F2FS for Android 4.4 and probably cache needs to be f2fs too.

You are missing using a kernel with f2fs support for the correct Android version and the correct entries in the ramdisk.

I have downloaded the lastest CM12 nightly and looked at the updater script. It mounts both the /system and /data during installation (and most likely for the first boot)

To use CM12 with f2fs you need to:

Download the attachement from this post

Download Stock/AOSP (Android 5.0.1/5.0.2) ElementalX-N5-2.10 from here -> http://elementalx.org/devices/nexus-5/ (Yes it works with CM12 as it is still AOSP)

Thread for ElementalX (linked for info/credit purposes)

Format everything to EXT4 first.

Install the CM12 ROM.

Completely boot the ROM at least once. Make any changes and apply any settings if you wish.

Reboot to TWRP recovery.

Make a Nandroid Backup of the /system and /data partitions (/system is not needed but in case you mess up something you won't have to do Steps 3 -5 again)

Move the Nandroid Backup to your PC.

Format the /data and /cache partitions to f2fs

Copy the Nandroid backup from the computer back to the same TWRP folders (make a Nandroid backup of the boot parition if necessary to recreate the folders)

Restore the /data partition from the backup. You should get a warning that the backup was originally from an EXT4 partition.

Double check that the /data and /cache partitions are sitll f2fs in the Wipe -> Advanced Wipe -> Select Partition -> FS Options -> Current File System

If /data and /cache are still f2fs, sideload the Stock_f2fs_cache+data.zip (a dummy kernel with f2fs entries, necessary for ElementalX kernel). Do NOT reboot the phone yet.

Immediately sideload the ElementalX kernel and follow the Aroma installer to setup the kernel to your liking.

Finally, reboot the phone and it should boot into CM12 with the /data and /cache as f2fs.
[Nexus 5 Original Android Development] davidshen84:
Thanks dechronic,

I followed your steps and made good progress...but still can not get a working system.

First, I followed exactly your steps. The system booted, but I constantly got this "System UI" stopped error.

Then I tried with a clean /data. This time I got "Setup Wizard" stopped error...

Either way, the system can boot, but some basic apps won't work. Any suggestions?

Thanks,

David
[Nexus 5 Original Android Development] dechronic:
When I used Beanstalk which is based on CyanogenMod I had similar issues. That's why I suggested that lengthy procedure.

I am trying to remember which order I installed the GApps in. I think I booted into the OS for the first time then rebooted to recovery and installed the GApps. Booted to OS and then when I knew everything was working as it should, I did a nandroid backup moved to PC, formatted to f2fs, etc., etc.
[Nexus 5 Original Android Development] davidshen84:
ahhh~the order matters? ok, that's complicate. why can't CM just support f2fs by default...thanks a lot. I will try figure out the magic order.
[Nexus 5 Original Android Development] dechronic:
The attachement in this post has an unbootable stock 5.1 kernel with f2fs entries in the ramdisk for data + cache for use with ElementalX 2.11 (Android 5.1) for those that use f2fs.
[Nexus 5 Original Android Development] Dodgexander:
Is this dummy kernel solely for elemental x? Is it possible to add f2fs support to any kernel?

I'm using PA 5 currently and have to choose between Franco (to use themes) and a f2fs specific kernel like uber (to use f2fs). Sadly its one or the other, not both. Asfaik no f2fs kernel currently support the theme engine in aosp ROMs.
[Nexus 5 Original Android Development] dechronic:
It will work for UBER too as it uses the ramdisk of the previous kernel last time I checked. It has been a month or two since I did.

Either way. Backup your current kernel in TWRP before trying so that if you have any issues you can revert back to your backup.
[Nexus 5 Original Android Development] Dodgexander:
Thanks. UBER is working fine with f2fs already, I am hoping to find a kernel with both cm12 theme engine support in aosp and with f2fs support.
[Nexus 5 Original Android Development] Mohamed Yaser:
Can any one simply Tell me what advantage of F2FS
[Nexus 5 Original Android Development] Wakamatsu:
In the simplest terms, faster read/write than ext4.
[Nexus 5 Original Android Development] Xami:
No F2FS Franco r74 :'(
[Nexus 5 Original Android Development] garynych:
by simple:

F2FS actually is an improvement over Ext4 for flash devices

faster speed (browsing and typing. All what does the average user) & extends the life of the flash memory HAND
[Nexus 5 Original Android Development] jbowwow02:
I tried this with Euphoria and I keep getting System UI has stopped. Any ideas on what might be the problem?
[Nexus 5 Original Android Development] dechronic:
Connect the phone to a computer and using a terminal emulator/command prompt on the computer run the following command in the same directory as adb:

adb shell "mount|grep f2fs|grep -oe /userdata -oe /system -oe /cache"

OR

Via a terminal emulator app on the phone run:

mount|grep f2fs|grep -oe /data -oe /system -oe /cache

You should get the result:

/data

/cache

(/cache may appear twice)

If /cache or /data is missing it means that the missing one is not formatted as f2fs.

It could be the /cache partition.
[Nexus 5 Original Android Development] Wh1t3Rose:
Anybody found a 5.1.1 dummy kernel yet? Trying to flash Chroma (5.1.1) and get system FC using a 5.1 dummy kernel and Elemental X. And yes both Data and Cache are F2FS
[Nexus 5 Original Android Development] Wakamatsu:
Try here:

https://basketbuild.com/devs/Cl3Kener/HAMMERHEAD/F2FS

Some of these are deprecated. I can't remember which one is the latest as Cl3Kener's rom includes a working F2FS ramdisk so I don't have to flash a ramdisk prior to flashing a kernel. Extracting it from his Optipop rom might be another avenue.

EDIT - the kernels in the above folders may not work with the latest up-to-date ROMs. Quite likely, they won't
[Nexus 5 Original Android Development] Wh1t3Rose:
Those are 5.1. I need 5.1.1. Thanks though!
[Nexus 5 Original Android Development] Wakamatsu:
His roms and kernels are 5.1.1. At least some of those should work.
[Nexus 5 Original Android Development] Wh1t3Rose:
And the kernel has an F2FS ramdisk? Hence no need for a F2FS dummy kernel like Elemental X requires? I'll give it a shot.

---------- Post added at 12:12 AM ---------- Previous post was at 12:06 AM ----------

What makes you think these are 5.1.1? I only see 5.1
[Nexus 5 Original Android Development] Wakamatsu:
I'll play around with a few things and give you a more definitive answer but it will have to be a little bit later.
[Nexus 5 Original Android Development] Wh1t3Rose:
Well I just tried and while it did boot NFC service kept force closing making the ROM unusable.
[Nexus 5 Original Android Development] Wakamatsu:
I tried some things and got the similar. You *may* have better luck extracting the boot.img from the latest optipop but that could also be hit or miss.
[Nexus 5 Original Android Development] milestone2mod:
Alright guys,

after some months of ext4, I decided to go back to f2fs. But it doesn´t seem to work, and I don´t know whose (ROM, Kernel, Recovery, me?) fault it is:

I tried to convert data and cache as follows:

1. Flashed the stock 5.1 image to have a clean base

2. rooted and installed latest TWRP (2.8.6.1)

3. went to recovery, factory reset, then converted data and cache to f2fs via the advanced wipe menu

4. reboot recovery

5. back in recovery again, went to asvanced wipe and checked, data and cache was indeed f2fs

6. connected my Nexus 5 to my computer, copied ROM and Kernel to it and flashed them.

7. rebooted device, set the rom up

8. rebooted to recovery (after setting up everything)

9. in recovery I went to advanced wipe and then to cache and data, and tadaa, file system was stated as ext4.

Is this just a displaying problem in TWRP (data/cache are f2fs, but TWRP displays it wrong?) or did the converting process fail/was reverted? I tried several ROMS (CleanCore, Chroma, Optipop) and Kernels (CodeBlue and Uber), but the result was always the same.
[Nexus 5 Original Android Development] killer23d:
Try twrp 2.5.x.x. I think since, 2.6, it has bugs
[Nexus 5 Original Android Development] milestone2mod:
So you mean 2.8.5.3?
[Nexus 5 Original Android Development] cocchiararo:
The thing is, rom zip's nowadays flash a .dat or .img that carries the partition format and data, so flashing the zip converts it.

A possible workarround might be to flash the rom, perform a nandroid backup of cache and data (or data only, cache does not matter), copy it to pc, convert partitions, rename the backup files from ext4 to f2fs, copy them back, and restore the data.
[Nexus 5 Original Android Development] milestone2mod:
Did that, also tried with TWRP 2.8.5.2, but data and cache are still changing again to ext4. Im near absolute distress....
[Nexus 5 Original Android Development] cocchiararo:
at what point do they change?

I mean, if you flash the rom, it is logical for them to change (the .zip formats them).

Now, if you flash no more zips, and do as i say, WHEN do they change?

Restoring the nandroid (correctly renamed) changes nothing, and if it is incorrectly renamed, it will complain.
[Nexus 5 Original Android Development] milestone2mod:
I did as you said:

1. factory image (clean base)

2. root & TWRP

3. flashed Chroma Rom, Gapps and CodeBlue

4. made a nadroid backup

5. copied backup to PC, renamed "ext4" in data/cache-backup names to f2fs (also the md5 files)

6. converted data/cache to f2fs in recovery, reboot recovery

7. copied backup files back to the phone, restored cache and data

8. reboot the system

9. after setup of Google account etc. I rebooted to recovery again, and now cache and data were labelled as ext4 in the advanced wipe section.

What am I doing wrong? Is there a guide I can follow, so that it just works (also with the newer .dat or .img files you mentioned)?
[Nexus 5 Original Android Development] cocchiararo:
I would repeat the process, double checking that the format remains F2FS after each step.

Also, do you have f2fs support in your kernel? If so, it might need to be flashed after the partitions are already f2fs (if not, you need to add support).
[Nexus 5 Original Android Development] milestone2mod:
Did the double chek after every step, It´s changing when I first boot up the ROM and then go back to recovery.

I thought CodeBlue had support for cache and data on f2fs.

So how should I try it? Flash CodeBlue again after I restored the backup? I already did that, doesn´t keep t from changing back to ext4 after first bootup....
[Nexus 5 Original Android Development] cocchiararo:
mm, then i would:

1. factory image (clean base)

2. root & TWRP

3. flashed Chroma Rom, Gapps and CodeBlue

3.a boot rom, configure first boot setup

3.b reboot recovery

3.c wipe caches

4. nadroid backup (/data only)

5. copy backup to PC, renamed "ext4" in data-backup name to f2fs (also the md5 files)

6. converted data/cache to f2fs in recovery, reboot recovery

6.a check it is still F2FS

6.b flash codeblue again

7. copy backup files back to the phone, restore data

7.a check it is still F2FS

7.b reboot recovery and re-check /data and /cache are still F2FS

8. reboot the system

9. after setup of Google account etc. I rebooted to recovery again, and now cache and data were labelled as ext4 in the advanced wipe section.

If that still fails, either your rom, kernel, of the gods, wont do F2FS :P
[Nexus 5 Original Android Development] milestone2mod:
Thank you for your help and quick answers! I will try that, should I use a specific version of TWRP? like 2.8.5.2 (.3 doesn´t allow MTP) or 2.8.6.0/.1 or some other version? Some seem to be buggy/not correctly working. I just want to avoid another hour of f&f (flash and frustrate)
[Nexus 5 Original Android Development] cocchiararo:
no idea really, i always use the latest i can find, unless i see/hear it has issues.

i am on 2.8.6.1 now, trying cm12.1 caf,without f2fs for now.
[Nexus 5 Original Android Development] milestone2mod:
Alright, and what do I do, when I wnat to update the ROM? I remember when i tried f2fs the first time (with 5.0), I flashed the ROM update, then a dummy kernel (boot cache&date f2fs), and then CodeBlue.