How to Delete Volumes

Volumes are network-based block devices that provide additional data storage for Droplets. You can move them between Droplets, create disk images of them, and resize them at any time.


To remove a volume from a Droplet, you can either detach the volume or delete the volume.

  • Detaching a volume removes the volume from its current Droplet. You can attach the volume and all of its contents to a different Droplet as needed.
  • Deleting a volume permanently destroys the volume and its contents. This action cannot be reversed.

Delete a Volume Using Automation

Before deleting a volume, unmount it to prevent data loss.

How to delete a volume using the DigitalOcean CLI

To delete a volume via the command-line, follow these steps:

  1. Install doctl, the DigitalOcean command-line tool.

  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, delete a volume with doctl compute volume delete. The basic usage looks like this, but you'll want to 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
                    
How to delete a volume using the DigitalOcean API

To delete a volume using the DigitalOcean API, follow these steps:

  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

    To delete a volume with cURL, call:

    
                    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

    Go developers can use Godo, the official DigitalOcean V2 API client for Go. To delete a volume with Godo, use the following code:

    
                    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

    Ruby developers can use DropletKit, the official DigitalOcean V2 API client for Ruby. To delete a volume with DropletKit, use the following code:

    
                    require 'droplet_kit'
    token = ENV['DIGITALOCEAN_TOKEN']
    client = DropletKit::Client.new(access_token: token)
    
    client.volumes.delete(id: '7724db7c-e098-11e5-b522-000f53304e51')

    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

Before deleting a volume, unmount it to prevent data loss.

You can delete a volume from the volume’s More menu, which is available on the account-level Volumes page.

Volumes more menu

When you select Delete, a window to confirm the deletion opens.

Delete volume confirmation window
Warning
When you delete a volume, the volume and its contents will be completely deleted. This action is irreversible.

Click Confirm to delete the volume.