Sun Microsystems
Products & Services
 
Support & Training
 
 

Previous Previous     Contents     Next Next
Chapter 5

Managing Filesystems

This chapter provides detailed information about managing ZFS filesystems. Included are such concepts as hierarchical filesystem layout, property inheritance, and automatic mount point management and share interactions.

A ZFS filesystem is a lightweight POSIX file system built on top of a storage pool. Filesystems can be dynamically created and destroyed without having to allocate or format any underlying space. Because filesystems are so lightweight, and because they are the central point of administration in ZFS, administrators are likely to create many of them.

ZFS filesystems are administered via the zfs command. The zfs(1M) command provides a set of subcommands which perform specific operations on filesystems. The following sections of this document describe these subcommands in detail. Snapshots, volumes, and clones are also managed through the use of zfs(1M), but will only be covered briefly in this section. For detailed information about snapshots and clones, see Chapter 6, ZFS Snapshots and Clones. For detailed information about volumes, see 8.1 Emulated Volumes.

Note: The term dataset is used in this section as a generic term to refer to a filesystem, snapshot, clone, or volume.

The following sections are provided in this chapter.

5.1 Creating and Destroying Filesystems

Filesystems can be created and destroyed by using the zfs create and zfs destroy commands.

5.1.1 Creating a Filesystem

Filesystems are created by using the zfs create command. When creating a filesystem, the create subcommand takes a single argument: the name of the filesystem to create. The filesystem name is specified as a path name starting from the name of the pool: pool_name/[filesystem_name/]filesystem_name. The pool name and initial filesystem names in the path identify the location in the hierarchy where the new filesystem should be created. All the intermediate filesystem names must already exist in the pool. The last name in the path, identifies the name of the filesystem to be created. The filesystem name must satisfy the naming conventions defined in 1.3 ZFS Component Naming Conventions.

The following example creates a filesystem named bonwick at tank/home.

# zfs create tank/home/bonwick

Upon successful creation, ZFS automatically mounts the newly created filesystem. By default, filesystems are mounted as /dataset, using the path provided for the filesystem name in the create subcommand. In the above example, the newly created bonwick filesystem would be mounted at /tank/home/bonwick. For more information on auto-managed mount points, see 5.5.1 Managing Mount Points.

5.1.2 Destroying a Filesystem

To destroy a filesystem, use the zfs destroy command. The destroyed filesystem is automatically unmounted and unshared. For more information on auto-managed mounts or auto-managed shares, see 5.5.1.1 Automatic Mount Points. The following example destroys the tabriz filesystem.

# zfs destroy tank/home/tabriz

If the filesystem to be destroyed is busy (and so cannot be unmounted), the zfs destroy command will not succeed. To force the destruction of an active filesystem, the -f option must be used. This option should be used with caution as it can unmount, unshare, and destroy active filesystems, causing unexpected application behavior.

# zfs destroy tank/home/ahrens
cannot unmount 'tank/home/ahrens': Device busy

# zfs destroy -f tank/home/ahrens

Thezfs destroy command also fails if a filesystem has children. To force a recursive destruction of a filesystem and all its descendants, the -r option must be used. Note that a recursive destroy also destroys snapshots. Great care should be taken when using this option.

# zfs destroy tank/ws
cannot destroy 'tank/ws': filesystem has children
use '-r' to destroy the following datasets:
tank/ws/billm
tank/ws/bonwick
tank/ws/maybee

# zfs destroy -r tank/ws

If the filesystem to be destroyed has indirect dependants, even the recursive destroy command described above fails. To force the destruction of all dependants, including cloned filesystems outside the target hierarchy, the -R option must be used. This option should be used with extreme caution.

# zfs destroy -r tank/home/schrock
cannot destroy 'tank/home/schrock': filesystem has dependant clones
use '-R' to destroy the following datasets:
tank/clones/schrock-clone

# zfs destroy -R tank/home/schrock

For more information about snapshots and clones, see Chapter 6, ZFS Snapshots and Clones.

5.1.3 Renaming a Filesystem

Filesystems can be renamed by using the zfs rename command. A rename can change the name of a filesystem and/or it can relocate the filesystem to a new location within the ZFS hierarchy. The first example below uses the rename subcommand to do a simple rename of a filesystem.

# zfs rename tank/home/kustarz tank/home/kustarz_old

The example above renames the kustarz filesystem to kustarz_old. The next example shows how to use zfs rename to relocate a filesystem.

# zfs rename tank/home/maybee tank/ws/maybee

In the above example, the maybee filesystem was relocated from tank/home to tank/ws. When relocating through rename, the new location must be within the same pool and it must have enough space to hold this new filesystem. If the new location does not have enough space, possibly because it has reached its quota (see 5.6 Quotas and Reservations for more information), the rename will fail.

The rename operation attempts an unmount/remount sequence for the filesystem and any descendant filesystems. The rename fails if it is unable to unmount an active filesystem. If this occurs, manual intervention is needed to force unmount the filesystem(s).

For information about renaming snapshots, see 6.1.1.1 Renaming ZFS Snapshots.

5.2 ZFS Properties

Properties are the main mechanism used to control the behavior of filesystems, volumes, snapshots, and clones. Unless explicitly called out, the properties defined in the section apply to all the dataset types.

Properties are either readonly statistics, or settable properties. Most settable properties are also inheritable, where an inheritable property is one that, when set on a parent, is propagated down to all descendants.

All inheritable properties have an associated source. The source indicates how a property was obtained. It can have the following values:

local

A local source indicates that this property was explicitly set on this dataset using the zfs set command (described in 5.4.1 Setting Properties).

inherited from dataset-name

A value of inherited from dataset-name means that this property was inherited from the named ancestor.

default

A value of default means that this property setting was not inherited nor set locally. This source is a result of no ancestor having this property as source local.

Name

Type

Default Value

Description

aclinherit

string

secure

Controls how ACL entries are inherited when files and directories are created. The values are: discard, noallow, secure, and passthrough. For a description of these values, see 7.1.3 ACL Property Modes.

aclmode

string

groupmask

Controls how an ACL is modified during a chmod(2) operation. The values are: discard, groupmask, and passthrough. For a description of these values, see 7.1.3 ACL Property Modes.

atime

boolean

on

Controls whether the access time for files is updated when they are read.

See the description below.

available

number

N/A

The amount of space available to the dataset and all its children, assuming that there is no other activity in the pool.

See the description below.

checksum

string

on

Controls the checksum used to verify data integrity. The default value is on, which automatically selects an appropriate algorithm, currently, fletcher2. The values are fletcher2, fletcher4, and sha256. A value of off disables integrity checking on user data; this is NOT recommended.

compression

string

off

Controls the compression algorithm used for this dataset. There is currently only one algorithm, lzjb, though this might change in future releases.

This property can also be referred to by its shortened column name compress.

compressratio

number

N/A

The compression ratio achieved for this dataset, expressed as a multiplier. Compression can be turned on by running zfs set compression=on dataset.

creation

number

N/A

The date and time the dataset was created.

devices

boolean

on

Controls whether device nodes can be opened in the filesystem.

exec

boolean

on

Controls whether processes can be executed from within this filesystem.

mounted

boolean

N/A

For filesystems, indicates whether the filesystem is currently mounted. This property can be either yes or no.

mountpoint

string

See below

Controls the mountpoint used for this filesystem.

See the description below.

origin

string

N/A

For cloned filesystems or volumes, the snapshot from which the clone was created. The origin cannot be destroyed (even with the -r or -f options) so long as a clone exists.

quota

number (or none)

none

Limits the amount of space a dataset and its descendents can consume.

See the description below.

readonly

boolean

off

Controls whether dataset can be modified. This property can also be referred to by its shortened column name, rdonly.

recordsize

number

128K

Specifies a suggested block size for files in the file system.

See the description below.

referenced

number

N/A

The amount of data accessible by this dataset, which may or may not be shared with other datasets in the pool.

See the description below.

reservation

number (or none)

none

The minimum amount of space guaranteed to a dataset and its descendents.

See the description below.

sharenfs

string

off

Controls whether the file system is shared via NFS, and what options are used.

See the description below.

setuid

boolean

on

Controls whether the setuid bit is honored in the filesystem.

snapdir

string

visible

Controls whether the .zfs directory is hidden or visible in the root of the file system as discussed in the Snapshots section.

type

string

N/A

Identifies dataset type such as filesystem (filesystem/clone), volume, or snapshot.

used

number

N/A

The amount of space consumed by this dataset and all its descendants.

See the detailed description below.

volsize

number

See below

For volumes, specifies the logical size of the volume. See the description below.

volblocksize

number

See below

For volumes, specifies the block size of the volume. See the description below.

zoned

boolean

See below

Controls whether the dataset is managed from a non-global zone. The default value is off.

See the detailed description below.

Previous Previous     Contents     Next Next