When to create a ZFS filesystem?
Someone named “Edward M” posted on the freebsd-questions mailing list a question of when should we create a ZFS filesystem. I didn’t reply to any of the messages, but I decided to write this post expressing my view.
In short, whenever a part of the filesystem hierarchy exhibits different characteristics, create one or more ZFS filesystems for that particular subtree.
In more detail:
- Separating the hierarchy into many ZFS filesystems can make backup a lot easier. Although most backup systems allow you to specify exclude lists, listing only the important filesystems might save you some precious backup space and time.
- On the same note, if you allow your users to create their own filesystem through ZFS Delegated Administration, then your users must inform the personnel in charge of the backup system what filesystems to back up. (Maybe we should suggest the illumos people erect a new ZFS property allowing us to specify our desire for backup of the files stored in a particular subtree of the pool. However, this would in turn require every valid backup system to be aware of such a property and act accordingly. The use of user-properties might be a compromise.)
- Configuration files are usually text files and easily compressable. Thus,
/usr/local/etcwould be a perfect candidate as a separate ZFS filesystem. Mind you, this is not recommended at all for
/etcas those files must be present within the dataset specified by the zpool
- Source code are also highly compressable, and thus should
/usr/portsbe separate filesystem with compression enabled. The subtrees
/usr/ports/packagesshould be created as ZFS filesystems without any compression applied, as the files stored in these locations are compressed by nature.
- MySQL databases write their data in chunks of 16 KiB. Thus, it makes sense not only making
/var/db/mysqla separate ZFS filesystem, you should also set the ZFS
- PostgreSQL databases write their data in chunks of 8 KiB. Similarly,
/usr/local/pgsqlshould be a separate ZFS filesystem with the ZFS
recordsizeproperty set to
- Maybe some of your data is so precious that it would not only make sense to create a separate filesystem for these files, you might also consider raising the ZFS
3for added redundancy within the storage pool.
- Sometimes you might want to limit the amount of storage space used by a particular ZFS filesystem and its children by setting an appropriate value for the ZFS
quotaproperty. If you want to limit the amount of storage space used only by a particular ZFS filesystem, set the appropriate value for the ZFS
- It might be necessary to guarantee some amount of storage space for a particular ZFS filesystem and possibly its children, and then you would turn to the ZFS
refreservationproperties. These properties are used in the same manner as with the ZFS
- If you’re planning on creating snapshots for only a subset of the hierarchy, create a separate ZFS filesystem at the appropriate branchpoint.
- If you later add more disks and want all your files to take advantage of the new disks, then create a new filesystem with a similar name and placement, move your files from the old filesystem to the new one, delete the old filesystem, and rename the new filesystem to match the old filesystem’s name.
- Finally, if possible, separate your user’s files from the system’s files by using separate zpools.