Pass through a host DVD Drive


Recommended Posts

I maybe missing something so simple, but I can't figure this out.


I have a Win10 VM running as my daily driver.  There is a DVD Writer that's part of my Unraid system that just sits there.  It's connected to the MB via SATA cable and shows up as:

SCSI Device

[4:0:0:0]cd/dvd HL-DT-ST BD-RE BH08LS20 2.00 /dev/sr0

 

How do I not have it available to the host and just pass it through so it appears as a native DVD drive under my Win10 VM? 

 

Appreciate any help you can provide, thanks!

 

- Cha

Link to comment

I would also be highly interested in a more elegant odd sata passthrough solution.

@jonp

@lime13tech

Guys, anything better than the below for this?

 

what i know works.

Pass through a controller that has been flashed specifically for ODD (issue: manual flash is a pita, eats up an entire expansion slot on the mobo)

  • PCI Syba SD-SATA-4P Flashed to b5500 bios (IDE) Sata 4 port for ODD Chipset Sil3114 
  • PCIe 1 StarTech Sata 2 port for ODD Chipset ASM1062

 

Pass through as a USB device.  (issues: doesn't always work, trying to pass through 2 optical drives this way and the vm doesn't want to start, and read is slow).

Generic USB 2.0 to 7+6 13Pin Slimline SATA Laptop CD/DVD Rom Optical Drive Adapter Cable.

fyi, while the pictures of these tend to show 1 usb port, most take 2 (and extra dongle for power). 

https://www.amazon.com/gp/product/B00C574Q5G

 

  • Upvote 1
Link to comment

Tonight I tested blacklisting a pcie card which works just fine.

Note that you must select a card that works with ODD/DVD/BD/etc... or flash a card to use IDE mode.

 

The following works out of the box

StarTech.com 2 Port PCI Express SATA 6 Gbps eSATA Controller Card

https://www.amazon.com/gp/product/B00952N2DQ

Because of the chipset it uses: Asmedia ASM1062

 

Under  flash I added vfio-pci.ids=(my [id] info from system devices)

I also had to add iommu=pt 

Quote

label unRAID OS
  menu default
  kernel /bzimage
  append iommu=pt vfio-pci.ids=1b21:0612 initrd=/bzroot

 

Under system devices

 
Quote

 


IOMMU group 32
	[1a03:1150] 07:00.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge (rev 03)
	[1a03:2000] 08:00.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED Graphics Family (rev 30)
IOMMU group 33
	[1b21:1182] 09:00.0 PCI bridge: ASMedia Technology Inc. Device 1182
IOMMU group 34
	[1b21:1182] 0a:03.0 PCI bridge: ASMedia Technology Inc. Device 1182
	[1b21:0612] 0b:00.0 SATA controller: ASMedia Technology Inc. ASM1062 Serial ATA Controller (rev 02)
IOMMU group 35
	[1b21:1182] 0a:07.0 PCI bridge: ASMedia Technology Inc. Device 1182


 

 

 

Link to comment

Okay, so that's a solution if you're connected to a standalone PCI card, which is great that works, I could use that in another build.  But for space limited servers like my main rig, I can't add another PCI card.  In the the drive is connected direct to the Motherboard, there isn't away to blacklist that and pass that through? 

 

I need to figure out a vfio-pci.ids command for a SATA devices, like vfio-sata.ids = 0:0:0:2 or something.

Link to comment
  • 9 months later...

Has the question of passing through a DVD (or Blu-ray) connected via SATA to the motherboard been resolved?

 

I am looking to do audio CD ripping, disc backups, and movie rips. I am aware of the makemkv docker which works well but I have not found any docker solutions for CD audio ripping that work.

 

To be clear, I have a 6.6.0 Unraid computer, I am running a Ubuntu VM, and am looking for a way to access the blu-ray drive from within the Ubuntu VM.

Link to comment

So after a variety of attempts from a number of forum posts, the following approach

link1       

link2

worked for me:

>>  lsscsi

[2:0:0:0] cd/dvd HL-DT-ST BD-RE WH14NS40 1.03 /dev/sr0

And then hand modifying the ubuntu XML VM with 

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

 

Other posts had suggested changing the controller value to "1" which did not work for me. 

 

I now have access to the Blu-ray drive from within the Ubuntu VM (it automatically detects a Audio disk insert and mounts it).

I am now able to rip audio CDs which was my original objective.

 

  • Like 2
  • Thanks 1
  • Upvote 1
Link to comment
14 hours ago, SwimmingDiplodocus said:

So after a variety of attempts from a number of forum posts, the following approach

link1       

link2

worked for me:


>>  lsscsi

[2:0:0:0] cd/dvd HL-DT-ST BD-RE WH14NS40 1.03 /dev/sr0

And then hand modifying the ubuntu XML VM with 


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

 

Other posts had suggested changing the controller value to "1" which did not work for me. 

 

I now have access to the Blu-ray drive from within the Ubuntu VM (it automatically detects a Audio disk insert and mounts it).

I am now able to rip audio CDs which was my original objective.

 

 

How is the speed? 

When I tried years ago it was extremely slow. 

Link to comment

It is a Bluray drive.

 

I've only checked with CDs so I'm not sure about DVD or Bluray speeds.

 

With a data CD inside the Ubuntu VM:

pv whatever.tmp > ~/whatever.tmp
65.9MiB 0:00:12 [5.07MiB/s] [========================================================>] 100%

and directly at the unraid terminal:

pv whatever.tmp > /mnt/user/whatever.tmp
65.9MiB 0:00:13 [4.81MiB/s] [=====================================================================>] 100%

 

These appear within error to me and as expected for a CD (>24x speed, so full speed spinning). So I do not see a slowdown for CDs

Link to comment
51 minutes ago, SwimmingDiplodocus said:

It is a Bluray drive.

 

I've only checked with CDs so I'm not sure about DVD or Bluray speeds.

 

With a data CD inside the Ubuntu VM:


pv whatever.tmp > ~/whatever.tmp
65.9MiB 0:00:12 [5.07MiB/s] [========================================================>] 100%

and directly at the unraid terminal:


pv whatever.tmp > /mnt/user/whatever.tmp
65.9MiB 0:00:13 [4.81MiB/s] [=====================================================================>] 100%

 

These appear within error to me and as expected for a CD (>24x speed, so full speed spinning). So I do not see a slowdown for CDs

 

Sounds like they fixed the speed in later releases of libvirt then 😀

Link to comment
  • 11 months later...
On 10/7/2018 at 2:13 AM, SwimmingDiplodocus said:

So after a variety of attempts from a number of forum posts, the following approach

link1       

link2

worked for me:


>>  lsscsi

[2:0:0:0] cd/dvd HL-DT-ST BD-RE WH14NS40 1.03 /dev/sr0

And then hand modifying the ubuntu XML VM with 


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

 

Other posts had suggested changing the controller value to "1" which did not work for me. 

 

I now have access to the Blu-ray drive from within the Ubuntu VM (it automatically detects a Audio disk insert and mounts it).

I am now able to rip audio CDs which was my original objective.

 

 

Hi! I also tried this method to passthrough my optical drive but it actually breaks the VM - It hangs in an endless boot screen. 

I actually don't know if this is related to changes in unRAID or has to do with incompatibilities on X570 mainboards... 

Any ideas?

The simplest way would be to passthrough the entire SATA controller. But on my system the SATA controllers have indeed different IOMMU groups but all the same ID. So without knowing on which physical port the optical drive is plugged in, its hard to find out which controller I can passthrough...

Link to comment
  • 3 months later...

Running unraid 6.7.2 on AMD  https://pcpartpicker.com/builds/edit/?userbuild=qx7WGX

 

 

Using the lsscsi command I was able to identify the drive in the unraid console - it's an LG DVD writer connected via SATA to my MB

...

[3:0:0:0]    cd/dvd  HL-DT-ST DVDRRW GSA-H30L  S856  /dev/sr0

...

I'm able to pass through the DVD writer using

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

After starting the Win7 VM and installing the SCSI virtio SCSI device driver the drive is recognized and device manager says the device is working properly, but doesn't read any media inserted, only telling me to "Insert a disc into drive D:"  This is the case with Audio, Data and DVDs. 

If added to my Win10 VM there is no compatible virtio SCSI driver for Win10 and without it the drive cannot be recognized or used.

Any thoughts?

Edited by navigat0
Added OS and pcpartpicker link
Link to comment

I've been trying to do this on Unraid 6.8.1 this week... I finally got it to work and thought I'd share my results. I'm able to pass through a SATA BluRay drive to Ubuntu and Windows 10 VMs, and I can read CD/DVD/BluRay. I haven't tested burning yet.

 

First I had to connect the drive directly to a SATA port on my motherboard rather than through my SAS HBA. It might be possible to pass it through the HBA but it wasn't working, and seemed like that might be adding an additional hurdle.

 

Here is the drive's SCSI address from Tools/System Devices:

SCSI Devices
...
[6:0:0:0]	cd/dvd  HL-DT-ST BD-RE  WH14NS40  1.03  /dev/sr0        -

 

This addition to the Windows 10 VM XML works for me:

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

 

And this VM XML addition works for me on Ubuntu 18.04.03 VM:

    <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='2' bus='0' target='0' unit='0'/>
    </hostdev>

 

Note that controller='2' here for the Ubuntu VM.... other users suggested using 0 or 1, which for me gave UEFI errors on VM boot. Controller 2 seems to work for me. (Not sure why there's a difference between the Windows 10 and Ubuntu VMs on this.)

  • Like 1
Link to comment

A little more info on my setup.

The DVD drive is currently attached to the on-board SATA bus and not a separate controller.  The onboard SATA is also being used for all of my unraid drives.  That' being said, the DVD drive is visible in the VM and device manager reports that the drive, the virtio SCSI, and virtio SCSI passthrough devices are all working properly.  Looking at the address, children, and parent attributes of these controllers and my drive it looks like the VM sees the drive attached to the virtio SCSI passthrough controller as expected.

 

I've tried changing the device controller ID to another number but that results in the VM not seeing the drive at all, and the creation of additional LSI SCSI controllers that just show up to windows as unidentified SCSI controllers for which no drivers are available.

 

I've also tried adding an alias field (hostdev0) and the rawio set to yes, but in these cases the drive behaves exactly the same - windows sees it, but never recognizes any disc as valid and asks for me to insert a disk.  Being there are no issues the Windows event log is clean.

 

Here's the relevant lines from the VM log (no errors) and it appears the drive/ device is mapping properly, but the media data is not usable.

-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x9 \  
(Windows sees this as the virtio SCSI pas-through controller based on the address and based on the children attribute the DVD drive is listed as a drive under this controller)

-device lsi,id=scsi1,bus=pci.0,addr=0xa \
-device lsi,id=scsi2,bus=pci.0,addr=0xb \
-device lsi,id=scsi3,bus=pci.0,addr=0xc \
(These were created when changing the controller #. They have been removed from the config and no longer show in my current log)

-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk3,id=virtio-disk3,write-cache=on \  
(This is the virtio SCSI controller to which the small 2nd vdisk is attached)

-drive file=/dev/sg3,if=none,format=raw,id=drive-hostdev0 \
-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-hostdev0,id=hostdev0 \
(The device in question currently configured as the following)
    <hostdev mode='subsystem' type='scsi' managed='no' rawio='yes'>
      <source>
        <adapter name='scsi_host3'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

 I don't have any other SATA optical drives nor do I have a SATA PCIe controller to test with.

Link to comment

I spent a LOT of time a few years back sussing out a solution as a Windows VM without access to an ODD was then a deal breaker for my use.

 

I found 2 workable solutions

1 – use a USB ODD drive and pass that through AFTER booting the VM if speed is of little concern

2 – Blacklist a PCIe card and pass the PCIe SATA card through.

 

Note that you must either flash the PCIe card for ODD (aka IDE mode) use or select a card that works natively with ODD.

 

Because of using the Asmedia ASM1062 chipset - StarTech’s 2 Port PCI Express SATA 6 Gbps eSATA Controller Card - Works out of the box. https://www.amazon.com/gp/product/B00952N2DQ

 

Under flash you can blacklist the device via:

label unRAID OS

menu default

kernel /bzimage

append iommu=pt vfio-pci.ids=1b21:0612 initrd=/bzroot

 

Where vfio-pci.ids=(my [id] info from system devices)

IOMMU group 34

[1b21:1182] 0a:03.0 PCI bridge: ASMedia Technology Inc. Device 1182 [1b21:0612] 0b:00.0 SATA controller: ASMedia Technology Inc. ASM1062 Serial ATA Controller (rev 02)

 

Link to comment

Still no luck and sorry for the long-ish post

 

I tried the approach testdasi posted above, by modifying the controller to be a virtio-scsi passthru controller (even re-addressing it to match my optical drive's lsscsi address and swapping it with my network interface).  Windows does indeed install the drivers for the passthru controller and assigns the optical drive appropriately and as usual all devices are working properly in windows but sadly media is still not recognized.

 

Additionally I decided to test another (slightly older) optical drive connected via a SATA/IDE -> USB conversion kit.  Immediately the Windows VM sees the drive and it can actually read/write optical discs of course it's severely limited by the USB 2.0 bus.  I'll verify the SATA drive when I get a moment to pull it from the tower.

 

At this point I can only assume either the drive itself is bad, the onboard SATA controller doesn't like the device or something in the middle-layer of unRAID is causing an issue as the drive is properly recognized but the data layer is where things fall apart.

 

On another sad, but related, side-note (and likely for one of the same unknown reasons listed above) my MakeMKV and Ripper dockers can both see the drive, but never identify any media in the drive.  If I go the USB route with the IDE drive for the dockers, Ripper will identify media is present, but it's always a data disc (regardless of the actual media (DVD, CDFS, or data) and it never actually creates a proper image and locks the device up.

 

I've set up a lot of complicated things in unRAID as a relative noob to the platform including migrating a Win10 ESXi VM with hardware GPU passthru, setting up a reverse-proxy, deploying OpenVPN-AS with client-cert auth, and yet, optical media management seems to be taking (or wasting) the most time.  I'm hoping that continued challenges with optical media and unRAID prompt the development of direct access support (Unassigned devices maybe?) or fully supported passthrough.

 

In the meantime if anyone has an extra PCIe SATA controller just layin around they'd like to donate DM me ;-)

 

I hope all of my efforts can help someone else succeed or save them the trouble.

Link to comment
16 hours ago, navigat0 said:

On another sad, but related, side-note (and likely for one of the same unknown reasons listed above) my MakeMKV and Ripper dockers can both see the drive, but never identify any media in the drive.  If I go the USB route with the IDE drive for the dockers, Ripper will identify media is present, but it's always a data disc (regardless of the actual media (DVD, CDFS, or data) and it never actually creates a proper image and locks the device up.

 

I've set up a lot of complicated things in unRAID as a relative noob to the platform including migrating a Win10 ESXi VM with hardware GPU passthru, setting up a reverse-proxy, deploying OpenVPN-AS with client-cert auth, and yet, optical media management seems to be taking (or wasting) the most time.  I'm hoping that continued challenges with optical media and unRAID prompt the development of direct access support (Unassigned devices maybe?) or fully supported passthrough.

If your drive doesn't work with MakeMKV / Ripper docker (assuming settings were done correctly) then it's a more fundamental problem than whether it can be passed through or not.

No amount of support will help if Linux (kernel) doesn't like the drive (or combination of drive + controller). It's unlikely to be Unraid specific (e.g. given the fact that my optical drive works seamlessly with MakeMKV / Ripper with zero effort).

 

You might want to try booting into a Linux distro to see if it detects and works with your optical drive to begin with.

Link to comment
  • 1 month later...
On 1/13/2020 at 10:15 PM, ossicle said:

I've been trying to do this on Unraid 6.8.1 this week... I finally got it to work and thought I'd share my results. I'm able to pass through a SATA BluRay drive to Ubuntu and Windows 10 VMs, and I can read CD/DVD/BluRay. I haven't tested burning yet.

I've managed to start the VM (Win10) using your method, but Windows device managers just shows it as a "unknown device" and "SCSI-controller". It will not install the drivers from virtio-win-0.1.160-1.iso.

 

How did you get windows to install the correct drivers???

Link to comment

Harmani, that sounds frustrating.... First thing to check, did you change the XML code to match the SCSI device number? In my system the drive address is [6:0:0:0], so I used <adapter name='scsi_host6'/> in the XML. Your system is likely different.

 

If you can post the system info and XML that would help us troubleshoot your issue.

Link to comment
  • 2 weeks later...
On 1/13/2020 at 6:15 PM, ossicle said:

 

This addition to the Windows 10 VM XML works for me:


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

 

Hi there. I want to do something similar, but instead of passing through a single CD-Rom drive, I want to pass through a single SATA port, which is connected to an external bay, which will be using different hard drives (which is why I don't want to pass it by unique hard drive UUID, which is the alternate method).

 

You see, this server has an external hard drive connector bay that I have been using as a way to dock hard drives of service PCs I use to image the drive with Macrium Reflect. So passing through a hard drive by UUID when a new hard drive is less ideal than just passing a SATA port (which is what you do, but on an optical drive).

 

However, I'm using a Windows 10 vm to test this and I can't seem to pass the hard drive to it. I need some help: Where do you exactly paste this particular piece of text? Anywhere on the configuration XML? Or does it need to live in a specific place (let's say, inside the <device> </device> part of the XML? between the <controller> tags existing in there, anywhere else, so on and so forth?

I only get the "unidentified SCSI controller" and the VirtIO drivers don't work. My computer doesn't have IOMMU support, but I don't know if that matters in this case.

 

Thank you in advance for your help.

Link to comment
25 minutes ago, trurl said:

You can't do passthrough at all then.

Guess i'm SOTL then. My mobo has the support for it, but the processor (an old 2600k) doesn't seem to have VT-d (which is the Intel term for iommu?) It does have virtualization, but not "for directed i/o):

 

https://ark.intel.com/content/www/us/en/ark/products/52214/intel-core-i7-2600k-processor-8m-cache-up-to-3-80-ghz.html

 

oh well, it was a good dream. 

Link to comment
32 minutes ago, Rain_1 said:

Hi there. I want to do something similar, but instead of passing through a single CD-Rom drive, I want to pass through a single SATA port, which is connected to an external bay, which will be using different hard drives (which is why I don't want to pass it by unique hard drive UUID, which is the alternate method).

 

You see, this server has an external hard drive connector bay that I have been using as a way to dock hard drives of service PCs I use to image the drive with Macrium Reflect. So passing through a hard drive by UUID when a new hard drive is less ideal than just passing a SATA port (which is what you do, but on an optical drive).

 

However, I'm using a Windows 10 vm to test this and I can't seem to pass the hard drive to it. I need some help: Where do you exactly paste this particular piece of text? Anywhere on the configuration XML? Or does it need to live in a specific place (let's say, inside the <device> </device> part of the XML? between the <controller> tags existing in there, anywhere else, so on and so forth?

I only get the "unidentified SCSI controller" and the VirtIO drivers don't work. My computer doesn't have IOMMU support, but I don't know if that matters in this case.

 

Thank you in advance for your help.

I would suggest you create your own topic instead of digging up something from 2017.

 

Remember to copy-paste the xml of your VM and the list of scsi devices AS TEXT i.e. no screenshot.

Please use the forum code functionality (the </> button next to the smiley button) so the text is formatted correctly.

 

IOMMU is required only for PCIe pass through as far as I know. This isn't PCIe pass-through so hopefully it would be ok.

 

Link to comment
20 hours ago, Rain_1 said:

Where do you exactly paste this particular piece of text? Anywhere on the configuration XML? Or does it need to live in a specific place (let's say, inside the <device> </device> part of the XML? between the <controller> tags existing in there, anywhere else, so on and so forth?

The <hostdev> block goes towards the end of the XML, inside the <devices> block, between the <video> and <memballoon> blocks. Here are the last lines of my XML:

[...]
   <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <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>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </memballoon>
  </devices>
</domain>

 

Link to comment
  • 2 months later...

I had some success with the following inserted into the <disk> section:

<disk type='block' device='cdrom'>
  <driver name='qemu' type='raw'/>
  <source dev='/dev/sr0'/>
  <target dev='hdg' bus='sata'/>
  <readonly/>
</disk>

Given that lsscsi revealed:
[4:0:0:0]    cd/dvd  TSSTcorp DVDWBD SH-B123L  SB04  /dev/sr0 

  • Like 3
Link to comment

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.