Hard drive passthrough


Recommended Posts

I just setup an SSD to be mounted outside the array, using SNAP.  I moved my windows8 VM to that drive, then started it, then ran the Windows Experience Index on the VM, and it recognized the drive as an SSD, and scored pretty well.  The VM is running very fast.

 

I tested it by playing a bluray to the TV, streaming another one to my phone from the VM, streaming another one to my laptop from the VM, downloaded an album with SABnzbd, and started a parity check.  All videos played without skipping, or any issues at all.  I've not seen it work that well ever before.

 

I wonder if this would do what you need, without having to passthru the hard drive.  This lets you still access it from unRAID, FWIW.

 

 

Link to comment

This is kind of easy.  So my old bootable Windows SSD was attached to my VM by adding the following:

 

<disk type='block' device='disk'>
        <source dev='/dev/disk/by-id/ata-Corsair_CSSD-F120GB2_1109650632000461003B' />
        <target dev='hdc' bus='virtio' />
</disk>

 

I set the /dev/disk/by-id/.... so that upon reboot, if my Corsair SSD ended up a different sdX, it would still work.

 

I was able to boot the vm, and it tried to load windows, but then went into a bsod boot loop.  This was to be expected, so I deleted the partitions on the disk using fdisk.  Now, though, when I boot, it tries to boot from that drive, and then fails. For some reason, it doesn't see my .iso boot image.  If I remove the hard drive from the xml, then the vm boots into the iso install.  I'm not sure why it is not seeing my iso as a bootable device.  Both are /dev/hdx devices in my xml.

 

All my disk devices:

 

   <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/cache/iso/Win81Pro.iso'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/cache/iso/virtio-win-0.1-81.iso'/>
      <target dev='hdd' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='1'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/disk/by-id/ata-Corsair_CSSD-F120GB2_1109650632000461003B'/>
      <target dev='hdc' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk> 

 

Thoughts on how to get it to boot to my Win81.iso while still having my ssd attached?

Link to comment

Success!  I couldn't just change the boot device, I ended up having to have both <boot dev='cdrom'/> and <boot dev='hd'/> along with <bootmenu enable='yes timeout='3000'/>

 

I've just now installed Windows 8.1 in about 2 1/2 minutes.  This is so crazy and awesome! 

 

<domain type='kvm' id='30'>

  <name>Gaming</name>

  <uuid>331e68d5-820c-660a-cb4e-d7470ec818d8</uuid>

  <memory unit='KiB'>2621440</memory>

  <currentMemory unit='KiB'>2621440</currentMemory>

  <vcpu placement='static'>1</vcpu>

  <resource>

    <partition>/machine</partition>

  </resource>

  <os>

    <type arch='x86_64' machine='pc-i440fx-2.1'>hvm</type>

    <boot dev='cdrom'/>

    <boot dev='hd'/>

    <bootmenu enable='yes' timeout='3000'/>

.......

  <devices>

    <emulator>/usr/bin/qemu-system-x86_64</emulator>

    <disk type='file' device='cdrom'>

      <driver name='qemu' type='raw'/>

      <source file='/mnt/cache/iso/virtio-win-0.1-81.iso'/>

      <backingStore/>

      <target dev='hdd' bus='ide'/>

      <readonly/>

      <alias name='ide0-1-1'/>

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

    </disk>

    <disk type='file' device='cdrom'>

      <driver name='qemu' type='raw'/>

      <source file='/mnt/cache/iso/Win81Pro.iso'/>

      <backingStore/>

      <target dev='hde' bus='ide'/>

      <readonly/>

      <alias name='ide0-1-0'/>

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

    </disk>

    <disk type='block' device='disk'>

      <driver name='qemu' type='raw'/>

      <source dev='/dev/disk/by-id/ata-Corsair_CSSD-F120GB2_1109650632000461003B'/>

      <backingStore/>

      <target dev='hdc' bus='virtio'/>

      <alias name='virtio-disk2'/>

      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>

    </disk>

 

.........

 

The <disk> stuff in red is what I added to the xml.  VMmanager added the rest.  So I added:

 

<disk type='block' device='disk'>
      <source dev='/dev/disk/by-id/ata-Corsair_CSSD-F120GB2_1109650632000461003B' />
      <target dev='hdc' bus='virtio' />
</disk>

 

Along with adding the following to the <os> tag:

    <boot dev='cdrom'/>
    <bootmenu enable='yes' timeout='3000'/>'

Link to comment

Once I completed the install, I removed the Win81.iso from my xml, along with the <bootmenu> and <cdrom> entries from the <os> tag, and it booted up fine.

 

I was curious if there was a performance difference if I set the SSD <disk> as a sata device instead of virtio.  Oddly enough, I was able to boot with it set to Sata, but was then not able to go back to Virtio.  I don't know if there will be a performance increase or decrease like this, but I'm going to leave it unless I notice significant issues.

Link to comment

 

 

Upon quick research, having it set as Virtio instead of IDE supposedly significantly decreases CPU usage. Not sure if this is the same for hard drive passthrough or if it is set to SATA, but I figured it was a fresh image and just reinstalled to make sure it was using Virtio.

 

I found that if a cdrom was set to sata and not ide then you can't do snapshots.  Some ich9 error.

Link to comment
  • 2 weeks later...

Jonp.  Thanks for the info!  Do you know if there's a way to set it back to Virtio from Sata?  My HTPC is a raw qcow2 image on Sata bus.

 

I've read that you can install the virtio drivers, shutdown the vm, change the bus, and then boot back up and it'll be fine, but I'd like a second opinion before I started messing with it.

Link to comment

Jonp.  Thanks for the info!  Do you know if there's a way to set it back to Virtio from Sata?  My HTPC is a raw qcow2 image on Sata bus.

 

I've read that you can install the virtio drivers, shutdown the vm, change the bus, and then boot back up and it'll be fine, but I'd like a second opinion before I started messing with it.

Yeah, there is a way to do it like that but I haven't had to do that before, so I'd be guessing if I gave you instructions ;-).

Link to comment
  • 1 year later...

So I have two questions about this topic.

 

1.  Can I passthrough a unassigned SSD for a VM?

2.  Can I make a separate pool of just SSD that is NOT in the cache?  I would ideally have a separate pool for just VM's.  Not sure if that is possible as of now.

 

1. Yes, use the method above. I have just done it for a 1Tb WD Black drive, works like a charm.

2. I am not sure this is possible, i guess if you motherboard has a raid controller you could create the array and you will end up with a single volume.

Link to comment
  • 2 months later...

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.