How to install zfs on CentOS7

WARN: ZFS module does NOT with new kernel. File system xfs is better. Using lvm is a good option.

  1. Install epel-release and setup zfs repository.
sudo yum -y install epel-release

sudo yum localinstall --nogpgcheck http://archive.zfsonlinux.org/epel/zfs-release.el7.noarch.rpm

  1. update and reboot
sudo yum -y update

sudo shutdown -r now

  1. install kernel-dev zfs
$ sudo yum install kernel-devel zfs

$ sudo modprobe zfs

$ sudo lsmod |grep zfs

zfs 2713912 4

zunicode 331170 1 zfs

zavl 15236 1 zfs

zcommon 55411 1 zfs

znvpair 93227 2 zfs,zcommon

spl 92223 3 zfs,zcommon,znvpair

  1. create a zpool
$ ls /dev/vd*

/dev/vda  /dev/vda1  /dev/vda2  /dev/vdb  /dev/vdb1  /dev/vdb9

$ sudo zpool create -f <pool name> /dev/vdb

  1. add a new disk to zpool (This disk cannot be removed after add. Only spare disk can be removed)
$ ls /dev/vd*

/dev/vda  /dev/vda1  /dev/vda2  /dev/vdb  /dev/vdb1  /dev/vdb9 /dev/vdc

$ sudo zpool add<pool name> /dev/vdc

NOTE: if zpool cannot be mounted automatically after reboot, running the following command can fix it.

sudo systemctl preset zfs-import-cache zfs-import-scan zfs-mount zfs-share zfs-zed zfs.target
  1. Import existed pool.
\# show availabe zpool
$ sudo zpool import

\# import zpool
$ sudo zpool import <zpool id>
Written on November 5, 2016