Sun Microsystems
Products & Services
 
Support & Training
 
 

Previous Previous     Contents     Next Next

5.3 Querying Filesystem 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.

5.3.1 Listing Basic Information

Basic dataset information can be seen using zfs list with no options. This invocation will display the names of all datasets on the system include their used, available, referenced, and mountpoint properties. See 5.2 ZFS Properties for more information about these properties.

# zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
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/hopme/marks@snap

The zfs list command can be refined to display specific datasets by providing the dataset name on the command line. Additionally, the -r option can be added to recursively display all descendants of that dataset. The example below uses zfs list 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

5.3.2 Complex Queries

The output displayed by zfs list can be customized through the use of the -o, -f, and -H options.

The -o option provides support for customizing the property value to be output. This option expects a comma separated list of the desired properties where any dataset property can be supplied as a valid value. See 5.2 ZFS Properties for a list of all supported dataset properties. In addition to the properties defined in the Properties section, the -o option list can also contain the literal name to indicate that the output should display the name of the dataset. The example below 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

The -t option provides the capability of specifying which type(s) of dataset(s) should be output. The valid types can be seen in the table below.

Table 5-1 Types of Datasets

Type

Description

filesystem

Display filesystem and clone datasets

volume

Display volume datasets

snapshot

Display snapshot datasets

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

# 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

The -H option can be used to omit the zfs list header from the generated output. When using the -H option, all white space is output as tabs. This option can be useful when parseable output is needed (for example, when scripting). The example below shows the output generated from an invocation of zfs list using the -H option.

# zfs list -H -o name
pool
pool/container
pool/home
pool/home/tabriz
pool/home/tabriz@now
pool/home/tabriz/container
pool/home/tabriz/container/fs1
pool/home/tabriz/container/fs2
pool/home/tabriz_clone

5.4 Managing Properties

Dataset properties are managed through the set, inherit, and get subcommands.

5.4.1 Setting Properties

The zfs set command can be used to modify any settable dataset property, see 5.2.2 Settable Properties for a list of settable dataset properties. The zfs set command takes a property/value sequence in the format of property=value and a dataset name. The example below sets theatime property to off for tank/home. Only one property can be set/modified per zfs set invocation.

# zfs set atime=off tank/home

Numeric properties can be specified using the following human-readable suffixes (in order of magnitude) BKMGTPEZ. Any of these suffixes can be followed by an optional b, indicating bytes, with the exception of the B suffix which already indicates bytes. The following four invocations of zfs set are equivalent numeric expressions indicating that the quota property should be set to the value of 50 gigabytes on the tank/home/marks filesystem.

# zfs set quota=50G tank/home/marks
# zfs set quota=50g tank/home/marks
# zfs set quota=50GB tank/home/marks
# zfs set quota=50gb tank/home/marks

Non-numeric properties are case sensitive and must be lower case, with the exception of mountpoint and sharenfs which may have mixed upper and lower case letters.

5.4.2 Inheriting Properties

All settable properties, with the exception of quotas and reservations, inherit their value from their parent, unless explicitly set by the child. If no ancestor has an explicit value set for an inherited property, the default value for the property is used. The zfs inherit command is used to clear a property setting, thus causing the setting to be inherited from the parent.

The following example useszfs set to turn on compression, and then zfs inherit to unset the compression property, thus causing it to inherit the default setting of off. Note, since neither home nor pool have the compression property locally set (via zfs set), the default value is used. If both had it set, the value set in the most immediate ancestor would be used (home in this example).

# zfs set compression=on tank/home/bonwick
# zfs get -r compression tank
NAME             PROPERTY      VALUE                      SOURCE
tank             compression   off                        default          
tank/home        compression   off                        default          
tank/home/bonwick compression   on                         local          
# zfs inherit compression tank/home/bonwick
# zfs get -r compression tank
NAME             PROPERTY      VALUE                      SOURCE
tank             compression   off                        default          
tank/home        compression   off                        default          
tank/home/bonwick compression  off                        default          

The inherit subcommand is applied recursively when the -r option is specified. The following example causes the value for the compression property to be inherited by tank/home and any descendants it may have.

# zfs inherit -r compression tank/home

Be aware that the use of the -r option clears the current property setting for all descendant datasets.

Previous Previous     Contents     Next Next