Attaching a Block Storage volume via the API
Published on 10 January 2020
Identity and Access Management (IAM):
If you have activated IAM, you may need certain IAM permissions to carry out some actions described on this page. This means:
- you are the Owner of the Scaleway Organization in which the actions will be carried out, or
- you are an IAM user of the Organization, with a policy granting you the necessary permission sets
Requirements:
- You have a Scaleway account
- You have configured your API keys
- You have a Block Storage volume
-
Query the current volumes of the Instance.
$ curl -q \
-H "X-Auth-Token: $SECRET_KEY" \
-H 'Content-Type: application/json' \
https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/be3c50af-e8f3-4ff4-90fe-66972f06670d
{
"server": {
"allowed_actions": [
...
"volumes": {
"0": {
...
"id": "7fe25caf-0a68-46a7-aeb9-63a278d33e2b",
...
}
},
...
}As displayed, our current volumes are only constituted of the root volume.
-
Hot-plug the volume created earlier:
$ curl -q \
-H "X-Auth-Token: $SECRET_KEY" \
-H 'Content-Type: application/json' \
-X PATCH \
-d '{
"volumes": {
"0": "7fe25caf-0a68-46a7-aeb9-63a278d33e2b",
"1": "b3a42fb1-e85c-46e9-b0a6-9adb62278295"
}
}' \
https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/be3c50af-e8f3-4ff4-90fe-66972f06670d
{
"server": {
...
"id": "be3c50af-e8f3-4ff4-90fe-66972f06670d",
...
"name": "scw-blissful-engelbart",
"protected": false,
"volumes": {
"0": {
"size": 20000000000,
"state": "available",
...
"id": "7fe25caf-0a68-46a7-aeb9-63a278d33e2b",
"volume_type": "l_ssd",
"server": {
"id": "be3c50af-e8f3-4ff4-90fe-66972f06670d",
"name": "scw-blissful-engelbart"
}
},
"1": {
"size": 10000000000,
"state": "available",
"name": "block-volume101",
"modification_date": "2019-09-03T10:17:40.800839+00:00",
...
"id": "b3a42fb1-e85c-46e9-b0a6-9adb62278295",
"volume_type": "b_ssd",
"server": {
"id": "be3c50af-e8f3-4ff4-90fe-66972f06670d",
"name": "scw-blissful-engelbart"
}
}
},
...
}
} -
Use SSH to log into your server and verify that the new disk exists:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 953.7M 0 disk
vda 252:0 0 18.6G 0 disk
├─vda1 252:1 0 18.5G 0 part /
└─vda15 252:15 0 100M 0 part /boot/efiThe block volume is presented inside your instance as
/dev/sdX
, to help you automate things, a symlink is also present in/dev/disk/by-id/
with theid
of the volume in it:$ ls /dev/disk/by-id/
scsi-0SCW_b_ssd_volume-b3a42fb1-e85c-46e9-b0a6-9adb62278295If you query information about the block volume from the API, the
server_id
on which it is plugged-in is displayed$ curl -q \
-H "X-Auth-Token: $SECRET_KEY" \
-H 'Content-Type: application/json' \
https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/b3a42fb1-e85c-46e9-b0a6-9adb62278295
{
"volume": {
"size": 10000000000,
"state": "available",
"name": "block-volume101",
...
"id": "b3a42fb1-e85c-46e9-b0a6-9adb62278295",
"volume_type": "b_ssd",
"server": {
"id": "be3c50af-e8f3-4ff4-90fe-66972f06670d",
"name": "scw-blissful-engelbart"
}
}
}
See Also