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?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Hi,
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.
####Prerequisites####
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:
Outputcurl 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:
sudo yum install curl
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:
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"
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.