# Auto Deleting Volumes on Instance Delete

## Problem

How to attach Volumes which will be deleted when the Source VM is deleted.

## Environment

* Platform9 Managed OpenStack - v4.0 and Higher
* python-openstackclient CLI

## Procedure

1. Obtain the UUID of the Volume and the VM you want to attach it to.
2. Source the OpenRC file for your environment.
3. Run the following command with the `--enable-delete-on-termination` flag. `$ openstack server add volume [--enable-delete-on-termination | --disable-delete-on- termination] server_uuid volume_uuid`

Note - This command will delete the volume by default when the associated VM is deleted. There will no confirmation step. Please ensure you have backups of all critical volumes to avoid potential data loss.

## Additional Information

* How to use the OpenStack CLI.
* [Upstream OpenStack Documentation](https://docs.openstack.org/python-openstackclient/ussuri/cli/command-objects/server.html#server-add-volume)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pmo/how-to/auto-deleting-volumes-on-instance-delete.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
