How can I automatically resize my disk to the largest size using the Linode API?

Linode Staff

I want to be able to resize my Linode's disk to the maximum size for its plan type without having to specify the size. Can this be done?

1 Reply

While you can't omit the size of a disk when resizing, it is possible to determine the maximum size for your Linode's plan programmatically using the Linode API. Specifically, you can use the "View Type" endpoint. By making a request to this endpoint and specifying which plan your Linode is using, you can obtain the maximum available disk size for your plan. It's worth noting that you will need to subtract the size of any of your Linode's other disks (including swap) from this value in order to avoid requesting a disk that is too large. You can use the "List Disks" endpoint to view the sizes of your Linode's other disks.

If you're using Linode CLI, then you can use a command like the following to view the specs for your Linode's plan, including maximum disk size. For example, to view the specs for a 4GB (2-core) Linode plan (g6-standard-2):

linode-cli linodes type-view g6-standard-2

You can check the sizes of your Linode's other disks like this:

linode-cli linodes disks-list $LINODE_ID

Just be sure to replace $LINODE_ID with your Linode's ID number (e.g. 12345).

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