Managing Volumes

The local volume is always connected to the cloud server and can only be managed in the Cloud Platform Control panel on the server page.

The list of network volumes can be found in the Volumes section of the project in the Control panel. Volumes are categorized by the Availability Zones in which they were created. A network volume can be managed in the volume card, on the page of the server it is connected to, or using the OpenStack CLI.

In addition to the actions on volumes described below, you can create snapshots of the volumes and volume images.

Viewing Information about Network Volumes through CLI

Learn more about getting started with the OpenStack CLI.

Viewing the List of Volumes

To view the list of the network volumes of the project, run the command with the --long key to display the Type (volume type) and Bootable (true — boot or false - unbootable volume) fields:

openstack volume list --long

Viewing Volume Types

Run the following command to view available volume types (this can be useful, for example, to create a volume):

openstack volume type list

The response will look as follows:

+--------------------------------------+-----------------+-----------+
| ID                                   | Name            | Is Public |
+--------------------------------------+-----------------+-----------+
| ce80ecbd-385a-4e5a-aed9-8b6e5f3359ba | iso.ru-3a       | True      |
| f42f37b2-062f-4ce2-a6b3-28ca5e619030 | basic.ru-3a     | True      |
| 9c16598e-342b-4ff2-b948-8c05cf8f1490 | fast.ru-3a      | True      |
| fca113dd-a80f-4996-be54-cf2515d4ddee | universal.ru-3a | True      |
+--------------------------------------+-----------------+-----------+

The volume can be fast, basic, universal, or iso. The volume type is displayed in the VolumeType.ZoneName format, for example, fast.ru-3a.

When starting a cloud server, if the boot volume is of the ISO type, the operating system installer starts.

Viewing the Volume Properties

To check the properties of the created volume, run:

openstack volume show <volume>

The response will look as follows:

+------------------------------+---------------------------------------------------------------------------------------------------+
| Field                        | Value                                                                                             |
+------------------------------+---------------------------------------------------------------------------------------------------+
| attachments                  | []                                                                                                |
| availability_zone            | ru-2b                                                                                             |
| bootable                     | true                                                                                              |
| consistencygroup_id          | None                                                                                              |
| created_at                   | 2020-04-28T00:43:21.000000                                                                        |
| description                  | None                                                                                              |
| encrypted                    | False                                                                                             |
| id                           | 08ed209f-5e7f-465c-b1e1-221b850298db                                                              |
| multiattach                  | False                                                                                             |
| name                         | Volume                                                                                            |
| os-vol-tenant-attr:tenant_id | 04d92ef9fe2i4caia90d6ecd2849c1cf89u                                                               |
| properties                   |                                                                                                   |
| replication_status           | None                                                                                              |
| size                         | 5                                                                                                 |
| snapshot_id                  | None                                                                                              |
| source_volid                 | None                                                                                              |
| status                       | available                                                                                         |
| type                         | fast.ru-2b                                                                                        |
| updated_at                   | 2020-04-28T00:43:22.000000                                                                        |
| user_id                      | d38f89ea67f94083803c5066f4586698i4a                                                               |
| volume_image_metadata        | {u'x_sel_os_type': u'linux', u'x_sel_image_agent_type': u'cloud-init', u'container_format':       |
|                              | u'bare', u'min_ram': u'512', u'hw_scsi_model': u'virtio-scsi', u'x_sel_image_type': u'master',    |
|                              | u'watchdog': u'pause', u'size': u'2133000192', u'os_distro': u'ubuntu', u'disk_format': u'raw',   |
|                              | u'x_sel_kpti_patch': u'True', u'hw_disk_bus': u'scsi', u'x_sel_image_owner': u'Selectel',         |
|                              | u'x_sel_image_source_file': u'ubuntu-bionic-amd64-selectel-master-product-0.1.img',               |
|                              | u'x_sel_image_os_dist': u'ubuntu', u'hw_qemu_guest_agent': u'yes', u'x_sel_image_os_arch':        |
|                              | u'amd64', u'image_name': u'Ubuntu 18.04 LTS 64-bit', u'image_id': u'c5c8d3cc-9a2c-48ce-adfe-      |
|                              | 93e066e9ae6e', u'min_disk': u'5', u'checksum': u'd4b69f195a23edaaf3b88b7807f980cc', u'os_type':   |
|                              | u'linux'}                                                                                         |
+------------------------------+---------------------------------------------------------------------------------------------------+

