NavigationContentFooter
Suggest an edit

Attaching a Block Storage volume via the Instance API

Reviewed on 24 June 2024Published on 10 January 2020

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
  1. 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",
    "volume_type": "l_ssd",
    ...
    }
    },
    ...
    }

    As displayed, our current volumes are only constituted of the root volume.

  2. Hot-plug the volume created earlier:

    curl -q \
    -H "X-Auth-Token: $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/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": "sbs_volume",
    "server": {
    "id": "be3c50af-e8f3-4ff4-90fe-66972f06670d",
    "name": "scw-blissful-engelbart"
    }
    }
    },
    ...
    }
    }
  3. 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 the id 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: $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"
    }
    }
    }
API DocsScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCareers
© 2023-2024 – Scaleway