Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Attach Second Optical Drive to Windows VM

Featured Replies

Hello,

 

I am currently using the code listed below for one of my drives. How can I code in the another optical drive?

 

<controller type='scsi' index='0' model='virtio-scsi'/> 
<hostdev mode='subsystem' type='scsi'>
  <source>
  <adapter name='scsi_host5'/>
  <address type='scsi' bus='0' target='0' unit='0'/>
  </source>
  <readonly/> 
  <address type='drive' controller='0' bus='0' target='0' unit='0'/>
</hostdev>

 

Thanks,

Guru

Edited by Greatestguru

Solved by Greatestguru

  • 1 month later...
  • Author
  • Solution

Make sure the first part has the model equalling 'virtio-scsi'. Doing so will allow the vm to recognize the optical drives and install drivers.

 

...
    <controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </controller>
    <controller type='scsi' index='1' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
    </controller>
...
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host2'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <readonly/>
      <address type='drive' controller='1' bus='0' target='0' unit='0'/>
    </hostdev>
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host6'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
...

 

Edited by Greatestguru

  • 2 years later...
  • Author

Passing Multiple Physical Optical Drives to a Windows VM Using SCSI (libvirt / KVM)

This guide explains:

  • How the original XML configuration worked with 2 optical drives

  • How it was extended to support 4 physical optical drives

  • Why each part of the configuration matters

The setup uses SCSI passthrough and virtio-scsi controllers.


1. Adding SCSI Controllers to the VM

First, the VM needs SCSI controllers to attach devices to.
In this configuration, two virtio-scsi controllers are used:

<controller type='scsi' index='0' model='virtio-scsi'>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
</controller>
<controller type='scsi' index='1' model='virtio-scsi'>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
</controller>

What this does:

  • Creates two independent SCSI controllers inside the guest

  • Uses virtio-scsi for good performance and flexibility

  • Pins each controller to a fixed PCI slot so device ordering remains stable

At this point, Windows sees two empty SCSI controllers.


2. How a Physical Optical Drive Is Passed Through

Each physical drive is passed using a <hostdev> block with type='scsi'.

Example of a single optical drive:

<hostdev mode='subsystem' type='scsi' managed='no'>
  <source>
    <adapter name='scsi_host6'/>
    <address bus='0' target='0' unit='0'/>
  </source>
  <readonly/>
  <address type='drive' controller='0' bus='0' target='0' unit='0'/>
</hostdev>

This block has two important parts.


2.1 Host-side device selection

<source>
  <adapter name='scsi_host6'/>
  <address bus='0' target='0' unit='0'/>
</source>

Meaning:

  • scsi_host6 identifies the SCSI controller on the Linux host

  • bus / target / unit identifies the exact physical device attached to it

This tells libvirt which real optical drive to use.


2.2 Guest-side placement

<address type='drive' controller='0' bus='0' target='0' unit='0'/>

Meaning:

  • Attaches the drive to SCSI controller 0 inside the VM

  • Assigns a unique SCSI address in the guest

Every drive inside the VM must have a unique
(controller, bus, target, unit) combination.


2.3 Read-only flag

<readonly/>

This marks the device as read-only in the guest, which matches optical drive behavior and prevents accidental writes.


3. Why the Original Setup Worked for 2 Drives

  • Two virtio-scsi controllers existed

  • Each optical drive:

    • Used a different host SCSI adapter

    • Was attached to a different guest controller

  • No guest SCSI address conflicts existed


4. Identifying Additional Optical Drives on the Host

To add more drives, first list them on the Linux host:

lsscsi

Example output:

[12:0:1:0]  cd/dvd  /dev/sr0
[12:0:4:0]  cd/dvd  /dev/sr1
[12:0:5:0]  cd/dvd  /dev/sr2
[12:0:6:0]  cd/dvd  /dev/sr3

Format:

[host : channel : target : lun]

From this output:

  • Host adapter = 12scsi_host12

  • Channel = 0

  • Targets = 1, 4, 5, 6

  • LUN = 0


5. Scaling from 2 Drives to 4 Drives

Instead of adding more controllers, we reused the existing two and placed two drives on each controller.

Guest-side layout:

  • Controller 0:

    • unit 0

    • unit 1

  • Controller 1:

    • unit 0

    • unit 1

This avoids address collisions and keeps the configuration clean.


6. Final Working Configuration (4 Drives)

<controller type='scsi' index='0' model='virtio-scsi'>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
</controller>
<controller type='scsi' index='1' model='virtio-scsi'>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
</controller>

<hostdev mode='subsystem' type='scsi' managed='no'>
  <source>
    <adapter name='scsi_host12'/>
    <address bus='0' target='1' unit='0'/>
  </source>
  <readonly/>
  <address type='drive' controller='0' bus='0' target='0' unit='0'/>
</hostdev>

<hostdev mode='subsystem' type='scsi' managed='no'>
  <source>
    <adapter name='scsi_host12'/>
    <address bus='0' target='4' unit='0'/>
  </source>
  <readonly/>
  <address type='drive' controller='0' bus='0' target='0' unit='1'/>
</hostdev>

<hostdev mode='subsystem' type='scsi' managed='no'>
  <source>
    <adapter name='scsi_host12'/>
    <address bus='0' target='5' unit='0'/>
  </source>
  <readonly/>
  <address type='drive' controller='1' bus='0' target='0' unit='0'/>
</hostdev>

<hostdev mode='subsystem' type='scsi' managed='no'>
  <source>
    <adapter name='scsi_host12'/>
    <address bus='0' target='6' unit='0'/>
  </source>
  <readonly/>
  <address type='drive' controller='1' bus='0' target='0' unit='1'/>
</hostdev>

7. Key Takeaways

  • Each physical drive requires its own <hostdev> block

  • Host SCSI addresses must match lsscsi output exactly

  • Guest SCSI addresses must be unique

  • Reusing controllers with different unit values scales cleanly

  • This approach works reliably for multiple optical drives in Windows VMs

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.