Install and Configure ZFS – CentOS 7.6

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

Why 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.

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

Issue the install command

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

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

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 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

To create a mirrored pool issue the following:

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

zfs zpool list

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

drive mount points

That’s it.