Attaching a Block Storage volume via the Block Storage API
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- A valid API key
- A Block Storage volume
-
Query the current volumes of the Instance.
curl -X GET \ -H "X-Auth-Token: $SCW_SECRET_KEY" \ "https://api.scaleway.com/instance/v1/zones/{zone}/servers/{server_id}"
The output displays as follows:
{ "server": { "id": "de0f4d6a-3289-4716-97a8-d24b2a58dcd9", "name": "scw-priceless-diffie", "arch": "x86_64", ... }, "volumes": { "0": { "boot": false, "volume_type": "sbs_volume", "id": "1469d160-bfb2-4fdd-bb5d-f8d7c1d0439d", "zone": "pl-waw-2" } }, ... }
As displayed, our current volumes are only constituted of the root volume.
-
Hot-plug the volume created earlier:
curl -q \ -H "X-Auth-Token: $SCW_SECRET_KEY" \ -H 'Content-Type: application/json' \ -X PATCH \ -d '{ "volumes": { "0": { "id": "7fe25caf-0a68-46a7-aeb9-63a278d33e2b", "volume_type": "l_ssd" }, "1": { "id": "b3a42fb1-e85c-46e9-b0a6-9adb62278295", "volume_type": "sbs_volume" } } }' \ https://api.scaleway.com/instance/v1/zones/{zone}/servers/{server_id}
The output looks like the following example:
{ "server": { "id": "1de0f4d6a-3289-4716-97a8-d24b2a58dcd9", "name": "scw-priceless-diffie", "arch": "x86_64", ... }, "volumes": { "0": { "boot": false, "volume_type": "sbs_volume", "id": "7fe25caf-0a68-46a7-aeb9-63a278d33e2b", "zone": "pl-waw-2" }, "1": { "boot": false, "volume_type": "sbs_volume", "id": "b3a42fb1-e85c-46e9-b0a6-9adb62278295", "zone": "pl-waw-2" } }, ... }
-
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/efi
The 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-9adb62278295
If 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: $SCW_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": "sbs_volume", "server": { "id": "be3c50af-e8f3-4ff4-90fe-66972f06670d", "name": "scw-blissful-engelbart" } } }
Still need help?Create a support ticket