VMware Cloud Community
Mike_Yazbeck
Enthusiast
Enthusiast

Convert pRDM and vRDM to VMDK via Storage vMotion at PowerCLI Level

Hi Guys,

Really need some assistance - every time I try to vMotion a VM whilst its off, I am unable to convert pRDM via PowerCLI as I keep getting this error:

Incompatible device backing specified for device '0'

I can Storage vMotion it across if its a vRDM but only when the VM is powered on, otherwise if its off it fails for the same reason. Im very confused by all this and I know my script works because I have vMotioned many vDisk only VMs and it works a treat (albeit whether they are on or off).

I have written various methods of trying to vMotion as in our infrastructure we have separate datastores for swap volumes and separate ones for standard data volumes.

I have also used various SDK methods to try and vMotion the disks across to, such as RelocateVM_Task, which does work - but does not convert the RDM to a VMDK (vDisk).

The other problem I have is that if I want to vMotion a VM across from one datastore to another, I have to move the configs first before I move the disks otherwise the whole thing messes up. The idea was to write a for loop that checks each disk, move the disk to another datastore, then once its all moved, move the configs. However, when the script completes it looks like the configs have moved but the disks end up back where they were as if the disks never moved.

I know they definitely moved because when I refresh the datastore to see the VMDKs (as part of a different VM with no RDM's) then the files appear.

I am using VMWare version: 5.1.0

Any assistance is much appreciated :smileygrin:

Thanks All! :smileygrin:

0 Kudos
20 Replies
LucD
Leadership
Leadership

Can you give some more info on these RDM.? Perhaps do the following to start with

Get-VM -Name MyVM | Get-Harddisk | Select *

It would also be interesting to see the VirtualMachineRelocateSpecDiskLocator config that you used with the RelocateVM_Task.

And are there any more meaningful messages in the vpdx log when the svMotion fails ?


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

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

Hi LucD :smileygrin:

Thanks for responding so soon Smiley Happy

My function looks like this:

function RDM-SvMotion

{

    $VM_HDD_List = $VM.HardDisks

    foreach ($VM_HDD in $VM_HDD_List)

    {

        if ($VM_HDD.Filename -match "swap")

        {

            Move-HardDisk -HardDisk $VM_HDD -Datastore $CSV_Array[$i].diskSwap -StorageFormat $CSV_Array[$i].diskFormatType -Confirm:$false -ErrorAction Stop

        }

        elseif ($VM_HDD.DiskType -eq "RawPhysical")

        {

            Move-HardDisk -HardDisk $VM_HDD -Datastore $CSV_Array[$i].diskStdDataStore -StorageFormat $CSV_Array[$i].diskFormatType -Confirm:$false -ErrorAction Stop

        }

        elseif ($VM_HDD.DiskType -eq "RawVirtual")

        {

            Move-HardDisk -HardDisk $VM_HDD -Datastore $CSV_Array[$i].diskStdDataStore -StorageFormat $CSV_Array[$i].diskFormatType -Confirm:$false -ErrorAction Stop

        }       

        elseif ($VM_HDD.DiskType -eq "Flat")

        {

            Move-HardDisk -HardDisk $VM_HDD -Datastore $CSV_Array[$i].diskSwap -StorageFormat $CSV_Array[$i].diskFormatType -Confirm:$false -ErrorAction Stop

        }

    }

}

From a VirtualMachineRelocateSpecDiskLocator perspective, I used this resource: Storage vmotion to different datastores for different vm hard disks | VMware and Powershell

Cheers Smiley Happy

0 Kudos
LucD
Leadership
Leadership

The StorageFormat parameter in Move-Harddisk only accepts Thin, Thick or EagerZeroed.

So am I not sure how this would convert your disk from RDM to VMDK.

Or what do you have in the array $CSV_Array ?

That script you point to is used to move different VMDK from a VM to different datastores.

That will not convert from RDM to VMDK either.

Or do you mean the header of the RDM, which is in fact a VMDK file ?

Still confused, showing your input array, and explaining what exactly you are trying to achieve would perhaps clarify some more.


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

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

Hi LucD Smiley Happy

My CSV Array looks like this:

    

vmNamediskStdDataStorediskSwapdiskFormatType
vm_testemail.ds1.64swap.ds1.70EagerZeroedThick

What I dont understand is, that from the API (advanced view specifically) - when you do select to move the disk to a specific datastore - it does a conversion from RDM to VMDK on the fly (of course whist the VM is off).

What im trying to achieve is to ultimately replicate the API at PowerCLI level.

Im working on a project to migrate all RDMs and migrate them to datastores so we can delete the LUNs on the SAN that connect directly to the VM. What we are trying to achieve ultimately is to have disks stored in datastores only. The only time a LUN should be created on the SAN is when it is be created for a brand new datastore.

I hope that helps Smiley Happy

Thanks again for your reply Smiley Happy

0 Kudos
LucD
Leadership
Leadership

Which PowerCLI version are you using ?

Do a Get-PowerCLIVersion


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

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

VMware vSphere PowerCLI 5.1 Release 2 build 1012425

0 Kudos
LucD
Leadership
Leadership

That's a rather old version.

Can't you upgrade ?

PowerCLI 6R3 supports vSphere 5.1, see the VMware Product Interoperability Matrixes


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

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

We are looking to upgrade to VMWare 6.0, but thats a few months off.

For the moment as part of our Veeam project, this needs to be done first.

I must add though, that even without the PowerCLI script I wrote, the GUI does the same thing - but not always. Im not sure if my script has exacerbated the issue since it only started when I ran my script, however that is probably a coincidence.

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

Where can I get the latest version of PowerCLI?

Is my script failing purely because of PowerCLI as I sometimes get the Incompatible device backing specified for device '0'​ from the GUI as well?

0 Kudos
LucD
Leadership
Leadership

When you select the Overview tab in this PowerCLI Community, you'll see a Download link.

That message can have many causes, I just want to eliminate the possibility that it might be a PowerCLI bug, that was fixed in the mean time.


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

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

Thanks again for your reply Smiley Happy

I have installed the latest version and now it says my version is:

VMware vSphere PowerCLI 6.0 Release 3 build 3205540

I will test my script shortly and give you an update Smiley Happy

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

It still fails unfortunately... however, PowerGUI now shows the accurate details in the progress bar when I tell it to move disks, etc...

Before it would load the progress bar, but it would never move, now it at least reports correctly.

However, I still keep getting the Incompatible device backing specified for device '0'Smiley Sad

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

One thing I have noticed, using the URL I referenced very early on: https://psvmware.wordpress.com/2012/09/04/storage-vmotion-to-different-datastores-for-different-vm-h...

There does not seem to be a way to specify the disk format. How would I go about doing that instead?

0 Kudos
LucD
Leadership
Leadership

What do you mean with "disk format" ?

Is that Thin, Thick... or RDM physical, RDM virtual...


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

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

Apologies I meant the actual disk format in regards to thick, thin, etc...

I dont think its my script that is coded incorrectly, but it appears to cause the incompatible backing device error as I managed to vMotion fine from the GUI.

That is why I tried using the SDK approach by using the VirtualMachineRelocateSpecDiskLocator method instead. However, although I can see the properties I can edit - I dont know which one belongs to the "disk thick" property so I can try that approach instead.

What I dont get is why vMotioning the config and then vMotioning the disks afterwards causes a problem at all Smiley Sad

Do you need to see any more of my script to see what might be going wrong?

0 Kudos
LucD
Leadership
Leadership

You can convert to Thin if you want, you have to use the Backing object to specify that.

The following sample script moves the 2 harddisks, located on datastore DS1 and both Thick, from a VM, to two separate datastores, named DS2 and DS3.

After the VMDK are moved they will be Thin.

.

$vmName = 'TestVM'

$ds1Name = 'DS2'

$ds2Name = 'DS3'

$vm = Get-VM -Name $vmName

$hd = Get-HardDisk -VM $vm

$ds = Get-Datastore -Name $ds1Name,$ds2Name

$spec = New-Object VMware.Vim.VirtualMachineRelocateSpec

0..1 | %{

    $vmdkDsName = $hd[$_].ExtensionData.Backing.FileName.Split(']')[0].TrimStart('[')

    $disk = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator

    $disk.Datastore = $ds[$_].ExtensionData.MoRef

    $disk.DiskId = $hd[$_].ExtensionData.Key

    $disk.DiskMoveType = 'moveAllDiskBackingsAndAllowSharing'

    $disk.diskBackingInfo = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

    $disk.diskBackingInfo.diskMode = 'persistent'

    $disk.diskBackingInfo.thinProvisioned = $true

    $disk.DiskBackingInfo.FileName = $hd[$_].ExtensionData.Backing.FileName.Replace($vmdkDsName,$ds[$_].Name)

    $spec.disk += $disk

}

$vm.ExtensionData.RelocateVM($spec,[VMware.Vim.VirtualMachineMovePriority]::defaultPriority)


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

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

My test server has 4 hard disks:

2 virtual disks

1 pRDM

1 vRDM

This script moved both virtual disks and didnt touch the RDMs at all Smiley Sad

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

So I removed the 2 virtual disks so that I only have RDM's only.

It actually hangs... normally it does that for 10 minutes and gives me the incompatible device bla bla bla, but this time it just sat there for 20 minutes until I manually cancelled it.

Any thoughts? Smiley Sad

0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

Is there any way to try and migrate the RDM's via Eager Thick?

I looked at: https://www.vmware.com/support/developer/converter-sdk/conv51_apireference/vim.vm.device.VirtualDisk...

and cant seem to find a parameter that can set it :smileyconfused:

0 Kudos