Linux|操作系统|最新版openzfs编译记录

前言:

zfs是一个强大的新一代文件系统,但由于开源证书的问题,该项技术并没有合并到主流Linux操作系统内核当中,这个不得不说是一个非常巨大的遗憾。

ok,那么zfs到底如何强悍就不在本文内吹捧了,直接记录centos7下编译安装该zfs文件系统的过程

一、

zfs文件系统的版本介绍和安装方式介绍

zfs文件系统的一些基本特点

第一点,zfs文件系统是和操作系统的内核深度绑定的,就像ntfs文件系统一样,Linux要使用此类文件系统,必须要内核方面支持。

第二点,zfs文件系统是可以和其它文件系统混用的,就像我们现在的操作系统内所作的事情一样,比如,有的操作系统根区文件系统是ext4,但并不妨碍我们使用xfs作为数据盘的文件系统,这个也是标准的部署方案。

第三点,zfs文件系统对于数据库这样的应用非常有用,可以做到秒级恢复,本文在centos7系统内尝试编译安装zfs文件系统

zfs文件系统的版本介绍

zfs文件系统在epel源里面好像是有,但版本过低,是0.7.3版本,该版本和centos7是完全不兼容的,现在的版本最新是2.4.1,源码下载地址是: https://github.com/openzfs/zfs/releases

选用2.4.1版本的原因是最新的zfs文件系统对于一些安全漏洞以及一些使用上的bug问题做了比较多的改善

zfs文件系统的安装方式

zfs文件系统的安装方式主要是两种,第一种是二进制方式安装,也就是最为常用的yum安装方式,但该方式对于版本的选择太少,局限性过高,第二种方式是源码编译方式,该方式比较复杂,但安装的成功率会更高,并且对于上面的版本冲突问题也能够解决的比较好。

本文采用源码编译的方式编译安装部署zfs-2.4.1,该版本是2025年12月发布,综合各方面来说,还是比较好的

二,zfs文件系统编译前的准备工作

1,硬件资源

计划在VMware虚拟机内实现zfs文件系统的编译,因此,先给该虚拟机添加3块硬盘,并可在系统中看到,zfs文件系统对于内存需求较高,因此是8G

三,centos内核版本

本例使用的是5.4.266内核版本

bash 复制代码
[root@centos1 zfs-2.4.1]# uname  -a
Linux centos1 5.4.266-1.el7.elrepo.x86_64 #1 SMP Mon Jan 8 23:23:50 EST 2024 x86_64 x86_64 x86_64 GNU/Linux

后面改成了5.4.69内核版本

四,编译环境的创建

bash 复制代码
yum install autoconf automake libtool -y
./autogen.sh 
yum install -y zlib-devel libuuid-devel libblkid-devel libattr-devel libtirpc-devel openssl-devel bc

五,zfs源码预编译和编译

第一次编译报错如下:

bash 复制代码
configure: WARNING: cannot find unwind via pkg-config or in the standard locations
checking makedev() is declared in sys/sysmacros.h... yes
checking makedev() is declared in sys/mkdev.h... no
checking for execvpe... yes
checking for issetugid... no
checking for mlockall... yes
checking for strlcat... no
checking for strlcpy... no
checking for gettid... no
checking kernel source and build directories... done
checking kernel source directory... /usr/src/kernels/5.4.266-1.el7.elrepo.x86_64
checking kernel build directory... /usr/src/kernels/5.4.266-1.el7.elrepo.x86_64
checking kernel source version... 5.4.266-1.el7.elrepo.x86_64
checking for kernel config option compatibility... done
checking whether CONFIG_MODULES is defined... no
configure: error: 
		*** This kernel does not include the required loadable module
		*** support!
		***
		*** To build OpenZFS as a loadable Linux kernel module
		*** enable loadable module support by setting
		*** `CONFIG_MODULES=y` in the kernel configuration and run
		*** `make modules_prepare` in the Linux source tree.
		***
		*** If you don't intend to enable loadable kernel module
		*** support, please compile OpenZFS as a Linux kernel built-in.
		***
		*** Prepare the Linux source tree by running `make prepare`,
		*** use the OpenZFS `--enable-linux-builtin` configure option,
		*** copy the OpenZFS sources into the Linux source tree using
		*** `./copy-builtin <linux source directory>`,
		*** set `CONFIG_ZFS=y` in the kernel configuration and compile
		*** kernel as usual.

