Go to main content

Managing ZFS File Systems in Oracle® Solaris 11.4

Exit Print View

Updated: August 2019
 
 

How to Destroy a ZFS File System

To destroy a ZFS file system, use the zfs destroy command. By default, all of the snapshots for the dataset will be destroyed. The destroyed file system is automatically unmounted and unshared. For more information about automatically managed mounts or automatically managed shares, see Automatic Mount Points.

  1. Assume the root role or an equivalent role with the appropriate ZFS rights profile.
  2. Destroy the ZFS file system.
    $ zfs destroy [-rRsf] filesystem
    –r

    Recursively destroys children datasets.

    –R

    Recursively destroys dependent datasets, including cloned file systems that are outside the target hierarchy.

    –s

    Performs a synchronous destroy operation where the command control does not return to the caller until the blocks occupied by the destroyed datasets are completely freed.

    –f

    Forces a file system to be unmounted in order to be destroyed.

    filesystem

    Is in the format pool-name/[dataset-path]/filesystem-name.


    Caution

    Caution  -  No confirmation prompt appears with the destroy subcommand either by itself or with options. Use this command with extreme caution, especially when using the –f and –r options. These options can destroy large portions of the pool and consequently cause unexpected behavior for the mounted file systems that are in use.


Example 30  Synchronously Destroying an Active ZFS File System

If the file system to be destroyed is busy and cannot be unmounted, the zfs destroy command fails. To destroy an active file system, use the –f option. Use this option with caution as it can unmount, unshare, and destroy active file systems, causing unexpected application behavior.

$ zfs destroy -fs tank/home/matt
Example 31  Destroying a ZFS File System with Descendents

The zfs destroy command also fails if a file system has descendents. To recursively destroy a file system and all its descendents, use the –r option.

$ zfs destroy tank/ws
cannot destroy 'tank/ws': filesystem has children
use '-r' to destroy the following datasets:
tank/ws/jeff
tank/ws/bill
tank/ws/mark
$ zfs destroy -r tank/ws