---
title: Insert a CD-ROM ISO image into a live virtual machine
---

# Insert a CD-ROM ISO image into a live virtual machine {#virt-inserting-cd-roms-in-virtual-machines}

To attach a storage device to a virtual machine (VM) without rebooting the VM, you can configure a VM to use a virtual CD-ROM drive, and insert an ISO image in the drive.

This also makes it possible to install an operating system from a CD-ROM in the VM.

## Inserting a CD-ROM in a live VM by using the command line {#virt-inserting-a-cd-rom-in-a-vm-by-using-the-command-line_virt-inserting-cd-roms-in-virtual-machines}

To make data on a CD-ROM storage device available to a running virtual machine (VM), create a virtual CD-ROM drive in the VM and insert the CD-ROM into the drive as an ISO image.

Setting up a virtual CD-ROM drive requires rebooting the VM, but afterwards, you can insert and eject ISO images in the drive while the VM is running.

**Prerequisites**

- The `DeclarativeHotplugVolumes` feature gate is enabled. To ensure this, the `HyperConverged` CR must contain the `declarativeHotplugVolumes: true` line in the `spec.featureGates` configuration section:

  ```yaml
  apiVersion: hco.kubevirt.io/v1beta1
  kind: HyperConverged
  metadata:
    name: kubevirt-hyperconverged
    namespace: openshift-cnv
  spec:
      featureGates:
        declarativeHotplugVolumes: true
  ```

  > [!NOTE]
  > The `DeclarativeHotplugVolumes` feature gate does not support hot plugging ephemeral volumes.
- You have an ISO image of a CD-ROM available in the cluster.

**Procedure**

1. Run the following command to edit the configuration of the VM in which you want to insert the CD-ROM:

   ```terminal
   $ oc edit vm <vm-name> -n <namespace>
   ```

   where:

   - `<vm-name>` is the name of the VM
   - `<namespace>` is the name of the project name space that contains the VM
2. Add a `cdrom` disk to the `spec.template.spec.domains.devices.disks` section of the VM configuration. For example:

   ```yaml
   apiVersion: kubevirt.io/v1
   kind: VirtualMachine
   metadata:
     name: example-vm
   spec:
     runStrategy: Always
     template:
       spec:
         domain:
           devices:
             disks:
             - cdrom:
                 bus: sata
                 name: cdrom
   ```
3. If the VM is running, shut it down.
4. Insert a CD-ROM volume in the `spec.template.spec.volumes` section of the VM configuration. For example:

   ```yaml
   apiVersion: kubevirt.io/v1
   kind: VirtualMachine
   metadata:
     name: example-vm
   spec:
     template:
       spec:
         volumes:
         - dataVolume:
             name: cdrom-example
             hotpluggable: true
           name: cdrom
   ```

   You can insert a CD-ROM this way while the VM is running, but the dataVolume must have the `hotpluggable: true` parameter set.
5. Optional: In the guest operating system, verify that the CD-ROM has been detected.
6. Optional: Eject the CD-ROM volume. To do so, remove the `cdrom` volume from the `spec.template.spec.volumes` section of the VM configuration. You can do this while the VM is running.

## Inserting a CD-ROM in a live VM by using the web console {#virt-inserting-a-cd-rom-in-a-vm-by-using-the-web-console_virt-inserting-cd-roms-in-virtual-machines}

To make data on a CD-ROM storage device available to a running virtual machine (VM), create a virtual CD-ROM drive in the VM and insert the CD-ROM into the drive as an ISO image.

Setting up a virtual CD-ROM drive requires rebooting the VM, but you can insert and eject ISO images in the drive while the VM is running.

**Prerequisites**

- The `DeclarativeHotplugVolumes` feature gate is enabled. To ensure this, the `HyperConverged` CR must contain the `declarativeHotplugVolumes: true` line in the `spec.featureGates` configuration section:

  ```yaml
  apiVersion: hco.kubevirt.io/v1beta1
  kind: HyperConverged
  metadata:
    name: kubevirt-hyperconverged
    namespace: openshift-cnv
  spec:
      featureGates:
        declarativeHotplugVolumes: true
  ```

  > [!NOTE]
  > The `DeclarativeHotplugVolumes` feature gate does not support hot plugging ephemeral volumes.

**Procedure**

1. In the OpenShift Container Platform web console, go to **Virtualization** → **VirtualMachines**.
2. Click the name of the VM in which you want to insert the CD-ROM.
3. On the VM details page, click the **Configuration** tab.
4. Open the **Storage** pane.
5. Click **Add**.

   A drop-down menu opens.
6. Click **CD-ROM**.
7. In the **Name** field, add a name for the CD-ROM drive device.
8. Select the ISO image to add to the drive as a CD-ROM volume. To do so, click the drop-down button, and select from the volumes available in the cluster.

   Alternatively, you can upload a new ISO file and insert it into the CD-ROM drive after it is created. To do so:

   1. Ensure that the **Upload a new ISO file to the cluster** line is checked.
   2. Drag and drop an ISO file in the **Upload ISO** field, or click **Upload** and select the ISO image that you want to upload.
   3. In the **Upload mode** field, select **Mount uploaded ISO as DataVolume**.
9. Click **Add**.

   The CD-ROM drive is added to the **Storage** list.
10. If the VM is running, shut it down or restart it.
11. To insert the ISO file attached to the CD-ROM drive as a CD-ROM volume into the VM, click the Options menu ![](/openshift-docs-markdown/images/kebab.png "Options menu") next to the CD-ROM drive, and click **Inject**. You can do this while the VM is running.
12. Optional: In the guest operating system, verify that the CD-ROM has been detected.
13. Optional: To eject the CD-ROM from the VM, click the Options menu ![](/openshift-docs-markdown/images/kebab.png "Options menu") next to the CD-ROM device in the web console, and select **Eject**. You can do this while the VM is running.
