Sunday Windows gardening - Windows Server Technical blog

Growing tomatoes with Windows Server...
Windows Server 2016 Discrete Device Assignment
Ariel Delgado. Posted 10/17/2016. Last Updated 10/17/2016.

For this demo, I will assign a Dell 12Gbps SAS HBA controller card installed on a physical Dell PowerEdge server to a virtual machine running on that same server.

There are two properties of the device you want to assign to a virtual machine that you need to find first:

1) InstanceId

2) Location Path

Both can be obtained using the GUI (Device Manager) or using PowerShell.

To obtain the InstanceId:

Since we want to assign a SAS adapter, We will start by querying the server for its installed storage controllers. You can check that in Device Manager or by running the PowerShell command below. In either case, make sure to document the "InstanceId" (in PowerShell) or the "Device Instance path" (in Device Manager). It’s the same thing

To obtain the device "Location Path" You can use the Get-PnpDeviceProperty cmdlet or by using Device Manager.

If using Device Manager look for the "Location Path"" property of the device that you will assign to the virtual machine:

If using PowerShell, use as parameter the InstanceId value obtained earlier or the "Device Instance Path" property obtained in Device Manager (it's the same)

In our example, the physical server has a Dell 12Gbps SAS HBA controller card in one of its PCIe slots and this card is connected to a Dell PowerVault MD1400 external JBOD. Therefore, using the Get-StorageEnclosure cmdlet, we obtain:

We can also get details about the drives present in this JBOD device via the 12Gbps SAS HBA:

The idea is to assign the SAS HBA card to a virtual machine and therefore, present its attached JBOD and disks to this virtual machine.

There are three steps to complete after you have obtained the InstanceId and the Location Path of the physical server's device you want to assign to the virtual machine:

Step 1 - Disable the device on the physical server:

Use either Device Manager or PowerShell as illustrated below to disable the device on the physical server:

If you use PowerShell, you will need the InstanceId value you obtained earlier as a parameter.

If you use Device Manager, just make sure you disable the correct device.

Step 2 - Dismount the device from the physical server:

Run the below command and make sure to replace the value in the "LocationPath" parameter with the value you obtain from the device you want to assign as described above and also make sure to include the -force parameter.

When the command completes, in Device Manager of the physical host you should not have listed the device you plan to assign to the virtual machine.

If you don't use the -force parameter, the below disclaimer is presented:

Step 3 - Mount the device to the virtual machine

You should now be able to mount the device to a virtual machine by using the following cmdlet:

But the following message is presented:

Note: From the message, it appears that as a requirement, the virtual machine to which you are mounting the hardware device must be configured to shutdown or turn off on host shutdown (as opposed to go to saved state on host shutdown which is the default). Since making this change will require We to shutdown the VM, I would also say that, technically, before assigning a device via Discrete Device Assignment, the virtual machine must be off. Let's make the change:

Let's try to mount the device again to the Virtual Machine:

No news is good news so let's examine the virtual machine's device manager now.

Below are two images detailing the assignment of PCIe SAS card before and after the commands we just ran. The "Before" picture shows the device assigned to the physical host whereas the "After" picture shows it now assigned to the virtual machine named VM1

The devices attached to the SAS HBA are now visible to the virtual machine:

If we were to create a cluster with this Virtual Machine as a member, we could use the JBOD disks presented to the VM via Discrete Device Assigned SAS HBA device for clustering purposes (Storage Spaces Direct for instance)

You are done!

To revert the assignment of the SAS HBA to the physical host, use the PowerShell sequence below (I was able to do this with the VM powered ON but I don't recommend it on a production VM. It just does not feel right):

Now, Enable the device in Device Manager of the physical host and you should be good to go.