juppiter89
Posts: 91
Joined: Fri Jan 04, 2013 10:50 pm

[HOWTO] F2FS

Fri Jun 21, 2013 4:42 pm

You probably already have heard of f2fs, the new file system designed by Samsung, thanks to specific allocation and wear leveling algorithms, improves the performance and durability of flash memories (also SD cards).
Here a "short" guide on the setup of a f2fs partition on Raspberry PI (just change the commands if necessary in the case of other distribution or different sdX etc.).

Prerequisite: to have a PC with Linux OS (lol)

- Install on the PC at least a kernel of version 3.8 (f2fs is only supported by 3.8 and later) and make sure it is compiled with support for f2fs (in case it should be compiled from source code)

- Compile and install the kernel 3.8 on Raspberry, also with support f2fs (included in the kernel and not as a separate module!) For instructions refer you to http://elinux.org/RPi_Kernel_Compilation (I highly recommend the Cross-compiling to save A LOT OF time). Therefore, make sure that the Raspberry start up properly with the new kernel.
EDIT: there is already a precompiled 3.8 kernel with f2fs support (thanks to portets)

Code: Select all

sudo rpi-update 2c4e92c01ff14d8f3e1ee35b995d430b4e6d1e1b
- Insert the SD card into the PC and maintain a backup of your entire root partition of the SD:

Code: Select all

