Lampros - Weird Bricks

How to install ZFS on CentOS 7.3

30 April, 2017 | CentOS

Hello internet,

ZFS is an advanced filesystem originally developed by Sun. It has a ton of advantages, including a built in volume manager, compression live snapshots etc. It's been ported to FreeBSD and Linux. 

1. These are my notes on how I got it installed on CentOS 7.3:

cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core)

2. Install the ZFS repository package for CentOS 7.3:

yum -y install

3. Update your /etc/yum.repos.d/zfs.repo:

We want to install the kABI recommended packages so ZFS won't have to be rebuilt every time the kernel is updated. 

To do this, we need to edit the /etc/yum.repos.d/zfs.repo and disable the [zfs] repository and enable the [zfs-kmod].

When done the first two sections of your file should look like this:

name=ZFS on Linux for EL7 - dkms

name=ZFS on Linux for EL7 - kmod

3. Install ZFS:

yum -y install zfs

4. Reboot your system:

reboot now

5. Check to see that the ZFS module is already loaded using lsmod | grep -i zfs:

You should get something like this:

lsmod | grep -i zfs
zfs 2709477 0
zunicode 331170 1 zfs
zavl 15236 1 zfs
zcommon 55411 1 zfs
znvpair 93227 2 zfs,zcommon
spl 92225 3 zfs,zcommon,znvpair

Note: If you don't get the above output, load the module manually with: modprobe zfs

6. Create a fake device:

Let's create a loop device to use it as a dedicated hard drive for our testing - we'll make it small, only 2GB and name
it zfs01.img:

cd /root
truncate -s 2G zfs01.img

7. Create a ZFS pool using our fake dedicated drive:

zpool create my-zfs-pool /root/zfs01.img

The above command has zero output. However, a lot was done - the file was formatted and mounted as /my-zfs-pool.

Check this by running df -hT:

df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 xfs 80G 1.3G 79G 2% /
devtmpfs devtmpfs 991M 0 991M 0% /dev
tmpfs tmpfs 1001M 0 1001M 0% /dev/shm
tmpfs tmpfs 1001M 8.3M 993M 1% /run
tmpfs tmpfs 1001M 0 1001M 0% /sys/fs/cgroup
tmpfs tmpfs 201M 0 201M 0% /run/user/0
my-zfs-pool zfs 2.0G 0 2.0G 0% /my-zfs-pool

Impressive isn't it?

8. Make sure it starts after you reboot your system:

Load the systemd presets for ZFS so that we enable all services - this will make the mounts persist after rebooting:

systemctl preset zfs-import-cache zfs-import-scan zfs-mount zfs-share zfs-zed

Reboot the system to test this:

reboot now

After reboot:

df -hT | egrep 'zfs|Filesystem'
Filesystem Type Size Used Avail Use% Mounted on
my-zfs-pool zfs 2.0G 0 2.0G 0% /my-zfs-pool

All done!