Creating an empty disk with a large block
Disks consist of blocks. By default, the block size is 4 KB for all new disks. When creating a disk, you can set the block size between 4 KB and 128 KB.
For network disks, the maximum disk size depends on the block size. The size of a newly created disk must be a multiple of 4 MB. The possible disk and block sizes are as follows:
Block size | Maximum disk size |
---|---|
4 KB | 8 TB |
8 KB | 16 TB |
16 KB | 32 TB |
32 KB | 64 TB |
64 KB | 128 TB |
128 KB | 256 TB |
For non-replicated SSDs and ultra high-speed network SSD storages with three replicas, you can select any block size for any disk size. The disk size must be a multiple of 93 GB.
You cannot change the block size after the disk is created.
Alert
The selected physical block size may affect disk performance.
Typically, the logical block size is 512 bytes. Although the guest OS tries to align data I/O with the physical block size, this may not always be feasible. When the software runs numerous read and write operations that are smaller than the physical block, these operations can reach the disk subsystem. When it comes to read operations, this means reading more data than actually requested, i.e., at least one physical block. Write operations are even more complex, as to write data smaller than the physical block, the system first reads the entire physical block, then modifies specific bytes, and, finally, rewrites this block (this is known as read-modify-write operation). As long as such an operation is not aligned to the physical block size, it may require reading and rewriting two physical blocks. This can turn one logical write into two read and two write operations at the disk subsystem level. This extra load will not show up in the guest OS metrics but will affect performance and will be considered when assessing how close the load is to the disk limits.
This is why we recommend choosing large block sizes only when your software uses large requests (at least equal to the physical block size) when working with the file system or disk.
The folder specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
-
See the description of the CLI commands for creating disks:
yc compute disk create --help
-
Create a disk in the default folder:
yc compute disk create \ --name big-disk \ --block-size 8K \ --size 40G \ --description "my 8k blocksize disk via yc"
This command will create a 40 GB disk with 8 KB block size, named
big-disk
and described asmy 8k blocksize disk via yc
.The disk naming requirements are as follows:
- It must be 2 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Get a list of disks in the default folder:
yc compute disk list
Result:
+----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+ | ID | NAME | SIZE | ZONE | STATUS | INSTANCE IDS | PLACEMENT GROUP | DESCRIPTION | +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+ | a7lqgbt0bb9s******** | first-disk | 20401094656 | ru-central1-a | READY | a7lcvu28njbh******** | | | | a7lv5j5hm1p1******** | second-disk | 21474836480 | ru-central1-a | READY | | | | +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+
Get the same list with more details in YAML format:
yc compute disk list --format yaml
Result:
- id: fhmm0br99mig******** folder_id: b1gb9jeqoior******** created_at: "2021-01-11T09:35:05Z" name: big-disk description: 8k blocksize disk type_id: network-hdd zone_id: ru-central1-a size: "42949672960" block_size: "8192" status: READY disk_placement_policy: {}
If you don't have Terraform, install it and configure the Yandex Cloud provider.
To create an empty disk:
-
Define the parameters of the
yandex_compute_disk
resource in the configuration file.Here is an example of the configuration file structure:
resource "yandex_compute_disk" "empty-disk" { name = "empty-disk" type = "network-hdd" zone = "<availability_zone>" size = <disk_size> block_size = <block_size> }
Where:
-
name
: Disk name. The name format is as follows:- It must be 2 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
type
: Disk type. -
zone
: Availability zone. The availability zone for your disk must match the zone of the placement group where you want to create it. We recommend creating disks in theru-central1-a
orru-central1-b
availability zone. -
size
: Disk size in GB. The maximum disk size depends on the specified block size. -
block_size
: Block size in bytes (minimum storage unit on the disk). By default, the block size is 4 KB for all new disks; however, this is insufficient for disks larger than 8 TB. For more information, see Creating an empty disk with a large block.
For more information about the
yandex_compute_disk
resource, see the relevant provider documentation . -
-
Make sure the configuration files are correct.
-
In the command line, go to the directory where you created the configuration file.
-
Run a check using this command:
terraform plan
If the configuration is correct, the terminal will display a list of resources to create and their parameters. If the configuration contains any errors, Terraform will point them out.
-
-
Deploy the cloud resources.
-
If the configuration does not contain any errors, run this command:
terraform apply
-
Confirm creating the resources.
All the resources you need will then be created in the specified folder. You can check the new resources and their settings using the management console
or this CLI command:yc compute disk list
-
Use the create REST API method for the Disk resource or the DiskService/Create gRPC API call.