Skip to content

Instantly share code, notes, and snippets.

@AoJ
Created January 22, 2023 13:27
Show Gist options
  • Save AoJ/8ccc92f423db7dd5c8a7c0423ab67e16 to your computer and use it in GitHub Desktop.
Save AoJ/8ccc92f423db7dd5c8a7c0423ab67e16 to your computer and use it in GitHub Desktop.
Introduction to Z File System (ZFS)

Introduction to Z File System (ZFS)

What is Z File System (ZFS)?

Z File System or also known as ZFS was created by Matthew Ahrens and Jeff Bonwick in 2001 to be the next generation file system for Sun Microsystem's Solaris. In 2008 ZFS was ported to FreeBSD which at the same year a ZFS ported project for Linux is also started the project name was ZFS on Linux.

However since ZFS is under the Common Development and Distribution License it can't be included directly to Linux Kernel. To solve this many Linux distributions make an offer to install ZFS from their package manager.

After Sun Microsystems wah bought by Oracle the OpenSolaris project is became close source project. All further development of ZFS now is closed source too. Due to this Ahrens and Bonwick was left Oracle and joining other companies to create OpenZFS project.

ZFS Features

Since ZFS is designed for an advanced file system then it has a lot of features such as:

  • Storage Pool
  • Copy-on-Write
  • Snapshots
  • Data integrity verification and automatic repair
  • RAID-Z
  • Maximum 16 Exabyte file size
  • Maximum 256 Quadrillion Zettabyte storage

Pooled Storage

ZFS is combining the features of a file system and volume manager like Linux Volume Manager (LVM). This mean that unlike other file systems, ZFS can create a file system that span across a series of drivers or a pool. Not only that but you can also add storage to the pool by adding another disk in Online mode, in the other side ZFS also handling the partitioning of their partition which called as a Dataset

/----------\   /----------\   /----------\   /----------\   /----------\   /----------\
|   DISK   |   |   DISK   |   |   DISK   |   |   DISK   |   |   DISK   |   |   DISK   |
\----------/   \----------/   \----------/   \----------/   \----------/   \----------/
      |              |              |              |              |              |
      |              |              |              |              |              |
/----------------------------------------\   /----------------------------------------\
|                 V D E V                |   |                 V D E V                |
\----------------------------------------/   \----------------------------------------/
                     |                                            |
                     |                                            |
/-------------------------------------------------------------------------------------\
|                                    Z  P O O L                                       |
\-------------------------------------------------------------------------------------/
                     |                                            |
                     |                                            |
/----------------------------------------\   /----------------------------------------\ 
 \----------------------------------------\   \----------------------------------------\
 |             FILE SYSTEMS               |   |               Z V O L S                |
 \----------------------------------------/   \----------------------------------------/

Copy-on-Write

Copy-on-Write is a technology on ZFS, where the new information is written to a different block. Once the write is complete, the file systems metadata is updated to point to the new information

This ensures that if the system crashes (or something else happens) while the write is taking place, the old data will be preserved. It also means that the system does not need to run fsck after a system crash

Snapshots

Snapshots technology on ZFS is based on Copy-on-Write feature where ZFS uses snapshots to track changes in the file system

“The snapshot contains the original version of the file system, and the live filesystem contains any changes made since the snapshot was taken. No additional space is used. As new data is written to the live file system, new blocks are allocated to store this data.” If a file is deleted, the snapshot reference is removed, as well. So, snapshots are mainly designed to track changes to files, but not the addition and creation of files

Snapshots can be mounted as read-only to recover a past version of a file. It is also possible to rollback the live system to a previous snapshot. All changes made since the snapshot will be lost

Data integrity verification and automatic repair

Whenever new data is written to ZFS, it creates a checksum for that data. When that data is read, the checksum is verified. If the checksum does not match, then ZFS knows that an error has been detected. ZFS will then automatically attempt to correct the error

RAID-Z

ZFS can handle RAID without requiring any extra software or hardware. Unsurprisingly, ZFS has its own implementation of RAID: RAID-Z. RAID-Z is actually a variation of RAID-5

However, it is designed to overcome the RAID-5 write hole error, “in which the data and parity information become inconsistent after an unexpected restart”

To use the basic level of RAID-Z (RAID-Z1) you need at least two disks for storage and one for parity. RAID-Z2 required at least two storage drives and two drive for parity. RAID-Z3 requires at least two storage drives and three drive for parity. When drives are added to the RAID-Z pools, they have to be added in multiples of two

Huge Storage Potential

When ZFS was created, it was designed to be the last word in file systems. At a time when most file systems where 64-bit, the ZFS creators decided to jump right to 128-bit to future proof it.

This means that ZFS “offers 16 billion billion times the capacity of 32- or 64-bit systems”. In fact, Jeff Bonwick (one of the creators) said that powering a “fully populating a 128-bit storage pool would, literally, require more energy than boiling the oceans.”

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment