ZFS: Create a New Filesystem from an Existing Pool

A previous tech-recipe demonstrated the command to create a ZFS pool using zpool. While this created a mounted filesystem, the fun does not stop there. The pool can be used in additional ways. This tech-recipe shows how to create more filesystems out of an existing pool.


Filesystems with ZFS are fundamentally different from those using UFS. The analogous structure to a UFS filesystem (configured on a disk slice) is a ZFS pool which can occupy a slice of a disk, but it can also be used with a whole disk. Multiple ZFS filesystems can then be created within a single ZFS pool. This is possible because attributes such as encryption, quotas, and space reservations can be set on individual filesystems or filesystem trees in a ZFS pool providing flexibility impossible with UFS.

Given the pool techrx (mounted at /techrx), a new filesystem ‘logs’ can be created using the command:

zfs create techrx/logs

At this point, there is now a new filesystem mounted at /techrx/logs which we can see with a df -h command:

# df -h /techrx/logs
Filesystem size used avail capacity Mounted on
techrx/logs 19G 24K 19G 1% /techrx/logs

Additional filesystems can be created under the new logs filesystem:

zfs create techrx/logs/httpd
zfs create techrx/logs/mail

These newly created filesystems share the same space as techrx/logs as seen in this df output:

# df -h /techrx/logs/*
Filesystem size used avail capacity Mounted on
techrx/logs/httpd 19G 24K 19G 1% /techrx/logs/httpd
techrx/logs/mail 19G 24K 19G 1% /techrx/logs/mail
techrx/logs 19G 24K 19G 1% /techrx/logs

 

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.

One Response to “ZFS: Create a New Filesystem from an Existing Pool”

  1. June 30, 2009 at 1:17 pm, sethunath said:

    How to create a specific size file system, rather than a default size one in ZFS

    Reply

Leave a Reply

You may also like-

ZFS: Create a mirrored storage poolZFS: Create a mirrored storage poolAnyone who has used DiskSuite to mirror drives in Solaris knows that, while not difficult, the multiple steps involved are fertile ground for (potentially ... ZFS: List or view filesystemsZFS: List or view filesystemsIt is worth repeating the distinction between ZFS pools and filesystems. A ZFS filesystem cannot exist outside of a ZFS pool. Creating a ZFS ...