Skip to main content

disks

Creates, updates, deletes, gets or lists a disks resource.

Overview

Namedisks
TypeResource
Idlinode.linode.disks

Fields

The following fields are returned by SELECT queries:

Returns a single Disk object.

NameDatatypeDescription
idintegerRead-only This disk's ID. You need this value to run other operations that interact with the disk.
createdstring (date-time)Read-only When this disk was created. (example: 2018-01-01T00:01:01)
disk_encryptionstringRead-only Displays if encryption is enabled on this disk. This setting is based on the disk_encryption setting of the Linode. (default: enabled, example: disabled)
filesystemstringThe disk's format or file system. A value of raw indicates no file system, just a raw binary stream. A value of swap indicates a Linux swap area. The values ext3 or ext4 represent these Linux journaling file systems. The value ext2 is the deprecated ext2 Linux file system. Finally, initrd indicates the disk is formatted as an uncompressed initial RAM disk. > 📘 > > The ext2 file system doesn't properly support timestamps and will be removed from Linux support in the near future. Also, initrd is a legacy format that no longer applies to most use cases. As a best practice, use the other supported formats or file systems instead. (raw, swap, ext2, ext3, ext4, initrd) (example: ext4)
labelstringFilterable The name of the disk. This is for display purposes only. (example: Debian 9 Disk)
sizeintegerFilterable The size of the disk in MB.
statusstringRead-only The current state of the disk. (ready, not ready, deleting) (example: ready)
updatedstring (date-time)Read-only When this disk was last updated. (example: 2018-01-01T00:01:01)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectlinodeId, diskIdView Disk information for a Disk associated with this Linode.

Learn more...

Learn more...
listselectlinodeIdpage, page_sizeView Disk information for Disks associated with this Linode.

Learn more...

Learn more...
createinsertlinodeId, sizeAdd a new disk to an existing Linode. You can create an empty disk to manually configure it later. You can also target a stored image to build the disk using a pre-configured file system--either through an image you've created or via a StackScript. For added security with all disks, you should supply SSH keys for the disk's root_pass user, using the authorized_keys field.

> 📘
>
> A Linode can have up to 50 disks.

Empty disks

- When creating an empty disk, a label is required.

- The default file system for an empty disk is ext4.

Disks created from an image

- A root_pass is required for a disk created from a stored image.

- A created disk inherits both the label and the filesystem from the target image, unless you specify otherwise.

- We offer an example workflow to create a disk using a stored image.

Disks created from a StackScript

- You can run List StackScripts to review available StackScripts.

- You need to include a StackScript-compatible image when creating the disk. Run Get a StackScript to review available images.

Learn more...

Learn more...
updatereplacelinodeId, diskIdUpdates a Disk that you have permission to read_write.

Learn more...

Learn more...
deletedeletelinodeId, diskIdDeletes a Disk you have permission to read_write.

Deleting a Disk is a destructive action and cannot be undone.

Learn more...

Learn more...
cloneexeclinodeId, diskIdCopies a disk, byte-for-byte, into a new disk on the same Linode. The operation fails if the target doesn't have enough storage space. A Linode can have up to 50 disks.

Learn more...

Learn more...
reset_passwordexeclinodeId, diskId, passwordResets the password of a Disk you have permission to read_write.

Learn more...

Learn more...
resizeexeclinodeId, diskId, sizeResizes a Disk you have permission to read_write.

The Disk must not be in use. If the Disk is in use, the request will succeed but the resize will ultimately fail. For a request to succeed, the Linode must be shut down prior to resizing the Disk, or the Disk must not be assigned to the Linode's active Configuration Profile.

If you are resizing the Disk to a smaller size, it cannot be made smaller than what is required by the total size of the files current on the Disk.

Learn more...

Learn more...

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
diskIdstringID of the Disk to look up.
linodeIdstringID of the Linode to look up.
pageintegerThe page of a collection to return.
page_sizeintegerThe number of items to return per page.

SELECT examples

View Disk information for a Disk associated with this Linode.

Learn more...

Learn more...

SELECT
id,
created,
disk_encryption,
filesystem,
label,
size,
status,
updated
FROM linode.linode.disks
WHERE linodeId = '{{ linodeId }}' -- required
AND diskId = '{{ diskId }}' -- required
;

INSERT examples

Add a new disk to an existing Linode. You can create an empty disk to manually configure it later. You can also target a stored image to build the disk using a pre-configured file system--either through an image you've created or via a StackScript. For added security with all disks, you should supply SSH keys for the disk's root_pass user, using the authorized_keys field.

> 📘
>
> A Linode can have up to 50 disks.

Empty disks

- When creating an empty disk, a label is required.

- The default file system for an empty disk is ext4.

Disks created from an image

- A root_pass is required for a disk created from a stored image.

- A created disk inherits both the label and the filesystem from the target image, unless you specify otherwise.

- We offer an example workflow to create a disk using a stored image.

Disks created from a StackScript

- You can run List StackScripts to review available StackScripts.

- You need to include a StackScript-compatible image when creating the disk. Run Get a StackScript to review available images.

Learn more...

Learn more...

INSERT INTO linode.linode.disks (
authorized_keys,
authorized_users,
filesystem,
image,
label,
root_pass,
size,
stackscript_data,
stackscript_id,
linodeId
)
SELECT
'{{ authorized_keys }}',
'{{ authorized_users }}',
'{{ filesystem }}',
'{{ image }}',
'{{ label }}',
'{{ root_pass }}',
{{ size }} /* required */,
'{{ stackscript_data }}',
{{ stackscript_id }},
'{{ linodeId }}'
RETURNING
id,
created,
disk_encryption,
filesystem,
label,
size,
status,
updated
;

REPLACE examples

Updates a Disk that you have permission to read_write.

Learn more...

Learn more...

REPLACE linode.linode.disks
SET
label = '{{ label }}'
WHERE
linodeId = '{{ linodeId }}' --required
AND diskId = '{{ diskId }}' --required
RETURNING
id,
created,
disk_encryption,
filesystem,
label,
size,
status,
updated;

DELETE examples

Deletes a Disk you have permission to read_write.

Deleting a Disk is a destructive action and cannot be undone.

Learn more...

Learn more...

DELETE FROM linode.linode.disks
WHERE linodeId = '{{ linodeId }}' --required
AND diskId = '{{ diskId }}' --required
;

Lifecycle Methods

Copies a disk, byte-for-byte, into a new disk on the same Linode. The operation fails if the target doesn't have enough storage space. A Linode can have up to 50 disks.

Learn more...

Learn more...

EXEC linode.linode.disks.clone
@linodeId='{{ linodeId }}' --required,
@diskId='{{ diskId }}' --required
;