[Yandex Cloud documentation](../../../index.md) > [Yandex Compute Cloud](../../index.md) > [Step-by-step guides](../index.md) > Creating a disk > Creating an empty disk with a large block

# 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.

{% note alert %}

The selected physical block size may affect disk performance.

{% endnote %}

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.

{% list tabs group=instructions %}

- Management console {#console}

  See [Creating an empty disk](empty.md).

- CLI {#cli}

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    1. See the description of the CLI commands for creating disks:

        ```bash
        yc compute disk create --help
        ```

    1. Create a disk in the default folder:

        ```bash
        yc compute disk create \
          --name big-disk \
          --zone <availability_zone> \
          --block-size 8K \
          --size 40G \
          --description "my 8k blocksize disk via yc"
        ```

       Where:
       * `--name`: Disk name. The disk naming requirements are as follows:

         * Length: between 3 and 63 characters.
         * It can only contain lowercase Latin letters, numbers, and hyphens.
         * It must start with a letter and cannot end with a hyphen.

       * `--zone`: [Availability zone](../../../overview/concepts/geo-scope.md) of the new disk. If the availability zone is not set in the [CLI profile](../../../cli/concepts/core-properties.md) by default, the parameter is required.
       * `--block-size`: Disk block size.
       * `--size`: Disk size.
       * `--description`: Disk description.

       This command will create a 40 GB disk with 8 KB block size, named `big-disk` and described as `my 8k blocksize disk via yc`.


    1. Get a list of disks in the default folder:

       ```bash
       yc compute disk list
       ```
       
       Result:
       
       ```text
       +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+
       |          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:

        ```bash
        yc compute disk list --format yaml
        ```

        Result:
        ```text
        - 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: {}
        ```

- Terraform {#tf}

  If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
  
  
  To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../../terraform/authentication.md) using the appropriate method.

  To create an empty disk:
  
  1. Define the parameters of the `yandex_compute_disk` resource in the configuration file.
  
     Here is an example of the configuration file structure:
  
     ```hcl
     resource "yandex_compute_disk" "empty-disk" {
       name       = "empty-disk"
       type       = "network-hdd"
       zone       = "<availability_zone>"
       size       = <disk_size>
       block_size = <block_size>
       kms_key_id = "<KMS_key_ID>"
     }
     ```
  
     Where:
     * `name`: Disk name. The name format is as follows:
  
          * Length: between 3 and 63 characters.
          * It can only 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](../../../overview/concepts/geo-scope.md). The availability zone for your disk must match the zone of the placement group where you want to create it.
     * `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](empty-disk-blocksize.md).
     * `kms_key_id`: ID of the [KMS symmetric key](../../../kms/concepts/key.md) to create an [encrypted](../../concepts/encryption.md) disk. This is an optional setting.
  
          To create an encrypted disk, you need the `kms.keys.user` [role](../../../kms/security/index.md#kms-keys-user) or higher.
  
          {% note warning %}
          
          You can specify encryption settings only when creating a disk. You cannot disable or change disk encryption. You also cannot enable encryption for an existing disk.
          
          {% endnote %}
  
          If you deactivate the key used to encrypt a disk, image, or snapshot, access to the data will be suspended until you reactivate the key.
          
          {% note alert %}
          
          If you destroy the key or its [version](../../../kms/concepts/version.md) used to encrypt a disk, image, or snapshot, you will irrevocably lose access to the data. For details, see [Destroying key version](../../../kms/concepts/version.md#version-distruct).
          
          {% endnote %}
  
     For more information about `yandex_compute_disk`, see [this provider guide](../../../terraform/resources/compute_disk.md).
  
  1. Make sure the configuration files are correct.
  
     1. In the terminal, navigate to the directory where you created your configuration file.
     1. Run a check using this command:
  
        ```bash
        terraform plan
        ```
  
     If the configuration is correct, the terminal will display a list of the resources and their settings. Otherwise, Terraform will show any detected errors. 
  
  1. Deploy the cloud resources.
  
     1. If the configuration is correct, run this command:
  
        ```bash
        terraform apply
        ```
  
     1. Confirm creating the resources.
  
     This will create all the resources you need in the specified folder. You can check the new resources and their settings using the [management console](https://console.yandex.cloud) or this [CLI](../../../cli/quickstart.md) command:
  
        ```bash
        yc compute disk list
        ```

- API {#api}

  Use the [create](../../api-ref/Disk/create.md) REST API method for the [Disk](../../api-ref/Disk/index.md) resource or the [DiskService/Create](../../api-ref/grpc/Disk/create.md) gRPC API call.

{% endlist %}


#### Useful links {#see-also}

* [Creating a disk snapshot schedule](../snapshot-control/create-schedule.md)