This article is the second part of the ZFS series of articles and this time we would like to focus on the concept of pooled storage and its component parts.
ZFS pool (Zpool) is a collection of one or more virtual devices, referred to as vdevs that appear as a single storage device accessible to the file system. The Zpool is the highest container in the whole ZFS system.
There are two types of data structures created by ZFS:
Datasets – portions of space emulating a regular file system. Datasets can be nested. In this case, such a dataset is considered as a directory for the file system navigation purposes. However, the nested dataset can possess different settings for snapshots, compression, deduplication and so on.
Volumes (zvols) – block devices created from the Zpool storage space. For example, iSCSI or Fibre Channel target created for a different system. Nesting of a volume within a zvol is not possible due to the fact that ZFS is not aware of what kind of file system is used on a block device nor can access and manage it.
It is very important to select redundancy level for vdevs, that is, a single drive, mirror, RAID-Z1, RAID-Z2, and RAID-Z3 configurations into which the physical disks will be grouped. Note that after creating a Zpool, it may not be possible to add additional disks to the vdev due to the fact that most vdev types prohibit such an operation. Exceptions to this are mirrors where vdev can be equipped with additional disks. However, this operation increases only the security level of vdev.
Please bear in mind that you are able to add additional vdevs to expand the Zpool. The storage space allocated to the Zpool cannot be decreased. However, you are able to exchange the drives in vdevs that are parts of the Zpool.
If there is a need to change the layout of the Zpool, the data should be backed up and the Zpool destroyed.
Errors and disk failures management
When a data block with a mismatched checksum is detected by the system, ZFS tries to retrieve the data from the mirror or parity disk. If it is able to provide the correct data, in addition to provide data to the application requesting the information, the system will amend the incorrect data on the disk with incorrect checksum. This particular operation is known as self-healing and is performed automatically by the system.
If a disk in a Zpool fails, the pool is set to the degraded state. The data on the failed device is then retrieved from the remaining disks and transferred to the spare device but first the spare disk replaces the failed one. The operation related to calculating and writing missing data to the new disk is called resilvering. Once the restoration operation is complete, the status of the Zpool changes back to online. In case when multiple disks have failed and if there are not enough redundant devices, the Zpool changes its state into unavailable.
Migrating zpools between different systems
Before moving a Zpool to another system, it has to be exported first. The export operation means that the Zpool’s datasets or zvols are unmounted and the devices are locked and marked as exported so that disk subsystems cannot use them. In turn, the import operation will cause that the datasets or zvols will be mounted automatically. This way, the Zpool can be imported on other operating systems supporting ZFS.
It is highly recommended to perform the scrubbing operation regularly. The scrubbing operation is somewhat similar to fsck consistency check operation. While scrubbing, the data on the disk is thoroughly examined and all corrupted data is repaired together with accompanying issues. Bear in mind that it is very time-consuming and disk-intensive operation that reduces performance of the disk undergoing this operation.
After exploring the possibilities offered by the pooled storage, it is undoubtedly visible that ZFS provides highly versatile and robust capabilities for data management since the whole Zpool can be moved to a different operating system or another machine. It should be also noted that ZFS offers data retention options such as resilvering or scrubbing that are vital when it comes to keeping the data in good shape.