Changing the Volume Type

You cannot change the network volume type directly. To change the type of a boot or additional network volume, you need to create a new volume of the desired type, for example:

  • create a new volume of a different type from volume (clone it);
  • create a snapshot of the volume, and then create a new volume of a different type from snapshot;
  • create a volume image, and then create a new volume from image;
  • create an empty volume of the required type and transfer the data to it — learn more about this method below.

Changing the Volume Type by Creating an Empty Volume

To change the volume type:

  1. Create an empty volume of the desired type.
  2. Connect it to the virtual machine (the old volume must also be connected).
  3. Transfer data from the old volume to the new one using the OS of the virtual machine: copy files or transfer the contents of the volume using the dd utility in rescue mode.

If the type of the boot volume changes, then when creating a new volume through the OpenStack CLI, you need to specify the volume properties.

Example:

openstack volume create \
      --size <size gb> \
      --type <new type> \
      --property hw_disk_bus=scsi \
      --property hw_scsi_model=virtio-scsi \
<new volume name>

Renaming the Volumes

Renaming the Volumes in the Control Panel

To rename a volume in the Control panel:

  1. Go to the Volumes section in the project.
  2. Expand the (⋮) menu of the volume and click Rename.
  3. Enter a new name.

Renaming the Volumes through CLI

Learn more about getting started with the OpenStack CLI.

To rename a volume, run the following:

openstack volume set --name <new name> <volume>

Increasing Volume Size

Please note that we recommend creating a snapshot of your volume before modifying partitions or the file system to avoid losing any data.

Learn more about network volumes limits.

Increasing Local Volume Size

The size of the local volume cannot be increased directly — you need to change the configuration of the cloud server for which the volume is bootable.

To increase the local volume size in the Control panel:

  1. Go to the Servers section.
  2. Open the Configuration tab on the server page and click Edit configuration.
  3. Choose a configuration with a larger local volume size.
  4. Click Apply and restart server.

Reconfiguration and resizing may take about 30—40 minutes, as the virtual machine is migrated to another virtualization host.

Increasing Network Volume Size

Increasing Network Volume Size in the Control Panel

To increase the network volume (boot or additional) in the Control panel:

  1. Go to the Servers section.
  2. Open the Network volumes tab on the server page.
  3. In the (⋮) menu of the desired volume, select Volume size.

    Please note that you can also change the volume size in the Volumes section. To do this, in the (⋮) volume menu, click Extend volume size or expand the volume card and go to the Size tab.

  4. Specify a new value in GB and save the changes.

  5. To apply the changes, complete the configuration:

Increasing Volume Size through CLI

Learn more about getting started with the OpenStack CLI.

To change the volume size (in GB), run the following:

openstack volume set --size <size> <volume>

Utilities for Increasing Volume Size

Linux

It is not necessary to turn off the VM when using modern OS distributions (for example, Ubuntu 18.04 LTS 64-bit).

Use the growpart utility from the cloud-initramfs-growroot package to increase the volume size for Unix-based servers:

# growpart --help
growpart disk partition
   rewrite partition table so that partition takes up all the space it can
   options:
    -h | --help       print Usage and exit
         --fudge F    if part could be resized, but change would be
                      less than 'F' bytes, do not resize (default: 1048576)
    -N | --dry-run    only report what would be done, show new 'sfdisk -d'
    -v | --verbose    increase verbosity / debug
    -u | --update  R  update the the kernel partition table info after growing
                      this requires kernel support and 'partx --update'
                      R is one of:
                       - 'auto'  : [default] update partition if possible
                       - 'force' : try despite sanity checks (fail on failure)
                       - 'off'   : do not attempt
                       - 'on'    : fail if sanity checks indicate no support

   Example:
    - growpart /dev/sda 1
      Resize partition 1 on /dev/sda

