I couldn't find any info on this anywhere, which may suggest it's not possible, but I'd love to find a way to do it.
I have 2 NetApp disk shelves with 48 disks total, and running TrueNAS in a VM. I'm still in the stage of playing around with it and I've already had to add all the physical disks to the VM a few times and it's painful doing it one at a time!
It would be nice if there was a way to just quickly tick all the disks to add, but I'm guessing that's not possible.
The solution would probably be via scripting. It could be achieved by selecting all disks that have a certain string in their model # as all the disks are the same model in each shelf (one has HGST, the other Seagate), or even matching on NetApp. I'm terrible with powershell and command line scripting though.
UPDATE: with some pointing in the right direction from j_h_o and cesmith9999 I cobbled together a little one-liner:
EDIT: Updated to remove curly braces around the $_.Number and to add the ControllerType flag to SCSI (otherwise it fills IDE first, then SCSI)
To add all offline drives that match "NETAPP" to VM TrueNAS on the SCSI controller:
To remove all the Passthru drives on VM TrueNAS from the SCSI controller:
To those wondering what the "Where-Object DiskNumber -gt -1" is for (where DiskNumber>-1), it's so it only removes the physical disks, not vdhx disks. It's a bit of a hack, but it worked.
NOTE: it can take a while.. you can refresh the settings in Hyper-V manager to confirm it's doing what's it's supposed to.
I have 2 NetApp disk shelves with 48 disks total, and running TrueNAS in a VM. I'm still in the stage of playing around with it and I've already had to add all the physical disks to the VM a few times and it's painful doing it one at a time!
It would be nice if there was a way to just quickly tick all the disks to add, but I'm guessing that's not possible.
The solution would probably be via scripting. It could be achieved by selecting all disks that have a certain string in their model # as all the disks are the same model in each shelf (one has HGST, the other Seagate), or even matching on NetApp. I'm terrible with powershell and command line scripting though.
UPDATE: with some pointing in the right direction from j_h_o and cesmith9999 I cobbled together a little one-liner:
EDIT: Updated to remove curly braces around the $_.Number and to add the ControllerType flag to SCSI (otherwise it fills IDE first, then SCSI)
To add all offline drives that match "NETAPP" to VM TrueNAS on the SCSI controller:
get-disk | where-object FriendlyName -match "NETAPP" | where-object OperationalStatus -eq "Offline" | foreach-object { Add-VMHardDiskDrive -VMName "TrueNAS" -Number $_.Number -Passthru -ControllerType SCSI}
To remove all the Passthru drives on VM TrueNAS from the SCSI controller:
Get-VMHardDiskDrive -VMName "TrueNAS" | Where-Object DiskNumber -gt -1 | foreach-object {Remove-VMHardDiskDrive -VMName $_.VMName -Passthru -ControllerNumber $_.ControllerNumber -ControllerLocation $_.ControllerLocation -ControllerType SCSI}
To those wondering what the "Where-Object DiskNumber -gt -1" is for (where DiskNumber>-1), it's so it only removes the physical disks, not vdhx disks. It's a bit of a hack, but it worked.
NOTE: it can take a while.. you can refresh the settings in Hyper-V manager to confirm it's doing what's it's supposed to.
Last edited: