最近在fedora 41上开发fuse文件系统。需要编译fuse内核模块,加一些调试信息。编译方法如下:
1 确定内核版本
$ uname -r
6.11.4-301.fc41.x86_64
2 从国内清华镜像站克隆内核源码
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/linux.git
$ cd linux/
$ git remote add stable https://mirrors.tuna.tsinghua.edu.cn/git/linux-stable.git
$ git fetch stable linux-6.11.y
$ git worktree add -b linux-6.11.y ../linux-6.11.y stable/linux-6.11.y
$ cd ../linux-6.11.y/
3 从linux中复制配置文件
$ cp /boot/config-`uname -r`* .config
4 编译
$ make fs/fuse/fuse.ko KBUILD_MODPOST_WARN=1
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
DESCEND bpf/resolve_btfids
INSTALL libsubcmd_headers
make[4]: 'fs/fuse/fuse.mod' is up to date.
MODPOST modules-only.symvers
WARNING: vmlinux.o is missing.
Modules may not have dependencies or modversions.
You may get many unresolved symbol errors.
You can set KBUILD_MODPOST_WARN=1 to turn errors into warning
if you want to proceed at your own risk.
WARNING: modpost: "__ubsan_handle_out_of_bounds" [fs/fuse/fuse.ko] undefined!
WARNING: modpost: "__var_waitqueue" [fs/fuse/fuse.ko] undefined!
WARNING: modpost: "iov_iter_extract_pages" [fs/fuse/fuse.ko] undefined!
WARNING: modpost: "backing_file_write_iter" [fs/fuse/fuse.ko] undefined!
WARNING: modpost: "page_offset_base" [fs/fuse/fuse.ko] undefined!
WARNING: modpost: "copy_page_from_iter_atomic" [fs/fuse/fuse.ko] undefined!
WARNING: modpost: "fs_param_is_gid" [fs/fuse/fuse.ko] undefined!
WARNING: modpost: "dax_read_unlock" [fs/fuse/fuse.ko] undefined!
WARNING: modpost: "fs_context_for_submount" [fs/fuse/fuse.ko] undefined!
WARNING: modpost: "inode_init_once" [fs/fuse/fuse.ko] undefined!
WARNING: modpost: suppressed 331 unresolved symbol warnings because there were too many)
CC [M] fs/fuse/fuse.mod.o
LD [M] fs/fuse/fuse.ko
参考:
https://gist.github.com/louisrubet/b448e78825fab915873f609ecabb2c22
https://docs.fedoraproject.org/en-US/quick-docs/kernel-build-custom/