In this tutorial we build a completely open Storage Server using open source technologies.

OpenZFS will be installed from source as it doesn’t form part of the official CentOS repository. Installing from source does add additional complexity in the installation process but it provides us with much more flexibility and control over the file system.

Operating System: CentOS Linux v7.5 (Build 1804)
Download Link: https://www.centos.org/download/

File System: OpenZFS v0.7.9
Download Link: http://zfsonlinux.org/

Operating System Installation

A graphical user interface won’t be required for this setup, all configurations will be performed using command line, the recommendation is to perform a minimal installation of CentOS, this will reduce the patching required and minimize the security exploits. A guideline for the operating system partitioning scheme is specified in the table below, please note that this is for a minimal installation only, if you plan on installing a graphical user interface, additional applications or workloads, the partition sizes may differ. Use the partitioning scheme below as a guideline.

Operating System Partitioning
Partition File System Size
/boot/efi EFI System Parition 200MB
/boot xfs 2048MB
/ xfs 32768MB
/var xfs 8192MB
swap swap 2048MB
Operating System Configuration

Perform a minimal installation of CentOS, although a graphical environment can also be installed but it’s not really required since all configurations will be perform using commands. Once the operating system has been installed, network configurations will be performed such as setting the host name and IP Addresses on the network interface cards.

Set a static hostname to the operating system

hostnamectl set-hostname "[fully qualified domain name]" --static

[Example] Setting a hostname to the operating system

hostnamectl set-hostname "storage.astantia.com" --static

Update the operating system to the latest kernel and libraries

yum update -y

Once the update has been completed, restart the server

reboot

Install additional libraries that will be required for compiling OpenZFS and server configurations

yum install -y wget gcc kernel-devel zlib-devel libuuid-devel libblkid-devel libattr-devel ntp
Time Synchronization

Ensure that the operating system is synchronized against a reliable and accurate time server.

Enable and Start the network time protocol service

systemctl enable ntpd.service --now

The default NTP configurations contain time servers which can be synchronized against, however, they can be changed to synchronize against specific sources.

Default NTP Sources:

server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

To add a specific NTP source, add an entry in the /etc/ntp.conf file in the following format

server [IP Address or FQDN of NTP source]

[Example] Using a hostname as the NTP Source

server ntp1.astantia.com

[Example] Using an IP Address as the NTP Source

server 192.168.20.1
OpenZFS Installation and Configuration

We need a working directory which will be used for storing and build the OpenZFS file system, any directory can be used. In this example we create this working directory in the root file system called “software”.

mkdir -p /software/{zfs,spl}

In order to install the OpenZFS File System, we need 2 components, the Solaris Portability Layer (SPL) Source Files and the Z File System (ZFS) Source files. Prior to compiling and installing OpenZFS, the Solaris Portability Layer (SPL) must be built and installed.

Download the Solaris Portability Layer (SPL) Libraries

wget https://github.com/zfsonlinux/zfs/releases/download/zfs-0.7.9/spl-0.7.9.tar.gz -P /software/spl/

Download the OpenZFS Libraries

wget https://github.com/zfsonlinux/zfs/releases/download/zfs-0.7.9/zfs-0.7.9.tar.gz -P /software/zfs

Extract both the Solaris Portability Layer and the OpenZFS Libraries

tar -zxvf /software/spl/spl-0.7.9.tar.gz -C /software/spl/
tar -zxvf /software/zfs/zfs-0.7.9.tar.gz -C /software/zfs/

Compile and install the Solaris Portability Layer (SPL)

cd /software/spl/spl-0.7.9
./configure
make
make install

Compile and install OpenZFS

cd /software/zfs/zfs-0.7.9
./configure
make
make install
Note: Both the Solaris Portability Layer (SPL) and OpenZFS were installed using the default configurations. Due to these being installed from source, a lot of options can be changed such as the installation directory and so on. To view all the configuration options, navigate to the source files and execute the command: ./configure –help

Enable and Start OpenZFS Services

systemctl enable zfs-import-cache.service --now
systemctl enable zfs-import-scan.service --now
systemctl enable zfs-import.target --now
systemctl enable zfs-mount.service --now
systemctl enable zfs-share.service --now
systemctl enable zfs.target zfs-zed.service --now

Prior to creating the ZFS File System and allocating drives to it, ensure that there is are no existing partitions or metadata on those drives. This is especially true if the disks were previously used.

wipefs -a -f /dev/[disk number]

[Example] Clearing a single disk

wipefs -a -f /dev/sdb

[Example] Clearing a multiple disks

wipefs -a -f /dev/sdb /dev/sdc

[Example] Clearing a range of disk from /dev/sdb to /dev/sdm, in total 12 disks

wipefs -a -f /dev/sd{b..m}

Create ZFS File System on disks

zpool create "storage" -m "/storage" /dev/sd{b..m}

List ZFS File Systems

[root@storage bomc]# zpool list
NAME      SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
storage    87T   504K  87.0T         -     0%     0%  1.00x  ONLINE  -