How can I automatically resize my disk to the largest size using the Linode API?
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?
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 (
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.