×

About hot plugging virtual disks

When you hot plug a virtual disk, you attach a virtual disk to a virtual machine instance while the virtual machine is running.

When you hot unplug a virtual disk, you detach a virtual disk from a virtual machine instance while the virtual machine is running.

Only data volumes and persistent volume claims (PVCs) can be hot plugged and hot unplugged. You cannot hot plug or hot unplug container disks.

After you hot plug a virtual disk, it remains attached until you detach it, even if you restart the virtual machine.

In the web console, hot-plugged volumes are marked by a "persistent hotplug" label on the disk in the disk list (VirtualMachine DetailsConfigurationDisks tab). To change a hot-plug volume to a persistent volume, click the Options menu kebab and select Make persistent. The "persistent hotplug" label is removed and the change is applied after the next reboot.

About virtio-scsi

In OKD Virtualization, each virtual machine (VM) has a virtio-scsi controller so that hot plugged disks can use a scsi bus. The virtio-scsi controller overcomes the limitations of virtio while retaining its performance advantages. It is highly scalable and supports hot plugging over 4 million disks.

Regular virtio is not available for hot plugged disks because it is not scalable: each virtio disk uses one of the limited PCI Express (PCIe) slots in the VM. PCIe slots are also used by other devices and must be reserved in advance, therefore slots might not be available on demand.

Hot plugging a virtual disk using the CLI

Hot plug virtual disks that you want to attach to a virtual machine instance (VMI) while a virtual machine is running.

Prerequisites
  • You must have a running virtual machine to hot plug a virtual disk.

  • You must have at least one data volume or persistent volume claim (PVC) available for hot plugging.

Procedure
  • Hot plug a virtual disk by running the following command:

    $ virtctl addvolume <virtual-machine|virtual-machine-instance> --volume-name=<datavolume|PVC> \
    [--persist] [--serial=<label-name>]
    • Use the optional --persist flag to add the hot plugged disk to the virtual machine specification as a permanently mounted virtual disk. Stop, restart, or reboot the virtual machine to permanently mount the virtual disk. After specifying the --persist flag, you can no longer hot plug or hot unplug the virtual disk. The --persist flag applies to virtual machines, not virtual machine instances.

    • The optional --serial flag allows you to add an alphanumeric string label of your choice. This helps you to identify the hot plugged disk in a guest virtual machine. If you do not specify this option, the label defaults to the name of the hot plugged data volume or PVC.

Hot unplugging a virtual disk using the CLI

Hot unplug virtual disks that you want to detach from a virtual machine instance (VMI) while a virtual machine is running.

Prerequisites
  • Your virtual machine must be running.

  • You must have at least one data volume or persistent volume claim (PVC) available and hot plugged.

Procedure
  • Hot unplug a virtual disk by running the following command:

    $ virtctl removevolume <virtual-machine|virtual-machine-instance> --volume-name=<datavolume|PVC>

Hot plugging a virtual disk using the web console

Hot plug virtual disks that you want to attach to a virtual machine instance (VMI) while a virtual machine is running. When you hot plug a virtual disk, it remains attached to the VMI until you unplug it.

Prerequisites
  • You must have a running virtual machine to hot plug a virtual disk.

Procedure
  1. Click VirtualizationVirtualMachines from the side menu.

  2. Select the running virtual machine to which you want to hot plug a virtual disk.

  3. On the VirtualMachine details page, click ConfigurationDisks.

  4. Click Add disk.

  5. In the Add disk (hot plugged) window, fill in the information for the virtual disk that you want to hot plug.

  6. Click Save.

Hot unplugging a virtual disk using the web console

Hot unplug virtual disks that you want to detach from a virtual machine instance (VMI) while a virtual machine is running.

Prerequisites
  • Your virtual machine must be running with a hot plugged disk attached.

Procedure
  1. Click VirtualizationVirtualMachines from the side menu.

  2. Select the running virtual machine with the disk you want to hot unplug to open the VirtualMachine details page.

  3. Click ConfigurationDisks.

  4. Click the Options menu kebab beside the virtual disk that you want to hot unplug and select Detach.

  5. Click Detach.