经查找资料,发现本例使用的内核版本是长期支持版本5.4.266,不支持动态内核编译,因此,更换内核版本为3.10.1160,内核重新安装后重启启用新内核

bash 复制代码
yum remove kernel-lt-* -y
yum install -y kernel-3.10.0-1160.118.1.el7.x86_64 kernel-devel-3.10.0-1160.118.1.el7.x86_64 kernel-headers-3.10.0-1160.118.1.el7.x86_64

在使用3.10.1160内核后,仍然报错,因此采用新的内核,直接 编译,编译完成后的内核版本如下(我自己设定的名字,因此,大家不要太纠结这个版本号问题)

bash 复制代码
[root@centos1 zfs-2.4.1]# uname -a
Linux centos1 5.4.695.4-test #1 SMP Sun May 3 18:11:01 CST 2026 x86_64 x86_64 x86_64 GNU/Linux

编译完成后,开始zfs的编译,解压zfs的源码包后,进入解压目录,执行以下命令:

bash 复制代码
./configure

输出如下:

bash 复制代码
[root@centos1 zfs-2.4.1]# ./configure 
checking for gawk... gawk
checking metadata... META file
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make supports nested variables... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking whether make sets $(MAKE)... yes
checking how to print strings... printf
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking whether ln -s works... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking dependency style of gcc... gcc3
checking whether gcc and cc understand -c and -o together... yes
checking whether to build with code coverage support... no
checking how to create a pax tar archive... gnutar
checking zfs author... OpenZFS
checking zfs license... CDDL
checking whether NLS is requested... yes
checking for msgfmt... /usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... /usr/bin/xgettext
checking for msgmerge... /usr/bin/msgmerge
checking for ld... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking for shared library run path origin... done
checking 32-bit host C ABI... no
checking for the common suffixes of directories in the library search path... lib64,lib64
checking zfs config... all
checking the number of available CPUs... 16
checking whether gcc supports -Wno-clobbered... yes
checking whether gcc supports -Winfinite-recursion... no
checking whether gcc supports -Winfinite-recursion... no
checking whether gcc supports -Wno-atomic-alignment... yes
checking whether gcc supports -Wimplicit-fallthrough... no
checking whether gcc supports -Wframe-larger-than=<size>... yes
checking whether gcc supports -Wno-format-truncation... yes
checking whether gcc supports -Wno-format-zero-length... yes
checking whether gcc supports -Wno-format-zero-length... yes
checking whether gcc supports -Wformat-overflow... no
checking whether gcc supports -fno-omit-frame-pointer... yes
checking whether gcc supports -fno-ipa-sra... yes
checking whether gcc supports -fno-ipa-sra... yes
checking whether to build with -fsanitize=address support... no
checking whether to build with -fsanitize=undefined support... no
checking whether host toolchain supports SSE... yes
checking whether host toolchain supports SSE2... yes
checking whether host toolchain supports SSE3... yes
checking whether host toolchain supports SSSE3... yes
checking whether host toolchain supports SSE4.1... yes
checking whether host toolchain supports SSE4.2... yes
checking whether host toolchain supports AVX... yes
checking whether host toolchain supports AVX2... yes
checking whether host toolchain supports AVX512F... yes
checking whether host toolchain supports AVX512CD... yes
checking whether host toolchain supports AVX512DQ... yes
checking whether host toolchain supports AVX512BW... yes
checking whether host toolchain supports AVX512IFMA... yes
checking whether host toolchain supports AVX512VBMI... yes
checking whether host toolchain supports AVX512PF... yes
checking whether host toolchain supports AVX512ER... yes
checking whether host toolchain supports AVX512VL... yes
checking whether host toolchain supports AES... yes
checking whether host toolchain supports PCLMULQDQ... yes
checking whether host toolchain supports MOVBE... yes
checking whether host toolchain supports VAES... no
checking whether host toolchain supports VPCLMULQDQ... no
checking whether host toolchain supports XSAVE... yes
checking whether host toolchain supports XSAVEOPT... yes
checking whether host toolchain supports XSAVES... yes
checking for system type (linux-gnu)... Linux
checking for conflicting environment variables... done
checking for python3... no
checking whether to enable pyzfs: ... no
checking for sed --in-place... --in-place
checking for cppcheck... no
checking for shellcheck... no
checking for checkbashisms... no
checking for parallel... no
./configure: line 64740: gt_INTL_MACOSX: command not found
checking for GNU gettext in libc... yes
checking whether to use NLS... yes
checking where the gettext function comes from... libc
checking for dracut directory... /usr/lib/dracut
checking for zlib... yes
checking for zlib.h... yes
checking for compress2 in -lz... yes
checking for uncompress in -lz... yes
checking for crc32 in -lz... yes
checking for udev directories... /lib/udev;/lib/udev/rules.d
checking for systemd support... yes
checking for libudev... no
checking for libudev.h... no
checking for libudev.h... no
configure: WARNING: cannot find udev via pkg-config or in the standard locations
checking for uuid... yes
checking for uuid/uuid.h... yes
checking for uuid_generate in -luuid... yes
checking for uuid_is_null in -luuid... yes
checking for blkid... yes
checking for blkid/blkid.h... yes
checking for main in -lblkid... yes
checking for sys/stat.h... (cached) yes
checking for statx... no
checking for library containing xdrmem_create... none required
checking for libcrypto... yes
checking for openssl/evp.h... yes
checking for PKCS5_PBKDF2_HMAC_SHA1 in -lcrypto... yes
checking for libaio.h... no
checking for libaio.h... no
configure: WARNING: cannot find aio via pkg-config or in the standard locations
checking whether -latomic is required... no
checking for libfetch... none
checking for aio.h... yes
checking for lio_listio in -lrt... yes
checking for clock_gettime... yes
checking security/pam_modules.h usability... no
checking security/pam_modules.h presence... no
checking for security/pam_modules.h... no
checking for library containing backtrace... none required
checking for libunwind... no
checking for libunwind.h... no
checking for libunwind.h... no
configure: WARNING: cannot find unwind via pkg-config or in the standard locations
checking makedev() is declared in sys/sysmacros.h... yes
checking makedev() is declared in sys/mkdev.h... no
checking for execvpe... yes
checking for issetugid... no
checking for mlockall... yes
checking for strlcat... no
checking for strlcpy... no
checking for gettid... no
checking kernel source and build directories... done
checking kernel source directory... /root/linux-5.4.69
checking kernel build directory... /root/linux-5.4.69
checking kernel source version... 5.4.695.4-test
checking for kernel config option compatibility... done
checking whether CONFIG_MODULES is defined... yes
checking whether CONFIG_BLOCK is defined... yes
checking whether mutex_lock() is GPL-only... no
checking whether CONFIG_TRIM_UNUSED_KSYM is disabled... yes
checking whether CONFIG_ZLIB_DEFLATE is defined... yes
checking whether CONFIG_ZLIB_INFLATE is defined... yes
checking kernel file name for module symbols... Module.symvers
checking whether fpu headers are available... asm/fpu/api.h asm/fpu/internal.h
checking whether objtool header is available... linux/frame.h
checking whether /dev/zfs minor is available... 249
checking whether DECLARE_EVENT_CLASS() is available... no
checking for available kernel interfaces... done
checking whether kernel defines intptr_t... no
checking whether access_ok() has 'type' parameter... no
checking whether compile-time stack validation (objtool) is available... yes
checking whether STACK_FRAME_NON_STANDARD is defined... yes
checking whether STACK_FRAME_NON_STANDARD asm macro is defined... no
checking whether CONFIG_OBJTOOL_WERROR is defined... no
checking whether pde_data() is lowercase... no
checking whether generic_fadvise() is available... yes
checking whether header linux/sched/rt.h exists... yes
checking whether usleep_range() is available... yes
checking whether __vmalloc(ptr, flags, pageflags) is available... yes
checking whether timestamp_truncate() exists... yes
checking whether inode_get_ctime() exists... no
checking whether inode_set_ctime_to_ts() exists... no
checking whether inode_get_atime() exists... no
checking whether inode_set_atime_to_ts() exists... no
checking whether inode_get_mtime() exists... no
checking whether inode_set_mtime_to_ts() exists... no
checking whether proc_ops structure exists... no
checking whether bops->check_events() exists... yes
checking whether bops->release() is void and takes 2 args... yes
checking whether bops->revalidate_disk() exists... yes
checking whether bops->getgeo() takes gendisk as first arg... no
checking whether bio_set_op_attrs is available... yes
checking whether bio_set_dev() is GPL-only... yes
checking whether bio_set_dev() is a macro... yes
checking whether current->bio_list exists... yes
checking whether blkg_tryget() is available... yes
checking whether blkg_tryget() is GPL-only... no
checking whether bio->bi_bdev->bd_disk exists... no
checking whether block_device_operations->submit_bio() returns void... no
checking whether bio_alloc() wants 4 args... no
checking whether blkdev_get_by_path() exists and takes 3 args... yes
checking whether blkdev_put() exists... yes
checking whether blkdev_reread_part() exists... yes
checking whether invalidate_bdev() exists... yes
checking whether lookup_bdev() wants dev_t arg... no
checking whether lookup_bdev() wants 1 arg... yes
checking whether bdev_logical_block_size() is available... yes
checking whether bdev_physical_block_size() is available... yes
checking whether check_disk_change() exists... yes
checking whether bdev_check_media_change() exists... no
checking whether bdev_whole() is available... no
checking whether bdev_nr_bytes() is available... no
checking whether bdevname() exists... yes
checking whether blkdev_get_by_path() handles ERESTARTSYS... yes
checking whether blkdev_issue_discard() is available... no
checking whether blkdev_issue_discard(flags) is available... yes
checking whether __blkdev_issue_discard() is available... no
checking whether __blkdev_issue_discard(flags) is available... yes
checking whether blkdev_issue_secure_erase() is available... no
checking whether bdev_kobj() exists... no
checking whether part_to_dev() exists... yes
checking whether disk_check_media_change() exists... no
checking whether BLK_STS_RESV_CONFLICT is defined... no
checking whether blk_mode_t is defined... no
checking whether struct blk_plug is available... yes
checking whether blk_queue bdi is dynamic... yes
checking whether backing_dev_info is available through queue gendisk... no
checking whether blk_queue_update_readahead() exists... no
checking whether disk_update_readahead() exists... no
checking whether bdev_max_discard_sectors() is available... no
checking whether blk_queue_discard() is available... yes
checking whether bdev_max_secure_erase_sectors() is available... no
checking whether blk_queue_secure_erase() is available... yes
checking whether blk_queue_max_hw_sectors() is available... yes
checking whether blk_queue_max_segments() is available... yes
checking whether block multiqueue hardware context is cached in struct request... yes
checking whether GENHD_FL_EXT_DEVT flag is available... yes
checking whether GENHD_FL_NO_PART flag is available... no
checking whether revalidate_disk_size() is available... no
checking whether revalidate_disk() is available... yes
checking whether get_disk_ro() is available... yes
checking whether ql->discard_granularity is available... yes
checking whether inode_owner_or_capable() exists... yes
checking whether super_block uses const struct xattr_handler... yes
checking whether xattr_handler->get() wants dentry and inode and flags... no
checking whether xattr_handler->set() wants dentry, inode, and mnt_idmap... no
checking whether xattr_handler->set() wants dentry, inode, and user_namespace... no
checking whether xattr_handler->set() wants dentry and inode... yes
checking whether posix_acl_equiv_mode() wants umode_t... yes
checking whether iops->get_acl() exists... yes
checking whether iops->set_acl() with 4 args exists... no
checking whether iops->setattr() takes mnt_idmap... no
checking whether iops->setattr() takes user_namespace... no
checking whether iops->getattr() takes mnt_idmap... no
checking whether iops->getattr() takes user_namespace... no
checking whether iops->getattr() takes a path... yes
checking whether inode_state_read_once() exists... no
checking whether sops->show_options() wants dentry... yes
checking whether super_block has s_shrink... yes
checking whether new var-arg register_shrinker() exists... no
checking whether shrinker_register() exists... no
checking whether iops->mkdir() returns struct dentry*... no
checking whether iops->mkdir() takes struct mnt_idmap*... no
checking whether iops->mkdir() takes struct user_namespace*... no
checking whether iops->lookup() passes flags... yes
checking whether iops->create() takes struct mnt_idmap*... no
checking whether iops->create() takes struct user_namespace*... no
checking whether iops->create() passes flags... yes
checking whether iops->permission() takes struct mnt_idmap*... no
checking whether iops->permission() takes struct user_namespace*... no
checking whether i_op->tmpfile() exists... yes
checking whether dops->d_automount() exists... yes
checking whether dops->d_revalidate() takes 4 args... no
checking whether eops->commit_metadata() exists... yes
checking whether setattr_prepare() is available and accepts struct mnt_idmap*... no
checking whether setattr_prepare() is available and accepts struct user_namespace*... no
checking whether setattr_prepare() is available, doesn't accept user_namespace... yes
checking whether insert_inode_locked() is available... yes
checking whether d_obtain_alias() is available... yes
checking whether d_set_d_op() is available... yes
checking whether set_default_d_op() is available... no
checking whether truncate_setsize() is available... yes
checking whether security_inode_init_security wants callback... yes
checking whether fst->mount() exists... yes
checking whether SB_DYING is defined... no
checking whether set_nlink() is available... yes
checking whether sget() wants 5 args... yes
checking whether filemap_dirty_folio exists... no
checking whether read_folio exists... no
checking whether migrate_folio exists... no
checking whether migratepage exists... yes
checking whether vfs_fsync() wants 2 args... yes
checking whether aops->readpages exists... yes
checking whether aops->writepage exists... yes
checking whether __set_page_dirty_nobuffers exists... yes
checking whether fault_in_iov_iter_readable() is available... no
checking whether iov_iter_type() is available... yes
checking whether iov_iter_get_pages2() is available... no
checking whether iter_is_ubuf() is available... no
checking whether iter_iov() is available... no
checking whether generic_copy_file_range() is available... yes
checking whether splice_copy_file_range() is available... no
checking whether fops->remap_file_range() is available... yes
checking whether fops->clone_file_range() is available... no
checking whether fops->dedupe_file_range() is available... no
checking whether kmap_atomic wants 1 args... yes
checking whether kmap_local_page exists... no
checking whether follow_down_one() is available... yes
checking whether submit_bio is member of struct block_device_operations... no
checking whether blk_alloc_queue() expects request function... no
checking whether make_request_fn() returns blk_qc_t... yes
checking whether 6.3+ bdev_*_io_acct() are available... no
checking whether pre-6.3 bdev_*_io_acct() are available... no
checking whether generic disk_*_io_acct() are available... no
checking whether generic bio_*_io_acct() are available... no
checking whether generic_*_io_acct wants 4 args... yes
checking whether kernel fpu is available... internal
checking whether kernel defines fmode_t... yes
checking whether kuid_t/kgid_t is available... yes
checking whether i_(uid|gid)_(read|write) exist... yes
checking whether iops->rename() takes struct mnt_idmap*... no
checking whether iops->rename() takes struct user_namespace*... no
checking whether iops->rename() wants flags... yes
checking whether totalram_pages() exists... yes
checking whether totalhigh_pages() exists... yes
checking whether is inside percpu_ref.data... no
checking whether generic_fillattr requires struct mnt_idmap* and request_mask... no
checking whether generic_fillattr requires struct mnt_idmap*... no
checking whether generic_fillattr requires struct user_namespace*... no
checking whether iops->mknod() takes struct mnt_idmap*... no
checking whether iops->mknod() takes struct user_namespace*... no
checking whether iops->symlink() takes struct mnt_idmap*... no
checking whether iops->symlink() takes struct user_namespace*... no
checking whether bio_max_segs() exists... no
checking whether kernel_siginfo_t tyepedef exists... yes
checking whether struct kobj_type.default_groups exists... yes
checking whether standalone <linux/stdarg.h> exists... no
checking whether strlcpy() exists... yes
checking whether folio_wait_bit() exists... no
checking whether readahead_page() exists... no
checking whether add_disk() returns int... no
checking whether kthread_complete_and_exit() is available... no
checking whether dequeue_signal() takes 4 arguments... no
checking whether 3-arg dequeue_signal() takes a type argument... no
checking whether ZERO_PAGE() is GPL-only... no
checking whether __copy_from_user_inatomic is available... yes
checking whether APIs for idmapped mount are present... no
checking whether idmapped mounts have a user namespace... no
checking whether iattr->ia_vfsuid and iattr->ia_vfsgid exist... no
checking whether int (*writepage_t)() takes struct folio*... no
checking whether write_cache_pages() is available... yes
checking whether struct reclaim_state has reclaimed field... no
checking whether register_sysctl_table exists... yes
checking whether register_sysctl_sz exists... no
checking whether proc_handler ctl_table arg is const... no
checking whether copy_splice_read() exists... no
checking whether fsync_bdev() exists... yes
checking whether PG_error flag is available... yes
checking whether 'flags' in 'struct page' is a struct... no
checking whether page_size() is available... yes
checking whether page_mapping() is available... yes
checking whether __assign_str() has one arg... no
checking whether file->f_version exists... no
checking whether pin_user_pages_unlocked() is available... no
checking whether timer_delete_sync() is available... no
checking whether super_block has s_wb_err... no
checking whether sops->free_inode() exists... no
checking whether ns_type is accessible through ns_common... no
checking whether inode_generic_drop() exists... no
checking whether kasan_enabled() is GPL-only... yes
checking os distribution... redhat
checking default package type... rpm
checking default init directory... ${prefix}/etc/init.d
checking default shell... /bin/sh
checking default nfs server init script... nfs
checking default init config directory... /etc/sysconfig
checking whether initramfs-tools is available... no
checking default bash completion directory... /etc/bash_completion.d
checking whether rpm is available... yes (4.11.3)
checking whether rpmbuild is available... no
checking whether spec files are available... yes (rpm/generic/*.spec.in)
checking whether dpkg is available... no
checking whether dpkg-buildpackage is available... no
checking whether alien is available... no
checking whether assertion support will be enabled... no
checking whether debuginfo support will be forced... no
checking whether basic kmem accounting is enabled... no
checking whether detailed kmem tracking is enabled... no
checking whether FreeBSD kernel INVARIANTS checks are enabled... no
checking whether objtool error on warning behavior is enabled... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating contrib/debian/rules
config.status: creating contrib/debian/changelog
config.status: creating Makefile
config.status: creating include/Makefile
config.status: creating lib/libzfs/libzfs.pc
config.status: creating lib/libzfs_core/libzfs_core.pc
config.status: creating lib/libzfsbootenv/libzfsbootenv.pc
config.status: creating module/Kbuild
config.status: creating module/Makefile
config.status: creating rpm/generic/zfs-dkms.spec
config.status: creating rpm/generic/zfs-kmod.spec
config.status: creating rpm/generic/zfs.spec
config.status: creating rpm/redhat/zfs-dkms.spec
config.status: creating rpm/redhat/zfs-kmod.spec
config.status: creating rpm/redhat/zfs.spec
config.status: creating tests/zfs-tests/tests/Makefile
config.status: creating zfs.release
config.status: creating scripts/objtool-wrapper
config.status: creating zfs_config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing po-directories commands

在make的时候,发现失败了,根本原因是内核版本不能自定义,因此,又重新编译了一次内核版本,编译全部默认,新内核版本如下(编译过程参照 https://blog.csdn.net/alwaysbefine/article/details/108931626),编译完成后,重启服务器,执行如下命令确认内核升级成功:

bash 复制代码
[root@centos1 ~]# uname -a
Linux centos1 5.4.69 #1 SMP Sun May 3 19:08:14 CST 2026 x86_64 x86_64 x86_64 GNU/Linux

make阶段报错,如下:

bash 复制代码
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1047:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c: In function 'GHASH_AVX':
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1054:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c: At top level:
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1075:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1085:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c: In function 'gcm_use_impl':
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1112:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c: In function 'gcm_impl_will_work':
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1139:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c: At top level:
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1193:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c: In function 'gcm_mode_encrypt_contiguous_blocks_avx':
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1244:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c: At top level:
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1461:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c: In function 'gcm_decrypt_final_avx':
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1490:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c: In function 'gcm_init_avx':
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1615:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
/root/zfs-2.4.1/module/icp/include/modes/modes.h:45:26: warning: "HAVE_VAES" is not defined [-Wundef]
 #define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
                          ^
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:1642:5: note: in expansion of macro 'CAN_USE_GCM_ASM'
 #if CAN_USE_GCM_ASM >= 2
     ^
make[5]: *** [/root/zfs-2.4.1/module/icp/algs/modes/gcm.o] Error 1
make[4]: *** [/root/zfs-2.4.1/module] Error 2
make[3]: *** [sub-make] Error 2
make[3]: Leaving directory `/root/linux-5.4.69'
make[2]: *** [modules-Linux] Error 2
make[2]: Leaving directory `/root/zfs-2.4.1/module'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/zfs-2.4.1'
make: *** [all] Error 2

解决措施为:

bash 复制代码
编辑有问题的头文件,为缺失的宏提供默认值:
# 编辑 modes.h
vim /root/zfs-2.4.1/module/icp/include/modes/modes.h
找到第45行附近(大约):
#define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)
修改为:
#ifndef HAVE_VAES
#define HAVE_VAES 0
#endif
#ifndef HAVE_VPCLMULQDQ
#define HAVE_VPCLMULQDQ 0
#endif
#define CAN_USE_GCM_ASM (HAVE_VAES && HAVE_VPCLMULQDQ ? 2 : 1)

该报错可以忽略,但预编译的时候没有选择忽略,因此,报错,只是一个加密功能的问题,zfs文件系统的核心功能没有改变

make继续报错,如下:

bash 复制代码
  CC [M]  /root/zfs-2.4.1/module/icp/algs/modes/gcm.o
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:853:18: error: 'IMPL_AVX2' undeclared here (not in a function)
   { "avx2-vaes", IMPL_AVX2 },
                  ^
make[5]: *** [/root/zfs-2.4.1/module/icp/algs/modes/gcm.o] Error 1
make[4]: *** [/root/zfs-2.4.1/module] Error 2
make[3]: *** [sub-make] Error 2
make[3]: Leaving directory `/root/linux-5.4.69'
make[2]: *** [modules-Linux] Error 2
make[2]: Leaving directory `/root/zfs-2.4.1/module'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/zfs-2.4.1'
make: *** [all] Error 2

解决方案为修改gcm.c文件,在20行左右添加如下配置:

bash 复制代码
#include "../../include/sys/crypto/impl.h"
#include "../../include/modes/modes.h"

又报错,如下:

bash 复制代码
	 \
	M="$PWD"  CONFIG_ZFS=m modules
make[3]: Entering directory `/root/linux-5.4.69'
  CC [M]  /root/zfs-2.4.1/module/icp/algs/modes/gcm.o
/root/zfs-2.4.1/module/icp/algs/modes/gcm.c:856:18: error: 'IMPL_AVX2' undeclared here (not in a function)
   { "avx2-vaes", IMPL_AVX2 },
                  ^
make[5]: *** [/root/zfs-2.4.1/module/icp/algs/modes/gcm.o] Error 1
make[4]: *** [/root/zfs-2.4.1/module] Error 2
make[3]: *** [sub-make] Error 2
make[3]: Leaving directory `/root/linux-5.4.69'
make[2]: *** [modules-Linux] Error 2
make[2]: Leaving directory `/root/zfs-2.4.1/module'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/zfs-2.4.1'
make: *** [all] Error 2

解决方案为:

bash 复制代码
# 编辑 gcm.c
vim /root/zfs-2.4.1/module/icp/algs/modes/gcm.c
找到第856行附近,注释掉有问题的行:


//{ "avx2-vaes", IMPL_AVX2 },  // 暂时禁用

然后就一路畅通,zfs文件系统终于顺利编译完成了

稍微总结下,由于是虚拟机的缘故,一些硬件检测导致编译失败,因此这些优化措施是可以禁用掉的,如果是真实物理机,估计很可能不会有这些报错

测试zfs文件系统是否安装成功:

bash 复制代码
[root@centos1 zfs-2.4.1]# lsmod |grep zfs
[root@centos1 zfs-2.4.1]# modprobe zfs
[root@centos1 zfs-2.4.1]# lsmod |grep zfs
zfs                  5554176  0 
spl                   122880  1 zfs

看到内核加载了zfs文件系统的模块,标志此次编译安装完成

六,zfs的rpm安装包生成

经过上面的一番操作,make出了zfs文件系统,那么,如果每个机器上都编译一次,未免太不人性化了,因此,还是需要直接编译出centos7x86_64的操作系统用的rpm安装包

狠简单的一个命令,make rpm就可以了,但是,我这里要说一下但是,还是缺了一些编译依赖,编译依赖解决后,还需要修改一下makefile文件,先说编译依赖问题:

bash 复制代码
yum install -y rpm-build ncompress libudev-devel libaio-devel bc

编译依赖解决完后,打开Makefile文件,vim /root/zfs-2.4.1/Makefile,将HAVE_RPMBUILD = no 修改为HAVE_RPMBUILD = yes

后面的rpm生成就非常顺畅了,生成的rpm包如下:

bash 复制代码
[root@centos1 zfs-2.4.1]# ls -alh *.rpm
-rw-r--r-- 1 root root 1.6M May  3 20:56 kmod-zfs-5.4.69-2.4.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 394K May  3 20:56 kmod-zfs-devel-2.4.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root  25K May  3 20:56 kmod-zfs-devel-5.4.69-2.4.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root  33K May  3 20:58 libnvpair3-2.4.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root  27K May  3 20:58 libuutil3-2.4.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 228K May  3 20:58 libzfs7-2.4.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 393K May  3 20:58 libzfs7-devel-2.4.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 1.5M May  3 20:58 libzpool7-2.4.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root  33M May  3 20:56 zfs-2.4.1-1.el7.src.rpm
-rw-r--r-- 1 root root 752K May  3 20:58 zfs-2.4.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 7.9M May  3 20:58 zfs-debuginfo-2.4.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root  33M May  3 20:56 zfs-dkms-2.4.1-1.el7.noarch.rpm
-rw-r--r-- 1 root root  33M May  3 20:56 zfs-dkms-2.4.1-1.el7.src.rpm
-rw-r--r-- 1 root root  13K May  3 20:58 zfs-dracut-2.4.1-1.el7.noarch.rpm
-rw-r--r-- 1 root root  33M May  3 20:54 zfs-kmod-2.4.1-1.el7.src.rpm
-rw-r--r-- 1 root root  16M May  3 20:56 zfs-kmod-debuginfo-2.4.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root  28M May  3 20:58 zfs-test-2.4.1-1.el7.x86_64.rpm

从这些rpm包的名字可以看出,zfs文件系统是和操作系统内核强相关的,因此,在这里做一个总结,即使是使用rpm包安装,也必须要编译或者yum安装大于等于4.18的版本

bash 复制代码
---> Package zfs-dkms.noarch 0:2.4.1-1.el7 will be installed
--> Processing Dependency: kernel-devel >= 4.18 for package: zfs-dkms-2.4.1-1.el7.noarch
--> Processing Dependency: kernel-devel >= 4.18 for package: zfs-dkms-2.4.1-1.el7.noarch
--> Processing Dependency: kernel-uname-r >= 4.18 for package: zfs-dkms-2.4.1-1.el7.noarch
--> Processing Dependency: kernel-uname-r >= 4.18 for package: zfs-dkms-2.4.1-1.el7.noarch
--> Processing Conflict: zfs-dkms-2.4.1-1.el7.noarch conflicts kernel-devel < 4.18
No package matched to upgrade: zfs-dkms
--> Processing Conflict: zfs-dkms-2.4.1-1.el7.noarch conflicts kernel-uname-r < 4.18
No package matched to upgrade: zfs-dkms
--> Finished Dependency Resolution
Error: Package: zfs-dkms-2.4.1-1.el7.noarch (/zfs-dkms-2.4.1-1.el7.noarch)
           Requires: kernel-devel >= 4.18
           Installed: kernel-devel-3.10.0-1160.118.1.el7.x86_64 (@updates)
               kernel-devel = 3.10.0-1160.118.1.el7
           Available: kernel-devel-3.10.0-1062.el7.x86_64 (dsfdsf)
               kernel-devel = 3.10.0-1062.el7
           Available: kernel-devel-3.10.0-1160.el7.x86_64 (base_x86_64)
               kernel-devel = 3.10.0-1160.el7
           Available: kernel-devel-3.10.0-1160.2.1.el7.x86_64 (updates)
               kernel-devel = 3.10.0-1160.2.1.el7
           Available: kernel-devel-3.10.0-1160.2.2.el7.x86_64 (updates)
               kernel-devel = 3.10.0-1160.2.2.el7
           Available: kernel-devel-3.10.0-1160.6.1.el7.x86_64 (updates)
               kernel-devel = 3.10.0-1160.6.1.el7
           Available: kernel-devel-3.10.0-1160.11.1.el7.x86_64 (update
相关推荐
GanGanGanGan_1 小时前
Rocky Linux 9 + XFCE 编译安装 fcitx5 + Rime 教程
linux·centos
代码中介商1 小时前
Linux TCP 网络编程完全指南:从三次握手到高并发服务器
服务器·网络·tcp/ip
dLYG DUMS2 小时前
DBeaver连接本地MySQL、创建数据库表的基础操作
数据库·mysql
咖喱o2 小时前
QinQ/VLAN Stacking
linux·运维·服务器·网络
xiaoye-duck2 小时前
《Linux系统编程》Linux指令 (二):从零开始理解Linux基础指令
linux
月白风清江有声2 小时前
安装mingw 版 cmake
linux
苍煜3 小时前
MySQL分库分表和ES到底怎么选?
数据库·mysql·elasticsearch
茉莉玫瑰花茶3 小时前
Qt 信号与槽 [ 1 ]
开发语言·数据库·qt
sduwcgg3 小时前
IQ-Learn 在 RTX 3090 服务器上的环境配置与踩坑记录
运维·服务器