// Module included in the following assemblies:
//
// * virt/virtual_machines/virtual_disks/virt-hot-plugging-virtual-disks.adoc

:_mod-docs-content-type: PROCEDURE
[id="virt-hot-plugging-disk-cli_{context}"]
= Hot plugging and hot unplugging a disk by using the CLI

[role="_abstract"]
You can hot plug and hot unplug a disk while a virtual machine (VM) is running by using the command line.

The hot plugged disk remains attached to the VM until you unplug it.

.Prerequisites

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

.Procedure

* Hot plug a disk by running the following command:
+
[source,terminal]
----
$ virtctl addvolume <virtual-machine|virtual-machine-instance> \
  --volume-name=<datavolume|PVC> \
  [--bus <bus_type>] [--serial=<label_name>]
----
+
** The optional `--bus` flag allows you to specify the bus type of the added disk. The options are `virtio` and `scsi`. The default bus type is `virtio`.
** 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 unplug a disk by running the following command:
+
[source,terminal]
----
$ virtctl removevolume <virtual-machine|virtual-machine-instance> \
  --volume-name=<datavolume|PVC>
----