After resizing partitions via growpart, run an additional change to the file system itself via resize2fs.

Launch example:

growpart /dev/sda 1
resize2fs /dev/sda1

*Please note that if something went wrong (for example, your image does not have the necessary utilities or your distribution does not support resizing on-the-fly), then boot to rescue mode and run the same commands.

Decreasing Volume Size

Decreasing volume size is not available to maintain the integrity of the volume file system and data.

To shrink a volume, we recommend creating a new volume with the appropriate volume size and transferring your data.

Attaching Volumes to the Server

Only additional network volumes can be attached to a cloud server with a local boot volume. You can change the boot volume and attach additional network volumes for a cloud server with a network boot volume.

Please note that if the cloud server was created from an image with property=virtio-blk, you can attach no more than 26 volumes to it, including the boot one. If a virtual machine was created from an image with property=virtio-scsi (this property is set by default in default images), then the limit is 255 volumes. Learn more about the properties of images.

Attaching (Changing) the Boot Network Volume

You can change the boot volume to another one for a cloud server with a boot network volume.

To change a boot network drive to another one:

  1. Stop the cloud server. Learn more about managing cloud servers.
  2. Detach all volumes from the server.
  3. First, attach the network volume from which you want to boot the cloud server — this volume will automatically become the boot one.

    Please note that you will need to transfer the bootloader/OS and all related software to the volume in advance.

  4. Connect additional network volumes if necessary.

Attaching an Additional Network Volume

Attaching an Additional Volume in the Control Panel

Please note that you need to make sure the VM is turned off, or turned on and fully booted (including the OS). Learn more in the Managing cloud servers instructions.

To connect an additional volume to the server in the Control panel:

  1. Go to the Volumes section in the project.
  2. Go to the Control tab in the volume card.
  3. In the Attach to server field, select the required server and click Attach.

    Please note that you can also attach a volume in the Servers section. To do this, click Attach volume on the Network volumes tab of the server page and select the volume.

  4. Prepare the disk for operation – format and mount it.

Attaching an Additional Volume through CLI

Learn more about getting started with the OpenStack CLI.

Make sure the machine is fully booted (including the OS) before attaching the volume or stop the server:

openstack server stop <server>

To connect a volume to a server, run:

openstack server add volume <server> <volume>

Prepare the disk for operation – format and mount it.

Formatting and Mounting an Additional Volume

You need to prepare the additional volume for operation before using it.

The attached empty network volume does not have a file system, so you need to create a partition table on the volume and then mount it. If the additional volume created from a source (image, another volume, or snapshot) is attached to the machine, then you only need to mount this volume before using it.

To prepare the volume for operation:

  1. Connect to the virtual machine via SSH.
  2. To view a list of all volumes connected to the virtual machine, run the lsblk command:

    lsblk
    
    NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda       8:0    0    8G  0 disk 
    ├─sda1    8:1    0    8G  0 part /
    └─sda14   8:14   0    8M  0 part 
    sdb       8:16   0    7G  0 disk 

    In this example, sdb is an additional volume.

  3. If the attached volume was created from a source, then go to step 7. If the volume is empty, then run the parted utility to create the file system and volume partitions:

    parted /dev/sdb
  4. Create a partition table with GPT markup:

    (parted) mklabel gpt
  5. Create partitions using the mkpart command and specify the beginning and end of the partition:

    (parted) mkpart primary 0 1GB 
    (parted) mkpart primary 1GB 3GB 

    This example creates the first 1 GB partition and the second 2 GB partition (1 GB to 3 GB sector).

  6. View the created partition table and exit:

    (parted) print 
    (parted) quit 
  7. Format each volume partition using the mkfs command (the ext4 partition format is used):

    mkfs.ext4 /dev/sdb1 
    mkfs.ext4 /dev/sdb2
  8. Create a directory for mounting the volume and mount partitions in it:

    mkdir -p /mnt
    mount /dev/sdb1 /mnt
    mount /dev/sdb2 /mnt
  9. Check the result with the lsblk command.

