How to using F2FS in EL9?

Any way to using f2fs inside rocky9?

I have a disk is f2fs, which works in centos7.
However, after swich to rocky9, f2fs not surported any more

mount: /mnt/nvme1: unknown filesystem type 'f2fs'.

I have tried to rpmbuild the ‘f2fs-tools’ from git clone https://src.fedoraproject.org/rpms/f2fs-tools.git, and installed the local builed f2fs-tools. however it is not work.

other testing:

# modprobe f2fs
modprobe: FATAL: Module f2fs not found in directory /lib/modules/5.14.0-503.38.1.el9_5.x86_64

The support for filesystems, “drivers”, is in kernel – most often as module. The f2fs-tools are mere userland tools that would talk to the kernel.

The kernel config for CentOS 7 did not set CONFIG_F2FS_FS. Therefore, CentOS 7 did not support f2fs “out of the box” either. You must have procured f2fs module for CentOS 7 somehow. How did you do that?

The ELRepo’s kernel-ml and kernel-lt upstream kernel builds for el9 seem to include the f2fs module.

Yes, just noticed that my centos7 uses kernel-ml.

Looks like I can only use elrepo’s kernel in el9.
And just tested in EL10, the kernel is the same as EL9, which is not suport f2fs.

It would be nice if there was a way to manually add kernel modules into the official kernel. ( Just like adding a new NIC driver. )

ELRepo, CentOS Kmods SIG, Rocky SIG/kernel, etc seem to be doing just that:
build kernel modules and package them for easy ‘dnf install’.

The ‘dkms’ and ‘akmod’ tools seem able to rebuild, if needed, modules from “sources” when new kernel boots (or installs).

There clearly is a way.


How does one build one kernel module? I have no idea.

The last entry in this forum post has an example

https://forums.rockylinux.org/t/building-v4l-rpm-for-tbs-hardware/18014/10

But even then, there’s still the issue of how to sign it.

I found a way to build and add mod, that is,

dnf install kernel-devel

mkdir /root/mybuild
cd /root/mybuild

# download src
dnf download --source kernel
rpm2cpio kernel-5.14.0-503.40.1.el9_5.src.rpm | cpio -idmv

tar -xvf linux-5.14.0-503.40.1.el9_5.tar.xz

cd linux-5.14.0-503.40.1.el9_5

# make the module
make CONFIG_F2FS_FS=m -C /usr/src/kernels/5.14.0-503.40.1.el9_5.x86_64 M=/root/mybuild/linux-5.14.0-503.40.1.el9_5/fs/f2fs modules

#  insert module: f2fs.ko
insmod ./fs/f2fs/f2fs.ko
# check supported filesystems
cat /proc/filesystems

However, the source-code may have some type of errors, the make is not finished fine, logs:

[root@host linux-5.14.0-503.40.1.el9_5]# make CONFIG_F2FS_FS=m -C /usr/src/kernels/5.14.0-503.40.1.el9_5.x86_64 M=/root/mybuild/linux-5.14.0-503.40.1.el9_5/fs/f2fs modules
make: Entering directory '/usr/src/kernels/5.14.0-503.40.1.el9_5.x86_64'
  CC [M]  /root/mybuild/linux-5.14.0-503.40.1.el9_5/fs/f2fs/dir.o
  CC [M]  /root/mybuild/linux-5.14.0-503.40.1.el9_5/fs/f2fs/file.o
  CC [M]  /root/mybuild/linux-5.14.0-503.40.1.el9_5/fs/f2fs/inode.o
/root/mybuild/linux-5.14.0-503.40.1.el9_5/fs/f2fs/inode.c: In function ‘f2fs_iget_retry’:
/root/mybuild/linux-5.14.0-503.40.1.el9_5/fs/f2fs/inode.c:565:25: error: implicit declaration of function ‘congestion_wait’ [-Werror=implicit-function-declaration]
  565 |                         congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT);
      |                         ^~~~~~~~~~~~~~~
/root/mybuild/linux-5.14.0-503.40.1.el9_5/fs/f2fs/inode.c:565:41: error: ‘BLK_RW_ASYNC’ undeclared (first use in this function)
  565 |                         congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT);
      |                                         ^~~~~~~~~~~~
/root/mybuild/linux-5.14.0-503.40.1.el9_5/fs/f2fs/inode.c:565:41: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errors
make[1]: *** [scripts/Makefile.build:249: /root/mybuild/linux-5.14.0-503.40.1.el9_5/fs/f2fs/inode.o] Error 1
make: *** [Makefile:1944: /root/mybuild/linux-5.14.0-503.40.1.el9_5/fs/f2fs] Error 2
make: Leaving directory '/usr/src/kernels/5.14.0-503.40.1.el9_5.x86_64'

I Have tested to install the elrepo kernel-lt or kernel-ml. Unfortunately, however, none of them support f2fs. looks like I’ll have to build the mod, or kernel.

Really? The dnf --repo=elrepo-kernel provides */f2fs.ko\* claims that both of them have f2fs.ko.xz
Would it not load, was the support missing even with that module loaded, or what?

1 Like

It’s definitely there:

root@zfs:~# modprobe f2fs

root@zfs:~# lsmod | grep f2fs
f2fs                  823296  0
lz4hc_compress         24576  1 f2fs
lz4_compress           36864  1 f2fs
zstd_compress         299008  1 f2fs

root@zfs:~# cat /etc/rocky-release
Rocky Linux release 9.5 (Blue Onyx)

root@zfs:~# uname -r
6.1.135-1.el9.elrepo.x86_64
1 Like

I was not run the modprobe, it works now for elrepo-kernel.

1 Like

I still expect, however, to go with the approach of loading self-built mods in the official kernel.

  1. elrepo not works with leapp, if want to update to EL10.
  2. If one installed nvidia drivers firstly, may will be not able to install elrepo kernel

Any one have idea on the err log of make modules