Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Install and Configure ZFS – CentOS 7.6

We’ll look at installing and configuring ZFS on CentOS 7.6 today.

Why ZFS?

"It is an enterprise-ready open source file system and volume manager with unprecedented flexibility and an uncompromising commitment to data integrity. ZFS is a truly next-generation file system that eliminates most, if not all of the shortcomings found in legacy file systems and hardware RAID devices. Once you go ZFS, you will never want to go back." - https://www.freenas.org/zfs/

Installation

Start off by installing the repo rpm for ZFS, we’ll be installing with the kABI-tracking kmod which should suffice for most unless you use a custom non-OS shipped kernel. With kABI you won’t have to recompile the ZFS module after every update.

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

Install the kABI-tracking kmod, modify the zfs repo file. Disable [zfs] and enable [zfs-kmod]. Edit the repo file located at /etc/yum.repos.d/zfs.repo

[zfs]
name=ZFS on Linux for EL7 - dkms
baseurl=http://download.zfsonlinux.org/epel/7.4/$basearch/
enabled=0
metadata_expire=7d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux

[zfs-kmod]
name=ZFS on Linux for EL7 - kmod
baseurl=http://download.zfsonlinux.org/epel/7.4/kmod/$basearch/
enabled=1
metadata_expire=7d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux

Issue the install command

sudo yum install zfs

You now need to reboot the server to the load the ZFS modules

sudo reboot

To verify that the ZFS modules have been loaded issue the following command:

sudo lsmod | grep zfs

ZFS module load status

Creating and Configuring Pools

Pool Naming Do’s and Don’ts

ZFS has strict rules about how you can name your pools, they’re listed below copied straight from Oracle’s documentation:

Each ZFS component, such as datasets and pools, must be named according to the following rules:

  • Each component can only contain alphanumeric characters in addition to the following four special characters:
    • Underscore (_)
    • Hyphen (-)
    • Colon (:)
    • Period (.)
  • Pool names must begin with a letter, except for the following restrictions:
    • The beginning sequence c[0-9] is not allowed.
    • The name log is reserved.
    • A name that begins with mirror, raidz, raidz1, raidz2, raidz3, or spare is not allowed because these names are reserved.
    • Pool names must not contain a percent sign (%).
  • Dataset names must begin with an alphanumeric character.
  • Dataset names must not contain a percent sign (%).

In addition, empty components are not allowed.

Source: https://docs.oracle.com/cd/E19253-01/819-5461/gbcpt/index.html

Creating a pool

It is pretty straight forward to create a pool. Issue the following command to get a list of drives attached to your server

fdisk -l

fdisk list disks

On this machine, we have two 10TB drives that we’ll be adding to the pool, /dev/sdc and /dev/sdd.

Issue the following to create a striped pool

sudo zpool create POOLNAME /dev/sdc /dev/sdd

To create a mirrored pool issue the following:

sudo zpool create POOLNAME mirror /dev/sdc /dev/sdd

To verify that the desired pool has been created issue the following:

sudo zpool list

zfs zpool list

Pools are automatically mounted, issue the following command to verify the mounts

df -h

drive mount points

That’s it.