Reconnecting the Volumes

To reconnect the volume, detach it from the server and then attach the volume.

Detaching Volumes from the Server

You can detach the boot and additional network volume from the cloud server.

Detaching Volumes in the Control Panel

To detach the volume from the server in the Control panel:

  1. Go to the Volumes section in the project.
  2. Stop the server if you want to detach the boot volume.
  3. Open the (⋮) menu of the volume and select Detach from server or expand the volume card, go to the Control tab and click Detach.

Please note that you can also detach a volume in the Servers section. To do this, click *Detach from the (⋮) menu of the volume on the Network volumes tab of the server page.

Detaching Volumes through CLI

Learn more about getting started with the OpenStack CLI.

Stop the server if you want to detach the boot volume.

openstack server stop <server>

To detach a volume from the server:

openstack server remove volume <server> <volume>

Transferring Volumes between Projects

Transferring a volume to other projects can be performed only within one region and one zone. You can transfer one volume or several volumes at once.

Transferring Volumes between Projects in the Control Panel

To transfer the volume in the Control panel:

  1. Detach the volume from the server.
  2. Go to the Volumes section in the project.
  3. In the (⋮) menu of the volume, select Transfer volume to another project or open the volume card, go to the Control tab and click Transfer volume. The section will contain the Transfer ID and Key, save them.

    To transfer multiple volumes at once, from the (⋮) menu of the Volumes section, select Transfer volumes to another project. In the list that opens, select the required volumes and click Transfer. The JSON file will automatically start downloading to the local computer. This file contains transfer data, save it.

  4. The volumes will be ready for transfer and will be in the AWAITING-TRANSFER status, in which they are not available for operation.

    Please note that if you want to undo the transfer of the volume, you need to return it from the AWAITING-TRANSFER status to the normal state. To do this, click Cancel transfer on the Control tab in the volume card.

  5. Go to the Volumes section in the project you want to move the volumes to.

  6. From the (⋮) menu of the section, select Transfer volume from another project.

  7. Fill in the Transfer ID and Key fields, the values of which were saved earlier – they are located under the Control tab of the card of the transferred volume.

    To transfer several volumes at once, click Upload list and upload the previously saved JSON file with transfer data.

  8. Click Transfer.

The volumes will be transferred to another project.

Transferring Volumes between Projects thorough CLI

Learn more about getting started with the OpenStack CLI.

Disconnect the volume from the virtual machine:

openstack server remove volume <server> <volume>

To transfer a volume between projects:

openstack volume transfer request create <volume>

To transfer multiple volumes:

openstack volume transfer request create <volume 1> <volume 2> <volume 3>

An example of transferring a volume between projects:

openstack volume transfer request create fda41064-1aec-4b11-a427-5b46dafce12

The response will look as follows:

+------------+--------------------------------------+
| Field      | Value                                |
+------------+--------------------------------------+
| auth_key   | 766e89ce43c8b96f                     |
| created_at | 2020-04-28T01:52:32.649970           |
| id         | c095a116-9728-4f79-846d-1ba52cf93ed6 |
| name       | None                                 |
| volume_id  | fda41064-1aec-4b11-a427-5b46dafce12  |
+------------+--------------------------------------+

The value of the auth_key and the transfer ID must be saved to accept the transfer in another project.

If transfer is not needed, return it from the AWAITING-TRANSFER status to the normal state by deleting the transfer request:

openstack volume transfer request delete <transfer request id>

In the project to which the volume is transferred, specify the key and transfer ID:

openstack volume transfer request accept --auth-key <auth key> <transfer request id>

Transferring Volumes to Another Zone

To transfer a volume to another zone:

  1. Create an image from volume.
  2. Copy the image to another zone.
  3. Create a volume from this image in the desired region.