Creating an empty disk with a large block
Disks consist of blocks. By default, the block size of all new disks is 4 KB. You can set block size in the range from 4 KB to 128 KB when creating a disk.
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.
In most cases, the logical block size is equal to 512 bytes. Although the OS tries to align data I/O with the physical block size, this might not always be possible. In case the software performs many read/write operations with a size that is less than the physical block size, such small operations may 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. In case of write operations, the situation is even more complicated, as writing data with a size that is less than the physical block size requires first reading the entire physical block, then modifying the requested bytes, and, finally, rewriting 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 also be required to read and rewrite as many as two physical blocks. Thus, a single logical write operation may turn into two read and two write operations at the disk subsystem level. This extra load will not reveal itself in the guest OS metrics, but will matter when the load is compared to the disk limits and will eventually affect performance.
This is why we recommend picking large block sizes only in case 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 using the --folder-name
or --folder-id
parameter.
-
See the description of the CLI create disk commands:
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:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be 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:
-
Describe the resource parameters in the
yandex_compute_disk
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:- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
type
: Disk type. -
zone
: Availability zone. The availability zone for a disk must be the same as that of the placement group where you want to create the disk. 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 (the minimum storage size for information on the disk). By default, the block size of all created disks is 4 KB; however, this is not enough 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 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 described correctly, the terminal will display a list of created resources and their parameters. If the configuration contains any errors, Terraform will point them out.
-
-
Deploy cloud resources.
-
If the configuration does not contain any errors, run this command:
terraform apply
-
Confirm that you want to create the resources.
All the resources you need will then be created in the specified folder. You can check the new resources and their configuration 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.