VMware Cloud Community
rramanadham
Contributor
Contributor

I get the error-"incompatible device backing specified for device '0'" when i try to add a raw lun via powershell

Hi,

Here is my script where i am trying to add a raw lun to a VM via powershell script. I get the error - "incompatible device backing specified for device '0'". I dont see this error when i do it using vsphere client. Any idea why i get this error?

# ------- ReconfigVM_Task -------
Connect-VIServer -Server losas147 -User itops -Password itops

$vmMo = Get-View (Get-VM losaz093).ID
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.changeVersion = $vmMo.Config.ChangeVersion

$spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)
$spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].operation = "add"
$spec.deviceChange[0].fileOperation = "create"
$spec.deviceChange[0].device = New-Object VMware.Vim.VirtualDisk
$spec.deviceChange[0].device.key = -100
$spec.deviceChange[0].device.backing = New-Object VMware.Vim.VirtualDiskRawDiskMappingVer1BackingInfo
$spec.deviceChange[0].device.backing.fileName = ""
$spec.deviceChange[0].device.backing.deviceName = "/vmfs/devices/disks/naa.6006016034c12c0012f008fdb959e111"
$spec.deviceChange[0].device.backing.diskMode = ""
$spec.deviceChange[0].device.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo
$spec.deviceChange[0].device.connectable.startConnected = $true
$spec.deviceChange[0].device.connectable.allowGuestControl = $false
$spec.deviceChange[0].device.connectable.connected = $true
$spec.deviceChange[0].device.controllerKey = 1000
$spec.deviceChange[0].device.unitNumber = 7
$spec.deviceChange[0].device.capacityInKB = 1048576
$VmMo.ReconfigVM_Task($spec)

Reply
0 Kudos
5 Replies
marcelo_soares
Champion
Champion

Don't you get the same error trying the operation using GUI? If yes, try removing/adding this VM to inventory and try the operation again.

Marcelo Soares
Reply
0 Kudos
rramanadham
Contributor
Contributor

No, I only get this when i use powershell script. Via the gui, I have no issues adding the lun.

Reply
0 Kudos
rramanadham
Contributor
Contributor

Any other ideas how to get around this?

Reply
0 Kudos
spulv
Contributor
Contributor

Where you able to figure this out?  I am having the same issue.  I am removing a Physical RDM and trying to remap it as a virtual RDM.  I can do this through the GUI without issue but when I use powercli I get that message.  My script works if I remove as pRDM and remap to a pRDM so I am not sure why it is different with vRDMs.

Reply
0 Kudos
LucD
Leadership
Leadership

Try the New-Harddisk cmdlet with the DiskPath parameter.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos