0

Update a disk

by
Published Oct 17, 2025

Updates a Disk that you have permission to `read_write`. > --- - __CLI__. ``` linode-cli linodes disk-update 123 25674 \ --label "Debian 9 Disk" ``` [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli) - __OAuth scopes__. ``` linodes:read_write ``` [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Update a disk
7
 * Updates a Disk that you have permission to `read_write`.
8

9

10
>
11

12
---
13

14

15
- __CLI__.
16

17
    ```
18
    linode-cli linodes disk-update 123 25674 \
19
  --label "Debian 9 Disk"
20
    ```
21

22
    [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli)
23

24
- __OAuth scopes__.
25

26
    ```
27
    linodes:read_write
28
    ```
29

30
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
31
 */
32
export async function main(
33
  auth: Linode,
34
  apiVersion: "v4" | "v4beta",
35
  linodeId: string,
36
  diskId: string,
37
  body: { label?: string },
38
) {
39
  const url = new URL(
40
    `https://api.linode.com/${apiVersion}/linode/instances/${linodeId}/disks/${diskId}`,
41
  );
42

43
  const response = await fetch(url, {
44
    method: "PUT",
45
    headers: {
46
      "Content-Type": "application/json",
47
      Authorization: "Bearer " + auth.token,
48
    },
49
    body: JSON.stringify(body),
50
  });
51
  if (!response.ok) {
52
    const text = await response.text();
53
    throw new Error(`${response.status} ${text}`);
54
  }
55
  return await response.json();
56
}
57