Configuring virtual machine volumes
You can add new volumes to your virtual machines, attach existing volumes, and detach unneeded volumes from virtual machines.
Limitations
- You cannot change, detach, or delete the boot volume.
- You can only attach and detach non-boot volumes.
- You cannot manage volumes of shelved VMs.
Prerequisites
- To be able to use volumes attached to VMs, they must be initialized inside the guest OS by standard means.
To attach a volume to a virtual machine
Admin panel
- On the Compute > Virtual machines > Virtual machines screen, click the required virtual machine.
- On the Overview tab, click the pencil icon in the Disks field.
-
In the Volumes window:
- Click Attach to attach an existing volume, and then select the volume in the Attach volume window.
- Click Add to create a new volume, and then specify the volume name, size, and storage policy. The created volume will be automatically added to the VM disks.
- Click Done to finish editing VM disks and save your changes.
Command-line interface
Use the following command:
vinfra service compute server volume attach --server <server> <volume>
--server <server>
- Virtual machine ID or name
<volume>
- Volume ID or name
For example, to attach the available volume with the ID e4cb5363-1fb2-41f5-b24b-18f98a388cba
to the virtual machine myvm
, run:
# vinfra service compute server volume attach e4cb5363-1fb2-41f5-b24b-18f98a388cba --server myvm +--------+--------------------------------------+ | Field | Value | +--------+--------------------------------------+ | device | /dev/vdb | | id | e4cb5363-1fb2-41f5-b24b-18f98a388cba | +--------+--------------------------------------+
The name of the new device will be shown in the command output. To see all of the VM volumes, run:
# vinfra service compute server volume list --server myvm +--------------------------------------+----------+ | id | device | +--------------------------------------+----------+ | e4cb5363-1fb2-41f5-b24b-18f98a388cba | /dev/vdb | | b325cc6e-8de1-4b6c-9807-5a497e3da7e3 | /dev/vda | +--------------------------------------+----------+
To detach a volume from a virtual machine
Admin panel
- On the Compute > Virtual machines > Virtual machines screen, click the required virtual machine.
- On the Overview tab, click the pencil icon in the Disks field.
-
In the Volumes window:
- Click Detach to detach a volume from a stopped virtual machine.
-
Click Force detach to detach a volume from a running virtual machine.
There is a risk of data loss.
- Click Done to finish editing VM disks and save your changes.
Command-line interface
Use the following command:
vinfra service compute server volume detach --server <server> <volume>
--server <server>
- Virtual machine ID or name
<volume>
- Volume ID or name
For example, to detach the volume with the ID e4cb5363-1fb2-41f5-b24b-18f98a388cba
from the virtual machine myvm
, run:
# vinfra service compute server volume detach e4cb5363-1fb2-41f5-b24b-18f98a388cba \ --server 871fef54-519b-4111-b18d-d2039e2410a8