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. (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. (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
get_linode_diskselectView Disk information for a Disk associated with this Linode.

Learn more...

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

Learn more...

Learn more...
post_add_linode_diskinsertdata__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.

- A Linode can have up to 50 disks.

- When creating an empty disk, you need to provide a label for it. If you don't include a label, you need to target an image instead.

- When you create a disk from an image, you need to set a root_pass for the disk.

- The default file system for a new disk is ext4. If you're creating one from an image, the disk inherits the file system of that image, is unless you specify otherwise.

- When you deploy a StackScript on a disk:

- You can run List StackScripts to review available StackScripts.

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

- You should supply SSH keys for the disk's root user, using the authorized_keys field.

- You can include individual users via the authorized_users field. Before you can add a user, it needs an SSH key assigned to its profile. See Add an SSH key for more information.

Learn more...

Learn more...
put_diskreplaceUpdates a Disk that you have permission to read_write.

Learn more...

Learn more...
delete_diskdeleteDeletes a Disk you have permission to read_write.

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

Learn more...

Learn more...
post_clone_linode_diskexecCopies 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...
post_reset_disk_passwordexecpasswordResets the password of a Disk you have permission to read_write.

Learn more...

Learn more...
post_resize_diskexecsizeResizes 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
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;

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.

- A Linode can have up to 50 disks.

- When creating an empty disk, you need to provide a label for it. If you don't include a label, you need to target an image instead.

- When you create a disk from an image, you need to set a root_pass for the disk.

- The default file system for a new disk is ext4. If you're creating one from an image, the disk inherits the file system of that image, is unless you specify otherwise.

- When you deploy a StackScript on a disk:

- You can run List StackScripts to review available StackScripts.

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

- You should supply SSH keys for the disk's root user, using the authorized_keys field.

- You can include individual users via the authorized_users field. Before you can add a user, it needs an SSH key assigned to its profile. See Add an SSH key for more information.

Learn more...

Learn more...

INSERT INTO linode.linode.disks (
data__authorized_keys,
data__authorized_users,
data__filesystem,
data__image,
data__label,
data__root_pass,
data__size,
data__stackscript_data,
data__stackscript_id
)
SELECT
'{{ authorized_keys }}',
'{{ authorized_users }}',
'{{ filesystem }}',
'{{ image }}',
'{{ label }}',
'{{ root_pass }}',
{{ size }} --required,
'{{ stackscript_data }}',
{{ stackscript_id }}
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
data__label = '{{ label }}'
WHERE

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;

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.post_clone_linode_disk 
;