When creating a Digitalocean Volume, it is required to specify a droplet to attache the volume to. Is it possible to instead create a standalone Volume, and attach it to a droplet at a later stage?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer


You can create detached volume with DO API. I tested it using both curl and Ruby. Let’s focus on curl because it is usually installed by default on most of Linux distros.


1. You must have curl installed.
To check if you have curl installed run following command

curl --version

If you have it installed, you will get the response like that:

curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.53.1 zlib/1.2.7 libidn/1.28 libssh2/1.8.0 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets

If you do not have it installed, you can install it with your distro’s standard package manager. Two examples below:

CentOS 7
sudo yum install curl
Ubuntu 20.04
sudo apt update && sudo apt install curl

2. You must have DO Personal Access Token set up.
If you do not have it, go to API section in DO control panel and generate new token accordingly to the DO tutorial.

Copy your new personal access token. It is visible just after its creation. 
Keep it secret !!!

Creating a detached volume

I am using an example from DO’s API documentation. To create a detached volume, run the command below. But before you will do it, customize its parameters. The parameters are well described in previously mentioned DO’s API documentation, however, I am highlighting some of them:

  • Bearer is your Personal Access Token
  • size_gigabytes is a volume size
  • name is a volume name you will see in DO control panel; you may use it for mounting the volume to your droplet
  • region is a slug identifier for a region where your volume will be created; bear in mind that you can attach a volume to the droplets located in the same datacenter
  • filesystem_type - you provide it if you want to have your new volume automatically formatted to specified filesystem. Currently available options are ext4 and xfs
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer 123456789abcdef1234567890abcdef1234567890abcdef" -d '{"size_gigabytes":10, "name": "example", "description": "Volume for testing", "region": "nyc1", "filesystem_type": "ext4", "filesystem_label": "example"}' "https://api.digitalocean.com/v2/volumes"
Submit an Answer