Install ZFS on CentOS 7

Installing ZFS File System

ZFS File System support is not enabled by default on CentOS 7. That is not the only problem. ZFS is not available in the official package repository of CentOS 7. You have to install it from the official package repository of ZFS. I am installing this on a server running Centos 7.6. You may take a look at https://github.com/zfsonlinux/zfs/wiki/RHEL-and-CentOS for more details.

First check what version of CentOS 7 you’re using with the following command:

$ cat /etc/redhat-release

As you can see, I am using Centos 7.6

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

Now you have to add the official repository of ZFS on CentOS 7 with the following command:

yum install http://download.zfsonlinux.org/epel/zfs-release.el7_6.noarch.rpm

ZFS repository should be added.

There are two ways ZFS module can be loaded to the kernel, DKMS and kABI. The difference between these is that if you install DKMS based ZFS module, and then for some reason you update the kernel of your operating system, the ZFS kernel module must be recompiled again. Otherwise it won’t work. But the kABI based ZFS module has the upper hand in that it doesn’t require recompilation if the kernel of the operating system is updated.

In this article, I will install the kABI based ZFS kernel module.

When you install the ZFS repository on CentOS 7, the DKMS based repository is enabled by default. So you have to disable DKMS based repository and enable the kABI based repository.

To disable the DKMS based ZFS repository and enable kABI based ZFS repository, first open the yum configuration file of ZFS with a text editor with the following command:

$ sudo vi /etc/yum.repos.d/zfs.repo

First change the marked section of the screenshot from enabled=1 to enabled=0 to disable the DKMS based ZFS repository.

Now change the marked section of the screenshot from enabled=0 to enabled=1 to enable the kABI based ZFS repository.

Now you can install ZFS File System on your CentOS 7 with the following command:

$ sudo yum install zfs

Now press ‘y’ and then press <Enter> to continue. ZFS should be installed.

Now reboot your computer with the following command:

sudo reboot

Once your computer starts, run the following command to check whether ZFS kernel module is loaded.

sudo lsmod | grep zfs

You may not see any output. If you don’t see any output, then ZFS kernel module is not loaded. In that case, run the following command to load the ZFS kernel module manually.

$ sudo modprobe zfs

Now if you run lsmod command again, you should see ZFS kernel module loaded as shown in the screenshot below.

Creating Pools

Pools are the rough equivalent of RAID in ZFS. They are flexible and can easily be manipulated.

RAID0

RAID0 just pools your drives into what behaves like one giant drive. It can increase your drive speeds, but if one of your drives fails, you’re probably going to be out of luck.

To achieve RAID0 with ZFS, just create a plain pool.

sudo zpool create your-pool /dev/sdc /dev/sdd

RAID1/MIRROR

You can achieve RAID1 functionality with the mirror keyword in ZFS. Raid1 creates a 1-to-1 copy of your drive. This means that your data is constantly backed up. It also increases performance. Of course, you use half of your storage to the duplication.

sudo zpool create your-pool mirror /dev/sdc /dev/sdd

RAID5/RAIDZ1

ZFS implements RAID5 functionality as RAIDZ1. RAID5 requires drives in multiples of three and allows you to keep 2/3 of your storage space by writing backup parity data to 1/3 of the drive space. If one drive fails, the array will remain online, but the failed drive should be replaced ASAP.

sudo zpool create your-pool raidz1 /dev/sdc /dev/sdd /dev/sde

RAID6/RAIDZ2

RAID6 is almost exactly like RAID5, but it works in multiples of four instead of multiples of three. It doubles the parity data to allow up to two drives to fail without bringing the array down.

sudo zpool create your-pool raidz2 /dev/sdc /dev/sdd /dev/sde /dev/sdf

RAID10/Striped Mirror

RAID10 aims to be the best of both worlds by providing both a speed increase and data redundancy with striping. You need drives in multiples of four and will only have access to half of the space. You can create a pool in RAID10 by creating two mirrors in the same pool command.

sudo zpool create your-pool mirror /dev/sdc /dev/sdd mirror /dev/sde /dev/sdf

Working With Pools

There are also some management tools that you have to work with your pools once you’ve created them. First, check the status of your pools.

sudo zpool status

Updates

When you update ZFS you’ll need to update your pools, too. Your pools will notify you of any updates when you check their status. To update a pool, run the following command.

sudo zpool upgrade your-pool

You can also upgrade them all.

sudo zpool upgrade -a

Adding Drives

You can also add drives to your pools at any time. Tell zpool the name of the pool and the location of the drive, and it’ll take care of everything.

sudo zpool add your-pool /dev/sdx

Src:

http://kb.herdhan.com/a-guide-to-install-and-use-zfs-on-centos-7 

How to Use the ZFS Filesystem on Ubuntu Linux

Share

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.