Querying ZFS File System Information

The zfs list command provides an extensible mechanism for viewing and querying dataset information. Both basic and complex queries are explained in this section.

Listing Basic ZFS Information

You can list basic dataset information by using the zfs list command with no options. This command displays the names of all datasets on the system including their used, available, referenced, and mountpoint properties. For more information about these properties, see ZFS Properties.

For example:

# zfs list
pool                  84.0K  33.5G      -  /pool
pool/clone                0  33.5G  8.50K  /pool/clone
pool/test                8K  33.5G     8K  /test
pool/home             17.5K  33.5G  9.00K  /pool/home
pool/home/marks       8.50K  33.5G  8.50K  /pool/home/marks
pool/home/marks@snap      0      -  8.50K  /pool/home/marks@snap

You can also use this command to display specific datasets by providing the dataset name on the command line. Additionally, use the the r option to recursively display all descendants of that dataset.

The following example shows how to display tank/home/chua and all of its descendant datasets.

# zfs list -r tank/home/chua
NAME                        USED  AVAIL  REFER  MOUNTPOINT 
tank/home/chua		        26.0K  4.81G  10.0K  /tank/home/chua 
tank/home/chua/projects       16K  4.81G   9.0K  /tank/home/chua/projects
tank/home/chua/projects/fs1    8K  4.81G     8K  /tank/home/chua/projects/fs1 
tank/home/chua/projects/fs2    8K  4.81G     8K  /tank/home/chua/projects/fs2

For additional information about the zfs list command, see zfs ( 1M ) .

Creating Complex ZFS Queries

The zfs list output can be customized by using of the o, f, and H options.

You can customize property value output by using the o option and a comma-separated list of desired properties. Supply any dataset property as a valid value. For a list of all supported dataset properties, see ZFS Properties. In addition to the properties defined there, the o option list can also contain the literal name to indicate that the output should include the name of the dataset.

The following example uses zfs list to display the dataset name, along with the sharenfs and mountpoint properties.

# zfs list -o name,sharenfs,mountpoint 
NAME                  SHARENFS         MOUNTPOINT
tank                  rw               /export
tank/archives         rw               /export/archives
tank/archives/zfs     rw               /export/archives/zfs
tank/calendar         off              /var/spool/calendar
tank/cores            rw               /cores
tank/dumps            rw               /export/dumps
tank/home             rw               /export/home
tank/home/ahl         rw               /export/home/ahl
tank/home/ahrens      rw               /export/home/ahrens
tank/home/andrei      rw               /export/home/andrei
tank/home/barts       rw               /export/home/barts
tank/home/billm       rw               /export/home/billm
tank/home/bjw         rw               /export/home/bjw
tank/home/bmc         rw               /export/home/bmc
tank/home/bonwick     rw               /export/home/bonwick
tank/home/brent       rw               /export/home/brent
tank/home/dilpreet    rw               /export/home/dilpreet
tank/home/dp          rw               /export/home/dp
tank/home/eschrock    rw               /export/home/eschrock
tank/home/fredz       rw               /export/home/fredz
tank/home/johansen    rw               /export/home/johansen
tank/home/jwadams     rw               /export/home/jwadams
tank/home/lling       rw               /export/home/lling
tank/home/mws         rw               /export/home/mws
tank/home/rab         rw               /export/home/rab
tank/home/sch         rw               /export/home/sch
tank/home/tabriz      rw               /export/home/tabriz
tank/home/tomee       rw               /export/home/tomee

You can use the t option to specify the types of datasets to display. The valid types are described in the following table.

Table 5.2. Types of ZFS Datasets




File systems and clones





The t options takes a comma-separated list of the types of datasets to be displayed. The following example uses the t and o options simultaneously to show the name and used property for all file systems:

# zfs list -t filesystem -o name,used
NAME                  USED
pool                  105K
pool/container        0
pool/home             26.0K
pool/home/tabriz      26.0K
pool/home/tabriz_clone  0

You can use the H option to omit the zfs list header from the generated output. With the H option, all white space is output as tabs. This option can be useful when you need parseable output, for example, when scripting. The following example shows the output generated from using the zfs list command with the H option:

# zfs list -H -o name