ZFS: Reserve Space for Filesystem

Descendent (child) filesystems in ZFS take on the characteristics of the parent filesystem (compression, quotas, and available disk space). The pool concept in ZFS is fitting – a hard drive (or several) becomes a pool. We no longer have to define the exact size of a filesystem when we create it. Each filesystem has access to the same pool of space. However, it is simple to reserve a minimum amount of space for a filesystem and its decendents.


Given the pool techrx and filesystems techrx/logs, techrx/logs/httpd, and techrx/mail, we may want to ensure that the httpd logs have at least 5GB of space available. Before making any changes, a zfs list command shows this output for these filesystems:

NAME USED AVAIL REFER MOUNTPOINT
techrx/logs 77.5K 19.2G 28.5K /techrx/logs
techrx/logs/httpd 24.5K 19.2G 24.5K /techrx/logs/httpd
techrx/logs/mail 24.5K 19.2G 24.5K /techrx/logs/mail

Note that the available space is the same for all filesystems. To reserve 5G of space for techrx/logs/httpd, the following command is used:

zfs set reservation=5g techrx/logs/httpd

The resulting output of the zfs list command shows some differences:

NAME USED AVAIL REFER MOUNTPOINT
techrx/logs 5.00G 14.2G 28.5K /techrx/logs
techrx/logs/httpd 24.5K 19.2G 24.5K /techrx/logs/httpd
techrx/logs/mail 24.5K 14.2G 24.5K /techrx/logs/mail

The used space in techrx/logs has increased to 5G and the available space for techrx/logs and techrx/logs/mail has decreased 5G to 14.2G. The available space for techrx/logs/httpd is still at 19.2G as it was before the reservation since that command sets only the minimum space available for the filesystem (and any filesystems created under it).

The command can be repeated to alter the reservation as needed, either up or down. To remove the reservation, use the command:

zfs set reservation=none techrx/logs/httpd

 

About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.