DEV Community

Rob Porter
Rob Porter

Posted on • Updated on

Installing ZFS on CentOS

Notes: I wrote this documentation around 2013 as internal documentation at Weever Apps for setting up RAID-Z as a method of making very quick backups of MySQL. Since we no longer use this setup and the documentation will never be used again, I felt it might be a good idea to post it out there for those who might find some use in it. Using RAID-Z for MySQL was amazing, and never failed us, and allowed hourly snapshot-based backups with no downtime. We've since moved to AWS RDS instances though.

This will be part of multiple posts that combined will allow one to build a RAID-Z setup for MySQL. Or, at least it used to be able to! While this is geared towards Azure, I'm sure it would work anywhere.

Article series

  1. Installing ZFS on CentOS
  2. Creating a RAID-Z Drive for MySQL with ZFS on CentOS
  3. Setting up RAID-Z for use in a MySQL Master-Master Replicator Pattern
  4. Creating a ZFS Image of a MySQL Data Directory

As I add more parts over the next few days I'll add links here.

Creating the VM

First, create a VM in Azure using the CentOS image. It needs to be a minimum of 2 cores to be set up with RAID-Z.

Make sure it is inside the Cloud Service of the application server VMs you wish to connect it to.

User name for the initial user should be azureadmin, but you should be sure to change the password and document it somewhere safe.

If you wish to make use of Load Balancing, be sure to create an Availability Set when asked, or select one that it will be used with if we're adding another load balanced instance.

After logging in via SSH...

First we need to be sudo.

sudo su

Next we're going to need to get ZFS installed, which will require some set up. First, we need to disable SELinux for this to work, at least until ZFS software gets updated to support it (or visa versa). First command disables it for now, second disables it for good.

echo 0 >/selinux/enforce
vim /etc/selinux/config

And change SELINUX= to permissive.

Next we need some new kernel libraries in yum so we need to edit the config file to remove kernel exceptions.

vim /etc/yum.conf

Find the line with exclude=kernel* and comment it out with a hash (#).

Then we're going to install some stuff.

yum groupinstall "Development Tools"
yum install kernel-devel zlib-devel libuuid-devel libblkid-devel libselinux-devel parted lsscsi nano mdadm bc

Next go to and click on CentOS link, which should have commands like these two:

sudo yum localinstall --nogpgcheck
sudo yum install zfs

This will take a few minutes.

Now we'll load the module.

modprobe zfs

To make sure it's there and working, we'll check using this command.

lsmod | grep -i zfs

Let's set it up so it'll load on boot.

vim /etc/sysconfig/modules/zfs.modules

Paste into this file:


if [ ! -c /dev/zfs ] ; then
        exec /sbin/modprobe zfs >/dev/null 2>&1

Save the file (:wq) and then we'll do this:

chmod +x /etc/sysconfig/modules/zfs.modules

Let's now test that it works, and reboot.


Then make sure we get output from:

lsmod | grep -i zfs

If so, ZFS is installed!

Is something badly out of date? Did this work for you? Please post a comment to help others who might use this for guidance.

Top comments (0)