Linux中解决 zfs 安装后无法加载和使用,报错类似如下:modprobe: FATAL: Module zfs not found.

Linux中解决 zfs 安装后无法加载和使用,报错类似如下:modprobe: FATAL: Module zfs not found.

在这里插入图片描述

# modprobe zfs
modprobe: FATAL: Module zfs not found.

解决办法:

yum remove zfs spl kmod-zfs -y

yum update -y --skip-broken

os_v=$(cat /etc/redhat-release) # cat /etc/issue 
os_v=$(echo ${os_v#*.})
os_v=$(echo ${os_v%.*})
yum install http://download.zfsonlinux.org/epel/zfs-release.el7_${os_v}.noarch.rpm -y

yum install -y https://zfsonlinux.org/epel/zfs-release-2-3$(rpm --eval "%{dist}").noarch.rpm



yum install zfs kmod-zfs -y

modprobe zfs

参考资料:

Step 1: Clean up and Reinstall DKMS Modules
Most of the time, the ZFS on Linux messes up the DKMS modules after the update. I suggest to clean up and reinstall DKMS modules once again. As of December 12, 2018, the ZFS on Linux will remove all of the DKMS modules for no reason.

First, check your DKMS status. You will need to clean up the DKMS if it is empty (nothing is installed), orphan (library is installed, but none of them is attached to any kernel) or multiple (multiple kernels installed). If it is clean (single kernel only), you may skip this step. If you are using ZFS on Linux ver 0.7.x, your DKMS will contain two modules (zfs and spl). If you are using ver. 0.8.x, your DKMS will contain one module only (zfs).

#dkms status

In general, all you want is only one version of DKMS modoule is installed, and it is attached to one kernel only. If you see multiple versions of DKMS modules, or multiple kernels, that’s bad.

#An example of dirty DKMS status (This is bad):
spl, 0.7.12, 3.10.0-862.14.4.el7: installed (original_module exists) (WARNING! Diff between built and installed module!)
spl, 0.7.12, 3.10.0-957.1.3.el7: installed (original_module exists)
zfs, 0.7.12, 3.10.0-862.14.4.el7: installed (original_module exists) (WARNING! Diff between built and installed module!)
zfs, 0.7.12, 3.10.0-957.1.3.el7: installed (original_module exists)
#An example of empty DKMS status (This is bad):
(empty)

#An example of DKMS status without kernal (This is bad):
zfs, 0.7.12: added
spl, 0.7.12: added

#An example of clean DKMS status (This is good):
spl, 0.7.12, 3.10.0-957.1.3.el7.x86_64, x86_64: installed
zfs, 0.7.12, 3.10.0-957.1.3.el7.x86_64, x86_64: installed 

or 

spl, 0.7.12, 3.10.0-957.1.3.el7.x86_64, x86_64: installed (original_module exists)
zfs, 0.7.12, 3.10.0-957.1.3.el7.x86_64, x86_64: installed (original_module exists)

or 

zfs, 0.8.3, 3.10.0-1127.el7.x86_64, x86_64: installed (original_module exists)
In my example above, my ZFS on Linux is 0.7.12, my old kernel is 3.10.0-862.14.4.el7, my new kernel is 3.10.0-957.1.3.el7. Your version may be different.

If your situation is something like the following:

Error! Could not locate dkms.conf file.
File: /var/lib/dkms/zfs/0.8.2/source/dkms.conf does not exist.

That means you have multiple versions of dkms-ZFS modules installed in your system. In my case, the 0.8.3 is running, and the old (0.8.2) is still available. Check the folder (/var/lib/dkms/zfs/) to see if any old libraries need to be removed.

#Currently running: dkms ZFS 0.8.3, kernel 3.10.0-1062.18.1.el7.x86_64

cd /var/lib/dkms/zfs/

#ls -al
total 12K
0.8.2 <---- Delete this 0.8.3 kernel-3.10.0-1062.1.2.el7.x86_64-x86_64 -> 0.8.2/3.10.0-1062.1.2.el7.x86_64/x86_64 <---- Delete this kernel-3.10.0-1062.4.1.el7.x86_64-x86_64 -> 0.8.2/3.10.0-1062.4.1.el7.x86_64/x86_64 <---- Delete this kernel-3.10.0-1062.4.3.el7.x86_64-x86_64 -> 0.8.2/3.10.0-1062.4.3.el7.x86_64/x86_64 <---- Delete this kernel-3.10.0-1062.7.1.el7.x86_64-x86_64 -> 0.8.2/3.10.0-1062.7.1.el7.x86_64/x86_64 <---- Delete this kernel-3.10.0-1062.9.1.el7.x86_64-x86_64 -> 0.8.3/3.10.0-1062.9.1.el7.x86_64/x86_64 <---- Delete this

You may want to remove both ZFS and SPL DKMS modules first, then reinstall them:

#If your version is 0.7.x:
sudo dkms remove zfs/0.7.12 --all; 
sudo dkms remove spl/0.7.12 --all; 


#If your version is 0.8.x:
sudo dkms remove zfs/0.8.3 --all; 

Sometimes, you will need to remove the old kernel manually:

sudo dkms remove zfs/0.7.12 -k 3.10.0-862.14.4.el7.x86_64; 
sudo dkms remove spl/0.7.12 -k 3.10.0-862.14.4.el7.x86_64;

Time to reinstall them:

#Don't forget to use the version that matches your system. In my situation, it was 0.7.12 / 0.8.3

#0.7.x:
sudo dkms --force install spl/0.7.12; 
sudo dkms --force install zfs/0.7.12;

#0.8.x:
sudo dkms --force install zfs/0.8.3;

Run the DKMS status again. You should see both ZPL and SPL are attached to the new kernel:

#If your version is 0.7.x:
spl, 0.7.12, 3.10.0-957.1.3.el7.x86_64, x86_64: installed
zfs, 0.7.12, 3.10.0-957.1.3.el7.x86_64, x86_64: installed

#If your version is 0.8.x:
zfs, 0.8.3, 3.10.0-1127.el7.x86_64, x86_64: installed

Try to load the ZFS module and import your ZFS data:

sudo /sbin/modprobe zfs
sudo zpool import -a

If everything looks good, you can reboot your system and test to see if the ZFS is loaded automatically or not. Once everything is okay, remove the old kernel from the system.

sudo package-cleanup --oldkernels --count=1 -y

That’s it, you are good to go.

Step 2: Reinstall ZFS packages
If you have tried the first step and it didn’t work. You may want to reinstall the ZFS packages. Here is a typical error message:

You try to import the ZFS data and the system complains:

#zpool import -a
The ZFS modules are not loaded.
Try running '/sbin/modprobe zfs' as root to load them.

So you try to load the ZFS module and the system complains again:

#/sbin/modprobe zfs
modprobe: FATAL: Module zfs not found.
or
modprobe: ERROR: could not insert 'zfs': Invalid argument

What you need to do is to erase all the ZFS and related packages:

yum erase zfs zfs-dkms libzfs2 spl spl-dkms libzpool2 -y

Please reboot the system. This step is very important.

reboot

After that, try to install ZFS again.

yum install zfs -y

If the system complaints about mismatched dependent packages, try to remove the affected packages first and run the installation again.

After the installation, try to start the ZFS module:

/sbin/modprobe zfs
zpool import -a

If the ZFS is up and running, please clean up your DKMS from step 1. If it complains again, please follow the steps below:

Reboot
Clear the cache of the yum repository and try to update the system again. (sudo yum clean all)
Reboot to the latest kernel
Erase the ZFS and related packages, try it again.
Keep in mind that ZFS on Linux is based on DKMS, a very buggy and unreliable platform. Sometimes when you uninstall and install the packages, don’t expect that it will do the same thing as fresh install. Before you send your server to the landfill, try this:

Check the dkms status:

#dkms status
#version 0.7.x
zfs, 0.7.2: added
spl, 0.7.2: added

#version 0.8.x
zfs, 0.8.3: added

If you see this message, that means the ZFS packages have been installed, but the DKMS doesn’t know how to use it. You will need to tell DKMS about it:

#version 0.7.x
dkms --force install zfs/0.7.2
dkms --force install spl/0.7.2

#version 0.8.x
dkms --force install zfs/0.8.3
#Try to start ZFS again.
/sbin/modprobe zfs
zpool import -a

If you already tried it for more than 3 times without any luck, don’t waste your time. You may want to bring the ZFS disks to a different server. The new server should be able to recognize the ZFS disks. For the original server, you can connect to the ZFS disks on the new server via NFS using the original path. That will minimize the impact of changes.

Keep in mind that the ZFS version is very important. The server with newer ZFS version can read the ZFS disks created in older ZFS versions. You can always check the ZFS versions by running the following:

#Get the version of the host:
sudo zfs upgrade -v
sudo zpool upgrade -v


#Get the version of the ZFS disks:
sudo zfs get version
sudo zpool get version

Install ZFS
So you already installed the system on eMMC or SD? You might want to use ZFS on the hard disk(s)! We assume rootfs is already on eMMC (or microSD Card) and you want to store your data on HDDs in ZFS pool.

Note

This wiki does not cover root-on-zfs. (Although it should be also possible.)

Note

If this method fails you can try to build directly ZFS on your system with the following instructions.

Step 1 - Install ZFS

sudo armbian-config

Go to Software and install headers.

Kernel Headers

Once kernel headers installed, install ZFS with the following command:

sudo apt install zfs-dkms zfsutils-linux

Optional:

sudo apt install zfs-auto-snapshot

Reboot.

Step 2 - Prepare partitions
Use fdisk of gdisk to create necessary partitions on your hard drive. This is beyond scope of this wiki. When ready look for assigned uuids:

ls -l /dev/disk/by-partuuid/

Step 3 - Create ZFS pool

sudo zpool create -o ashift=12 -m /mypool mypool mirror /dev/disk/by-partuuid/abc123 /dev/disk/by-partuuid/xyz789
sudo zfs set atime=off mypool
sudo zfs set compression=on mypool

Of course you may use more disks and create raidz instead of mirror. Your choice. 😃

Note: Do not use /dev/sdXY names. Use uuids only. This way your system will still work when you remove a disk or change order of disks.

If your disks are SSDs, enable trim support:

sudo zpool set autotrim=on mypool

Step 4 - Reboot
After reboot make sure the pool was imported automatically:

zpool status

You should now have working system with root on eMMC and ZFS pool on HDD.

DKMS and kABI-tracking kmod style packages are provided for x86_64 RHEL- and CentOS-based distributions from the OpenZFS repository. These packages are updated as new versions are released. Only the repository for the current minor version of each current major release is updated with new packages.

To simplify installation, a zfs-release package is provided which includes a zfs.repo configuration file and public signing key. All official OpenZFS packages are signed using this key, and by default yum or dnf will verify a package’s signature before allowing it be to installed. Users are strongly encouraged to verify the authenticity of the OpenZFS public key using the fingerprint listed here.

Key location: /etc/pki/rpm-gpg/RPM-GPG-KEY-openzfs (previously -zfsonlinux)
Current release packages: EL7, EL8, EL9
Archived release packages: see repo page
Signing key1 (EL8 and older, Fedora 36 and older) pgp.mit.edu / direct link
Fingerprint: C93A FFFD 9F3F 7B03 C310 CEB6 A9D5 A1C0 F14A B620
Signing key2 (EL9+, Fedora 37+) pgp.mit.edu / direct link
Fingerprint: 7DC7 299D CF7C 7FD9 CD87 701B A599 FD5E 9DB8 4141

For EL7 run:

yum install https://zfsonlinux.org/epel/zfs-release-2-3$(rpm --eval "%{dist}").noarch.rpm

and for EL8 and 9:

dnf install https://zfsonlinux.org/epel/zfs-release-2-3$(rpm --eval "%{dist}").noarch.rpm

After installing the zfs-release package and verifying the public key users can opt to install either the DKMS or kABI-tracking kmod style packages. DKMS packages are recommended for users running a non-distribution kernel or for users who wish to apply local customizations to OpenZFS. For most users the kABI-tracking kmod packages are recommended in order to avoid needing to rebuild OpenZFS for every kernel update.

DKMS
To install DKMS style packages issue the following commands. First add the EPEL repository which provides DKMS by installing the epel-release package, then the kernel-devel and zfs packages. Note that it is important to make sure that the matching kernel-devel package is installed for the running kernel since DKMS requires it to build OpenZFS.

For EL6 and 7, separately run:

yum install -y epel-release
yum install -y kernel-devel
yum install -y zfs

And for EL8 and newer, separately run:

dnf install -y epel-release
dnf install -y kernel-devel
dnf install -y zfs

Note

When switching from DKMS to kABI-tracking kmods first uninstall the existing DKMS packages. This should remove the kernel modules for all installed kernels, then the kABI-tracking kmods can be installed as described in the section below.

kABI-tracking kmod
By default the zfs-release package is configured to install DKMS style packages so they will work with a wide range of kernels. In order to install the kABI-tracking kmods the default repository must be switched from zfs to zfs-kmod. Keep in mind that the kABI-tracking kmods are only verified to work with the distribution-provided, non-Stream kernel.

For EL6 and 7 run:

yum-config-manager --disable zfs
yum-config-manager --enable zfs-kmod
yum install zfs

And for EL8 and newer:

dnf config-manager --disable zfs
dnf config-manager --enable zfs-kmod
dnf install zfs

By default the OpenZFS kernel modules are automatically loaded when a ZFS pool is detected. If you would prefer to always load the modules at boot time you can create such configuration in /etc/modules-load.d:

echo zfs >/etc/modules-load.d/zfs.conf

Note

When updating to a new EL minor release the existing kmod packages may not work due to upstream kABI changes in the kernel. The configuration of the current release package may have already made an updated package available, but the package manager may not know to install that package if the version number isn’t newer. When upgrading, users should verify that the kmod-zfs package is providing suitable kernel modules, reinstalling the kmod-zfs package if necessary.

Previous minor EL releases
The current release package uses “ r e l e a s e v e r ” r a t h e r t h a n s p e c i f y a p a r t i c u l a r m i n o r r e l e a s e a s p r e v i o u s r e l e a s e p a c k a g e s d i d . T y p i c a l l y “ {releasever}” rather than specify a particular minor release as previous release packages did. Typically “ releaseverratherthanspecifyaparticularminorreleaseaspreviousreleasepackagesdid.Typically{releasever}” will resolve to just the major version (e.g. 8), and the resulting repository URL will be aliased to the current minor version (e.g. 8.7), but you can specify –releasever to use previous repositories.

[vagrant@localhost ~]$ dnf list available --showduplicates kmod-zfs
Last metadata expiration check: 0:00:08 ago on tor 31 jan 2023 17:50:05 UTC.
Available Packages
kmod-zfs.x86_64                          2.1.6-1.el8                          zfs-kmod
kmod-zfs.x86_64                          2.1.7-1.el8                          zfs-kmod
kmod-zfs.x86_64                          2.1.8-1.el8                          zfs-kmod
kmod-zfs.x86_64                          2.1.9-1.el8                          zfs-kmod
[vagrant@localhost ~]$ dnf list available --showduplicates --releasever=8.6 kmod-zfs
Last metadata expiration check: 0:16:13 ago on tor 31 jan 2023 17:34:10 UTC.
Available Packages
kmod-zfs.x86_64                          2.1.4-1.el8                          zfs-kmod
kmod-zfs.x86_64                          2.1.5-1.el8                          zfs-kmod
kmod-zfs.x86_64                          2.1.5-2.el8                          zfs-kmod
kmod-zfs.x86_64                          2.1.6-1.el8                          zfs-kmod
[vagrant@localhost ~]$

In the above example, the former packages were built for EL8.7, and the latter for EL8.6.

Testing Repositories
In addition to the primary zfs repository a zfs-testing repository is available. This repository, which is disabled by default, contains the latest version of OpenZFS which is under active development. These packages are made available in order to get feedback from users regarding the functionality and stability of upcoming releases. These packages should not be used on production systems. Packages from the testing repository can be installed as follows.

For EL6 and 7 run:

yum-config-manager --enable zfs-testing
yum install kernel-devel zfs

And for EL8 and newer:

dnf config-manager --enable zfs-testing
dnf install kernel-devel zfs

Note

Use zfs-testing for DKMS packages and zfs-testing-kmod for kABI-tracking kmod packages.

  • 9
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代码讲故事

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值