The F2FS filesystem was developed specifically for flash memory like SD-cards. This means that the memory of a Raspberry Pi can last longer, which is a win. There are already tutorials out there of how to change your working Raspberry Pi file system use F2FS, but since there aren’t any official Raspbian images using F2FS, I’ll explain the steps of changing the official image to use F2FS.
Make sure you have an empty micro SD-card of at least 8GB (I’ll use one of 32GB). Next, download the newest Raspbian image from the official download page.
Now we can start to change the filesystem. To start, we need to mount the image, but since it contains multiple partitions we’ll create some loop devices first. As root execute the following
Note down the loop device and execute the following commands to mount the root filesystem of the pi image (we use loop0 here, make sure to change it to your situation)
Next up we create a temporary file based filesystem of about 1.8Gb to store the data so we can change the root partition filesystem. This is enough for the light image, but make sure to change the count if you have a larger image.
Now we need to change the filesystem entry in fstab as well. So we open /media/user/tmp/etc/fstab using vim and change this line
to the following
If your SD-card doesn’t support TRIM, you can leave out the discard option, but most SD-cards have it, so most of the times you can keep it.
Now we can change the file system of the Raspbian image and copy the files back. Make sure to use the right loop number (same as before) since you are removing all data on it!
Now we can unmount these filesystems and remove the temporary file we created before
We’re almost done, but before the image is ready, we also need to change something on the boot partition, namely the cmdline.txt. To do so, we first mount the boot partition
Using vim we open /media/user/boot/cmdline.txt to edit ‘rootfstype=ext4’ to ‘rootfstype=f2fs’. The result should look similar to this
The image is ready for installation, yay! Now we only need to close everything that’s still open
And that’s it, you’ve successfully changed your raspbian image to use the F2FS filesystem.
If you want to actually install the modified image, you only need to enter one more command. It’s pretty much copied from the official Raspberry Pi documentation, so make sure to look there for more information. Anyways, make sure that the SD-card isn’t mounted and then type the following as root, where ‘device’ is the identifier for the SD-card (most likely sdX or mmcblkX)
Enjoy your F2FS Raspberry Pi installation!
Trivial statements are trivial.