# zfs.resource.destroy

Destroy a ZFS resource (filesystem, volume, or snapshot).

This method provides an interface for destroying ZFS resources with support for recursive deletion, clone removal, hold removal, and batch snapshot deletion.

Args: data (dict): Dictionary containing destruction parameters: - path (str): Path of the ZFS resource to destroy. Must be in the form ‘pool/name’, ‘pool/name@snapshot’, or ‘pool/zvol’. Cannot be an absolute path or end with a forward slash. - recursive (bool, optional): If True, recursively destroy all descendants. For snapshots, destroys the snapshot across all descendant resources and also destroy clones and/or holds that may be present. Default: False. - all_snapshots (bool, optional): If True, destroy all snapshots of the specified resource (resource remains). Default: False.

Returns: None: On successful destruction.

Raises: ValidationError: Raised in the following cases: - Resource does not exist (ENOENT) - Resource has children and recursive=False (EBUSY) - Attempting to destroy root filesystem - Path is absolute (starts with /) - Path ends with forward slash - Path references protected internal resources

Examples: # Destroy a simple filesystem destroy({“path”: “tank/temp”})

> # Recursively destroy filesystem, snapshots, clones, holds # and all children destroy({“path”: “tank/parent”, “recursive”: True})

> # Destroy a specific snapshot destroy({“path”: “tank/temp@snapshot1”})

> # Recursively destroy the snapshot across all descendant # resources including clone(s), and/or hold(s) destroy({“path”: “tank/parent@snap”, “recursive”: True})

> # Destroy all snapshots of a resource (keeping “tank/temp”) destroy({“path”: “tank/temp”, “all_snapshots”: True})

Notes: - Root filesystem destruction is not allowed for safety - Protected system paths cannot be destroyed via API - When destroying snapshots recursively, only matching snapshots in descendant datasets are removed - The all_snapshots flag only removes snapshots, not the dataset itself - For volumes with snapshots, either use recursive=True or all_snapshots=True

Type: object

##

Type: array
No Additional Items

#### Tuple Validation

##### Parameter 1: zfs_resource_destroy_args

#### zfs_resource_destroy_args

Type: object

ZFSResourceDestroyArgs parameters.

No Additional Properties

##

#### Path

Type: string

Path of the zfs resource to be destroyed.

Must be at least `1` characters long

##

#### Recursive

Type: boolean Default: false

Recursively destroy all descendants of the resource. This will also release any holds and destroy any clones for any of the descendants of the resource being deleted.

If you want to recursively remove a particular snapshot from all descendants. You must set the `path` string to a snapshot (i.e. dozer/a@snap01) and set this to True. This will recursively destroy all snapshots named `snap01` from any descendants of dozer/a.

If you want to destroy all snapshots for a particular resource, then you must pass the `path` string as "pool/name" and set the all_snapshots flag to True. This will leave "pool/name" on disk but will remove all snapshots (and clones/holds) recursively for that resource.

##

#### All Snapshots

Type: boolean Default: false

Remove all snapshots for resource being destroyed.

##

#### Result

Type: null

Required roles: ZFS_RESOURCE_WRITE