How do I clone a profile or disk to another Linode using the APIv4?

Linode Staff

I want to use curl to copy my configuration profile and disks to an existing Linode. Your documentation only has an example of how to clone to a new Linode.

1 Reply

In general you will want to first get an access code and exchange it for an access token.

Lets assume we have the token "03d084436a6c91fbafd5c4b20c82e5056a2e9ce1635920c30dc8d81dc7a6665c"

Let's say we move configuration profiles and disks from Linode A (id: 9111111) to Linode B (id: 9222222)

If we do not already know the ids of the configuration profiles or the disks, we must get them first.

Get a list of configs for Linode A

curl -H "Authorization: Bearer 03d084436a6c91fbafd5c4b20c82e5056a2e9ce1635920c30dc8d81dc7a6665c" \
    https://api.linode.com/v4/linode/instances/9111111/configs

This will return a JSON response body like:

{
  "pages": 1,
  "results": 1,
  "data": [
    {
      "id": 804,
      "comments": "Example Linode configuration",
      "created": "2015-09-29T11:21:38.000Z",
      "devices": {
        "sda": {
          "volume_id": 120394
        },
        "sdb": {
          "volume_id": 120394
        },
        "sdc": null,
        "sdd": null,
        "sde": null,
        "sdf": null,
        "sdg": null,
        "sdh": null
      },
      "helpers": {
        "updatedb_disabled": true,
        "distro": true,
        "modules_dep": true,
        "network": true,
        "devtmpfs_automount": false
      },
      "initrd": "null",
      "kernel": "linode/latest-64bit",
      "label": "My openSUSE 13.2 Profile",
      "memory_limit": 512,
      "root_device": "/dev/sda",
      "run_level": "default",
      "updated": "2015-09-29T11:21:38.000Z",
      "virt_mode": "paravirt"
    }
  ],
  "page": 1
}

You can use the values to create the configuration profile on the new Linode or you can clone them.

If you want to clone them, take the id from the configuration profile you want to clone (Lets say 804 from the example above) and use the Linode Clone endpoint:

We can also get the volume ids of the disks in use from the configuration profile if we want to clone them with the profile. In this example the volume ids are 120394, 120395. Lets clone them too:

curl -H "Content-Type: application/json" \
    -H "Authorization: Bearer 03d084436a6c91fbafd5c4b20c82e5056a2e9ce1635920c30dc8d81dc7a6665c" \
    -X POST -d '{
        "linode_id": "9222222",
        "configs": [804],
        "disks": [120394, 120395]
        }
    }' \
    https://api.linode.com/v4/linode/instances/9111111/clone

If you want to get a list of all the disks on Linode A, you can use:

curl -H "Authorization: Bearer 03d084436a6c91fbafd5c4b20c82e5056a2e9ce1635920c30dc8d81dc7a6665c" \
    https://api.linode.com/v4/linode/instances/9111111/disks

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct