“ZFS on Linux”: The ZFS modules are not loaded. Try running ‘/sbin/modprobe zfs’ as root to load them.

ZFS on Linux is a poorly designed software solution to get ZFS up and running in Linux environments. Unlike FreeBSD, ZFS does not work with the Linux kernel natively. The developers of ZFS on Linux come up a crappy hack. By injecting the ZFS into the kernel via DKMS, Linux kernel will understand what is ZFS. It works very well, and it really works with a single assumption: The system will never be updated or rebooted after installing ZFS on Linux. So what will happen after you update the system (e.g., kernel, ZFS on Linux packages) and the system got rebooted? There is a good chance that your ZFS module will not be loaded. Otherwise you won’t be reading this article, right?

You just can’t assume that a MINI works like a semi truck. MINI was created for a totally different purposes. If you want to use a MINI like a semi-truck, then you have to accept the corresponding risks.

Event What will happen after reboot? What do you need to do?
You update kernel first, then ZFS on Linux afterward Your system will load the ZFS modules. Remove the old kernels from DKMS database. Rebuild the SPL and ZFS modules with the new kernel in the DKMS database.
You update ZFS on Linux first, then kernel afterward If your system boot into the new kernel (which is default), your system WILL NOT load the ZFS modules. Remove and install the ZFS and DKMS packages. Remove the old kernels from DKMS database. Rebuild the SPL and ZFS modules with the new kernel in the DKMS database.
You update ZFS on Linux only. Kernel has not been updated. Your system will load the ZFS modules. Remove the old kernels from DKMS database. Rebuild the SPL and ZFS modules with the new kernel in the DKMS database.
You update kernel only. ZFS on Linux has not been updated Your system will load the ZFS modules. Remove the old kernels from DKMS database. Rebuild the SPL and ZFS modules with the new kernel in the DKMS database.

Long story short, below is how you get your data back:


You reboot your computer after a system upgrade (either updating to a new kernel, or updating the ZFS on Linux package, or both), and you notice that the ZFS is not loaded, i.e.,

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


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



#dkms status
spl, 0.7.11, 3.10.0-862.11.6.el7: installed (original_module exists)
spl, 0.7.11, 3.10.0-862.14.4.el7: installed (original_module exists) (WARNING! Diff between built and installed module!)
zfs, 0.7.11, 3.10.0-862.11.6.el7: installed (original_module exists)
zfs, 0.7.11, 3.10.0-862.14.4.el7: installed (original_module exists) (WARNING! Diff between built and installed module!)

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 mismatch 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, you may move to next section. If you see the following message, please follow the steps below:


sudo /sbin/modprobe zfs

modprobe: ERROR: could not insert 'zfs': Invalid argument
  1. Reboot
  2. Clear the cache of the yum repository and try to update the system again. (sudo yum clean all)
  3. Reboot to the latest kernel
  4. Erase the ZFS and related packages and try it again.

If you already tried it for more than 5 times without any luck, don’t waste your time. You may want to bring the ZFS disks to another 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

Assuming that your ZFS is up and running, we will need to check the DKMS status:

#dkms status

If you see no error message, you are good to go.

spl, 0.7.11, 3.10.0-862.14.4.el7: installed (original_module exists)
zfs, 0.7.11, 3.10.0-862.14.4.el7: installed (original_module exists)

If you see an error message like the following, you may need to rebuild the modules again:

spl, 0.7.11, 3.10.0-862.11.6.el7: installed (original_module exists)  (WARNING! Diff between built and installed module!) 
spl, 0.7.11, 3.10.0-862.14.4.el7: installed (original_module exists)
zfs, 0.7.11, 3.10.0-862.11.6.el7: installed (original_module exists)  (WARNING! Diff between built and installed module!)
zfs, 0.7.11, 3.10.0-862.14.4.el7: installed (original_module exists)
sudo dkms remove zfs/0.7.11 --all 
sudo dkms remove spl/0.7.11 --all
sudo dkms --force install spl/0.7.11
sudo dkms --force install zfs/0.7.11
sudo dkms status

Sometimes the “remove –all” option does not work as expected. You may want to remove the modules manually:

sudo dkms remove zfs/0.7.11 -k 3.10.0-862.11.6.el7.x86_64; 
sudo dkms remove spl/0.7.11 -k 3.10.0-862.11.6.el7.x86_64;

This is pretty much what I need to do on my 50 servers every month. Good luck!

Our sponsors:

Leave a Reply

Your email address will not be published. Required fields are marked *