How to Detach and Delete Volumes

Validated on 5 Feb 2026 • Last edited on 18 Feb 2026

Volumes are network-attached block storage. You can use them with Droplets or Kubernetes clusters, move or resize them, and create snapshots at any time.

To remove a volume from a Droplet, you can either:

  • Detach the volume, which removes it from the Droplet, but keeps the volume and its data so you can reattach it to another Droplet at any time.

  • Delete a volume, which permanently removes the volume and all of its data. This option cannot be undone, and you’re no longer billed for the volume.

If you remove a volume from a running Droplet, you may lose data or cause errors on your Droplet. First, turn off the Droplet, or make sure it’s not writing to the volume. You can check whether the volume is in use by listing open files on the mount point with lsof.

Then, unmount your volume.

Detach a Volume Using Automation

You can detach volumes from Droplets via the DigitalOcean CLI or API.

Detach a Volume via the CLI

To detach a volume via the CLI, use doctl compute volume-action detach and provide the volume ID and Droplet ID.

How to Detach a Volume Using the DigitalOcean CLI
  1. Install doctl, the official DigitalOcean CLI.
  2. Create a personal access token and save it for use with doctl.
  3. Use the token to grant doctl access to your DigitalOcean account.
    doctl auth init
  4. Finally, run doctl compute volume-action detach. Basic usage looks like this, but you can read the usage docs for more details:
    doctl compute volume-action detach <volume-id> <droplet-id> [flags]
    The following example detaches a volume with the UUID f81d4fae-7dec-11d0-a765-00a0c91e6bf6 from a Droplet with the ID 386734086:
    doctl compute volume-action detach f81d4fae-7dec-11d0-a765-00a0c91e6bf6 386734086

Detach a Volume via the API

To detach a volume via the API, send a POST request to the volume actions endpoint with a detach action.

How to Detach a Volume Using the DigitalOcean API
  1. Create a personal access token and save it for use with the API.
  2. Send a POST request to https://api.digitalocean.com/v2/volumes/{volume_id}/actions.

cURL

Using cURL:

# Attach a Volume to a Droplet by ID
curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  -d '{"type": "attach", "droplet_id": 11612190, "region": "nyc1", "tags":["aninterestingtag"]}' \
  "https://api.digitalocean.com/v2/volumes/7724db7c-e098-11e5-b522-000f53304e51/actions"

# Remove a Volume from a Droplet by ID
curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  -d '{"type": "detach", "droplet_id": "11612190", "region": "nyc1"}' \
  "https://api.digitalocean.com/v2/volumes/7724db7c-e098-11e5-b522-000f53304e51/actions"

# Resize a Volume
curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  -d '{"type":"resize","size_gigabytes": 100, "region":"nyc1"}' \
  "https://api.digitalocean.com/v2/volumes/7724db7c-e098-11e5-b522-000f53304e51/actions"

Go

Using Godo, the official DigitalOcean API client for Go:

import (
    "context"
    "os"

    "github.com/digitalocean/godo"
)

func main() {
    token := os.Getenv("DIGITALOCEAN_TOKEN")

    client := godo.NewFromToken(token)
    ctx := context.TODO()

  // Attach a Volume to a Droplet by ID
    action, _, err := client.StorageActions.Attach(ctx, "7724db7c-e098-11e5-b522-000f53304e51", 11612190)

  // Remove a Volume from a Droplet by ID
  // action, _, err := client.StorageActions.Detach(ctx, "7724db7c-e098-11e5-b522-000f53304e51")

  // Resize a Volume
  // action, _, err := client.StorageActions.Resize(ctx, "7724db7c-e098-11e5-b522-000f53304e51", 100, "nyc1")
}

Ruby

Using DropletKit, the official DigitalOcean API client for Ruby:

require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)

# Attach a Volume to a Droplet by ID
client.volume_actions.attach(volume_id:'7724db7c-e098-11e5-b522-000f53304e51', droplet_id: 11612190, region: 'nyc1'


# Remove a Volume from a Droplet by ID
# client.volume_actions.detach(volume_id:'7724db7c-e098-11e5-b522-000f53304e51', droplet_id: 11612190, region: 'nyc1'

Python

Using PyDo, the official DigitalOcean API client for Python:

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "type": "attach",
  "droplet_id": 11612190,
  "region": "nyc1",
  "tags": [
    "aninterestingtag"
  ]
}

resp = client.volume_actions.post_by_id(volume_id="7724db7c", body=req)

Detach a Volume Using the Control Panel

To detach a volume, go to the control panel, in the left menu, click Volumes Block Storage, in the Volumes overview page, find the volume you want to detach, click More, and then click Detach from Droplet to open the confirmation window.

Then, click Confirm to detach the volume. You can then attach the volume to a different Droplet as needed.

If you detach an auto-mounted volume, you should also delete the corresponding systemd mount unit file from the Droplet, which is located at /etc/systemd/system/mnt-volume_*.mount. To do this, remove the file using rm, and then reload the systemd configuration with systemctl daemon-reload.

After detaching a volume, you can access it from the Volumes overview page. You continue to be billed for the volume until you delete it.

Delete a Volume Using Automation

You can delete volumes via the DigitalOcean CLI or API.

Delete a Volume via the CLI

To delete a volume via the CLI, use doctl compute volume delete and specify the ID or name of the volume you want to remove.

How to Delete a Volume Using the DigitalOcean CLI
  1. Install doctl, the official DigitalOcean CLI.
  2. Create a personal access token and save it for use with doctl.
  3. Use the token to grant doctl access to your DigitalOcean account.
    doctl auth init
  4. Finally, run doctl compute volume delete. Basic usage looks like this, but you can read the usage docs for more details:
    doctl compute volume delete <volume-id> [flags]
    The following example deletes a volume with the UUID f81d4fae-7dec-11d0-a765-00a0c91e6bf6:
    doctl compute volume delete f81d4fae-7dec-11d0-a765-00a0c91e6bf6

Delete a Volume via the API

To delete a volume via the API, send a DELETE request to the volume’s endpoint.

How to Delete a Volume Using the DigitalOcean API
  1. Create a personal access token and save it for use with the API.
  2. Send a DELETE request to https://api.digitalocean.com/v2/volumes/{volume_id}.

cURL

Using cURL:

curl -X DELETE \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  "https://api.digitalocean.com/v2/volumes/7724db7c-e098-11e5-b522-000f53304e51"

Go

Using Godo, the official DigitalOcean API client for Go:

import (
    "context"
    "os"

    "github.com/digitalocean/godo"
)

func main() {
    token := os.Getenv("DIGITALOCEAN_TOKEN")

    client := godo.NewFromToken(token)
    ctx := context.TODO()

    _, err := client.Storage.DeleteVolume(ctx, "7724db7c-e098-11e5-b522-000f53304e51")
}

Ruby

Using DropletKit, the official DigitalOcean API client for Ruby:

require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)

client.volumes.delete(id: '7724db7c-e098-11e5-b522-000f53304e51')

Python

Using PyDo, the official DigitalOcean API client for Python:

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

resp = client.volumes.delete(volume_id="7724db7c")

Delete a Volume Using the Control Panel

When you delete a volume, the volume and its contents are deleted. Deleting a volume is irreversible.

To delete a volume, go to the control panel, in the left menu, click Volumes Block Storage, in the Volumes overview page, find the volume you want to delete, click More, and then click Delete to open the confirmation window.

Then, click Confirm to delete the volume.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.