sudo cp -a /mnt/* ~/backup_sd
where /mnt is the path where you mounted the root of the SD (the -a option is IMPORTANT)

- Install the f2fs-tools package on the PC:

Code: Select all

sudo apt-get install f2fs-tools
- Format the root partition of the SD in f2fs (you can also use gparted 0.16 version or later):

Code: Select all

sudo mkfs.f2fs /dev/sdb2
- Ubuntu (and I imagine any other distribution) does not yet support auto-mount f2fs partitions, then:

Code: Select all

sudo mount -t f2fs /dev/sdb2 /mnt
- Re-copy the entire contents of the backup on that partition:

Code: Select all

sudo cp -a ~/backup_sd/* /mnt
- Edit the /etc/fstab file in the root of the SD. The row corresponding to / should be like this:

Code: Select all

/dev/mmcblk0p2   /    f2fs defaults,noatime,discard 0 0
- Lastly, modify the cmdline.txt file in the boot partition of the SD:

Code: Select all

rootfstype=ext4
must become

Code: Select all

rootfstype=f2fs
- Remove all:

Code: Select all

sudo umount /mnt
- Enjoy (I hope I did not forget some step :))

Obviously I do not take any responsibility in case of damage (however very unlikely unless of human carelessness in the execution of all the steps).

The process is quite elaborate and not exactly proof beginner, but it's worth it. Let me know the results :)
Last edited by juppiter89 on Fri Jun 21, 2013 10:16 pm, edited 2 times in total.

portets
Posts: 186
Joined: Sat Oct 29, 2011 6:24 am

Re: [HOWTO] F2FS

Fri Jun 21, 2013 8:02 pm

Doesn't the latest kernel(3.9) on github already have f2fs support compiled in?

juppiter89
Posts: 91
Joined: Fri Jan 04, 2013 10:50 pm

Re: [HOWTO] F2FS

Fri Jun 21, 2013 8:28 pm

portets wrote:Doesn't the latest kernel(3.9) on github already have f2fs support compiled in?
Well, from github you can only get the kernel sources, you have to check through "make menuconfig" that f2fs support is enabled, than compile the kernel. And yes, of course, kernel 3.9 supports f2fs aswell.

If you mean kernel binary, already compiled, I don' know if it's compiled with f2fs support; you could try with the following steps to format with f2fs filesystem, if they don't work you have to build the kernel yourself, sorry :)

portets
Posts: 186
Joined: Sat Oct 29, 2011 6:24 am

Re: [HOWTO] F2FS

Fri Jun 21, 2013 9:28 pm

The pre-compiled kernel on github has had f2fs support since 3.8.4. http://www.raspberrypi.org/phpBB3/viewt ... 12#p327312

I've been meaning to try this out. My flash drive I use for my pi formatted with f2fs is 10% faster in every test, except random writes are 2-20x faster. This was tested on my Ubuntu machine. Have yet to try on the Pi, but will soon thanks to your guide :D

juppiter89
Posts: 91
Joined: Fri Jan 04, 2013 10:50 pm

Re: [HOWTO] F2FS

Fri Jun 21, 2013 9:35 pm

Ah well, there is already a precomplied 3.8 kernel! Good, I did not know that :)
I have not actually done any benchmarks, but my Pi with f2fs is now visibly much faster :D. I hope my guide is useful for you and many others. Let me know your results!

inseooh
Posts: 9
Joined: Sun Aug 18, 2013 12:40 am

Re: [HOWTO] F2FS

Tue Aug 20, 2013 10:38 am

Restoring back to SD card takes for a long time...?
It looks like stopped on first file :-(
like this...
root@ubuntu:/home/inseooh# cp -av /home/inseooh/Desktop/piroot/* /mnt
‘/home/inseooh/Desktop/piroot/bin/domainname’ -> ‘/mnt/bin/domainname’

What can I do?

inseooh
Posts: 9
Joined: Sun Aug 18, 2013 12:40 am

Re: [HOWTO] F2FS

Tue Aug 20, 2013 1:59 pm

It was because of my virtual machine :-(
I installed ubuntu 13.04 on my PC, and a lot of try...
SUCCESS!!!!!!!!!!!

pilango
Posts: 2
Joined: Fri Apr 04, 2014 7:14 pm

Re: [HOWTO] F2FS

Fri Apr 04, 2014 7:33 pm

Being curious about f2fs I've just tried your howto on transfering the root partition to f2fs. Thanks for the detailed tutorial!

It all seemed to work fine, but since the transfer my pi stops in the early boot sequence with a kernel panic: "not syncing - no init found". As far as I understand (being quite a newbie to linux...) this means it cannot access the /bin-folder in the root partition, correct? Earlier in the boot sequence I can see that the root-partition was mounted correctly ("VFS: mounted root (f2fs fileystem) on device 179:2"). I'm using the latest raspbian image from Jan 2014 (kernel 3.10).

Any suggestion what to try next? Anybody else who had the same issue?
Thanx in advance for your help,
Felix

Tarcas
Posts: 739
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: [HOWTO] F2FS

Sat Apr 05, 2014 1:51 am

pilango wrote:Being curious about f2fs I've just tried your howto on transfering the root partition to f2fs. Thanks for the detailed tutorial!

It all seemed to work fine, but since the transfer my pi stops in the early boot sequence with a kernel panic: "not syncing - no init found". As far as I understand (being quite a newbie to linux...) this means it cannot access the /bin-folder in the root partition, correct? Earlier in the boot sequence I can see that the root-partition was mounted correctly ("VFS: mounted root (f2fs fileystem) on device 179:2"). I'm using the latest raspbian image from Jan 2014 (kernel 3.10).

Any suggestion what to try next? Anybody else who had the same issue?
Thanx in advance for your help,
Felix
In my experience compiling kernels, not being able to find the init is usually because the kernel can't read whatever partition init is on. In my case this was usually from not having some of the required modules compiled in. In your case, it could be any of the steps in the directions missed, unfortunately. You might try mounting the card from another Linux computer just to make sure that the partition is readable. Sorry I can't be more help.

pilango
Posts: 2
Joined: Fri Apr 04, 2014 7:14 pm

Re: [HOWTO] F2FS

Sat Apr 05, 2014 10:45 am

Tarcas wrote:
pilango wrote:Being curious about f2fs I've just tried your howto on transfering the root partition to f2fs. Thanks for the detailed tutorial!

It all seemed to work fine, but since the transfer my pi stops in the early boot sequence with a kernel panic: "not syncing - no init found". As far as I understand (being quite a newbie to linux...) this means it cannot access the /bin-folder in the root partition, correct? Earlier in the boot sequence I can see that the root-partition was mounted correctly ("VFS: mounted root (f2fs fileystem) on device 179:2"). I'm using the latest raspbian image from Jan 2014 (kernel 3.10).

Any suggestion what to try next? Anybody else who had the same issue?
Thanx in advance for your help,
Felix
In my experience compiling kernels, not being able to find the init is usually because the kernel can't read whatever partition init is on. In my case this was usually from not having some of the required modules compiled in. In your case, it could be any of the steps in the directions missed, unfortunately. You might try mounting the card from another Linux computer just to make sure that the partition is readable. Sorry I can't be more help.
Thanks again for your help. The f2fs root partition is readable in ubuntu (after manually mounting it) and all the sys files seem to be ok. After my original post yesterday I mirrored the data to another sd card of exactly the same type, just using ext4 again, and changed back the settings in cmdline.txt and fstab. That worked fine... so that leaves the kernel or an update failure as primary suspect, as you already suggested. I'll try on and post the result or solution if I find one.

Tarcas
Posts: 739
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: [HOWTO] F2FS

Sat Apr 05, 2014 6:58 pm

pilango wrote:
Tarcas wrote:
pilango wrote:Being curious about f2fs I've just tried your howto on transfering the root partition to f2fs. Thanks for the detailed tutorial!

It all seemed to work fine, but since the transfer my pi stops in the early boot sequence with a kernel panic: "not syncing - no init found". As far as I understand (being quite a newbie to linux...) this means it cannot access the /bin-folder in the root partition, correct? Earlier in the boot sequence I can see that the root-partition was mounted correctly ("VFS: mounted root (f2fs fileystem) on device 179:2"). I'm using the latest raspbian image from Jan 2014 (kernel 3.10).

Any suggestion what to try next? Anybody else who had the same issue?
Thanx in advance for your help,
Felix
In my experience compiling kernels, not being able to find the init is usually because the kernel can't read whatever partition init is on. In my case this was usually from not having some of the required modules compiled in. In your case, it could be any of the steps in the directions missed, unfortunately. You might try mounting the card from another Linux computer just to make sure that the partition is readable. Sorry I can't be more help.
Thanks again for your help. The f2fs root partition is readable in ubuntu (after manually mounting it) and all the sys files seem to be ok. After my original post yesterday I mirrored the data to another sd card of exactly the same type, just using ext4 again, and changed back the settings in cmdline.txt and fstab. That worked fine... so that leaves the kernel or an update failure as primary suspect, as you already suggested. I'll try on and post the result or solution if I find one.
I remember seeing that you used a kernel version after the one in the tutorial, but have you verified that support is compiled in? Loadable modules for root filesystems don't always load if it needs to be loaded before it can be read. I would expect that it's included correctly, but it's certainly worth checking, since you've verified that it's readable and consistent.

suicidal_orange
Posts: 217
Joined: Sun Mar 16, 2014 10:56 am

Re: [HOWTO] F2FS

Sun Apr 06, 2014 11:38 am

Thanks for the guide juppiter, I had not heard of f2fs but if someone has bothered to design an fs for solid state storage and it's enabled in the default kernel is there any good reason it's not the default?

At first when I followed the guide I missed that I needed to change the "0 1" at the end of the fstab line to "0 0" - this resulted in a failed boot as it couldn't find fsck.f2fs. Read the instructions carefully people :lol:

hagen
Posts: 15
Joined: Sat Apr 20, 2013 8:24 am

Re: [HOWTO] F2FS

Fri Nov 20, 2015 10:25 am

My RPi doesn't boot if the rootfs is on f2fs. Does Jessie kernel 4.1.7 support booting from f2fs?

User avatar
DougieLawson
Posts: 30430
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: [HOWTO] F2FS

Fri Nov 20, 2015 2:19 pm

hagen wrote:My RPi doesn't boot if the rootfs is on f2fs. Does Jessie kernel 4.1.7 support booting from f2fs?
Do you have f2fs built in to your kernel or is it a loadable module?

If it's a loadable module you WILL need a initramfs which includes the kernel module to get it booted.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

hagen
Posts: 15
Joined: Sat Apr 20, 2013 8:24 am

Re: [HOWTO] F2FS

Sat Dec 05, 2015 7:43 pm

I compiled new kernel on desktop computer and have f2fs built in to kernel. New kernel boots if rootfs is on ext4 but I still can not boot from f2fs.
How to make initramfs on my desktop computer?

gameboy709494
Posts: 1
Joined: Thu Feb 25, 2016 2:51 pm

Re: [HOWTO] F2FS

Thu Feb 25, 2016 2:55 pm

suicidal_orange wrote:Thanks for the guide juppiter, I had not heard of f2fs but if someone has bothered to design an fs for solid state storage and it's enabled in the default kernel is there any good reason it's not the default?

At first when I followed the guide I missed that I needed to change the "0 1" at the end of the fstab line to "0 0" - this resulted in a failed boot as it couldn't find fsck.f2fs. Read the instructions carefully people :lol:
Oh, Thank you so much!! I fix the issue.! :D

Return to “Advanced users”

Who is online

Users browsing this forum: DirkS and 18 guests