The ZFS file system was officially supported in Ubuntu 16.04 and earlier we have shown how to install on centos 7. Though it’s not installed and enabled by default it’s available in Ubuntu’s repositories.
ZFZ is an advanced file system and logical volume manager originally created by Sun Microsystems for Solaris. The file system is designed for larger servers and to provide protection against data loss. Every file is checksummed to ensure that it’s not been corrupted. It can also manage zettabytes of data – hence the name “Z”. ZFS also allows you to pool multiple drives into a single pool to create a software RAID with no special hardware. Additional features include compression, volume management, snapshots, cache and much more.
In this article, we’ll install ZFS on Ubuntu 17.04 and learn how to use its features.
To install ZFS on Ubuntu 17.04, enter the following command.
# apt install zfsutils
ZFS Virtual Device (VDEV): A virtual device is a collection of physical disks, partitions, images, or ZFS software rain devices.
ZFS Pool: A Zpool is a storage made of a collection of VDEVs. You can combine multiple disks, images to create a pool.
Below are the steps in creating a pool and making configurations using ZFS. In these examples,
pool-1 represents the name of the pool you want to use or modify.
Creating or Modifying ZFS Pools
In this example, a pool named pool-1 is created from tw0 physical drives.
# zpool create pool-1 /dev/sda5 /dev/sda3
or you can create a mirror pool using the following command.
# zpool create pool-1 mirror /dev/sd5 /dev/sd3
# zpool create pool-1 /dev/sda /dev/sdb
Adding another disk to pool
# zpool add pool-1 /dev/sda5 /dev/sda2
add the mirror option to add VDEVs in a mirror.
# zpool add pool-1 mirror /dev/sda5 /dev/sda2
You can create various types of RAIDS like raidz, raidz2, raidz3 and nested raids by adding the corresponding names before specifying the volumes.
Single File-based pool
You can have file as a vdev and make it into a pool.
# zpool create pool-test /home/user/pool-1.img
Checking Pool Status
# zpool status
If you created a pool named
pool-1, you can access it at /pool-1/
# zpool destroy pool-1
Checking Pool Size and usage
# zpool list
Taking ZFS Snapshots
A ZFS snapshot is a read-only copy of the ZFS file system which saves the current state of the file system and one can be rolled back to at a later time.
# zfs snapshot pool-1@snap1
You can see your snapshots by typing:
# zfs list -t snapshot
To roll back to a specific snapshot:
# zfs rollback mypool/projects@snap1
You can delete a snapshot by entering the command
# zfs destroy mypool/projects@snap1
If you try to list the snapshots, you’ll get the message “no datasets available”.
Clones are writable copies of ZFS snapshots. A clone can only be created from a snapshot and the snapshot cannot be deleted until all the clones are delivered. To clone a pool, first take a snapshot and then clone it. In this example, we’ll clone pool-1@snap1 and clone it to pool-1/clone.
# zfs snapshot -r pool-1@snap1 # zfs clone pool-1@snap1 pool-1/clone
You can initiate a data integrity check on a pool using the scrub option. For example, to scrub ‘pool-1’:
# zpool scrub pool-1
View I/O Stats for Pools
# zpool iostat
ZFS looks definitely fun to work with and lets you play around with multiple file systems using RAID. You can read more from the documentation from Ubuntu’s Reference Page.