Change migrated VM, vmdk disk file name / reference data store

Hi all

I'm trying to migrate a large number of virtual machines between physical datacenters (using SAN as the migration of mirroring method).

The problem I encountered is that the operating system and data vmdk is localized on different data for each virtual computer warehouses. When break us the mirror and enter the VMX to the new location, the VMX file is a reference to the old path to the VMDK files (ie: the old data store in the center of source data). Only the VMDK files located in the same folder as the VMX file appear correctly in the vSphere - other client appears with the size of '0 GB' - as vSphere can't find referenced vmdk files.

I don't want to update the VMX files manually, of course that's why I'm here. :-) But I struggled to find a way to update the hard drive using PowerCLI vmdk file name.

I have to resort to pure PowerShell and update the file vmx in this way?

I read all the blogs on the updating of the vmx files - but they have all shown to day extension data "extraconfig". for example:

http://blogs.VMware.com/vipowershell/2008/09/changing-VMX-fi.html

This extraconfig does not include the lines in the VMX file that specify the vmdk file name. for example:

scsi0:1.filename = ' / vmfs/volumes/abcdefgh-503544b2-e46c-d41234567890/myVmName/myVmName_1.vmdk '.

Ideally, I would have liked to use the command set-hard drive - unfortunately this is actually trying to move the non-existent vmdk to the new data store that I specify - rather than just update the baseline data store.

I hope someone here can tell me an effective solution - without having to read in the vmx files and edit them using PowerShell.

Oh, and I wrote a script to print the list of VMDK files attached to each virtual machine (in the datacenter from source before you remove migrated VMs)- so I have my CSV entry ready for use with a viable solution.

Any help much appreciated!

Thank you

FaTony

If you have the list with the VMDK from the source, and you know how to translate those paths to the new location, you should be able to use the Remove-hard drive and the hard drive New cmdlets.

Have you tried that?

Tags: VMware

Similar Questions

  • Copy local disk file to the data store

    No idea why this simple script does not work?

    $Datastre = get-Datastore. where {$_.} Name: like "{* such * datastore01'}"
    Get-Datastore $Datastre | New-DatastoreDrive-name of the ds
    Copy-DatastoreItem-point D:\VMware-VIMSetup-all-5.0.0-456005.iso-Destination ds:\VMware-VIMSetup-all-5.0.0-456005.iso

    DatastoreItem copy: File Upload 'D:\VMware-VIMSetup-all-5.0.0-456005.iso' failed. Error message
    : Failed to write data to the transport connection: an existing connection was to be closed by t
    remote host HE.
    On line: 1 char: 19
    + Copy-DatastoreItem < < < <-point D:\VMware-VIMSetup-all-5.0.0-456005.iso-Destination ds:\VMware-VI
    MSetup-everything - 5.0.0 - 456005.iso
    + CategoryInfo: NotSpecified: (:)) [copy-DatastoreItem], VimException)
    + FullyQualifiedErrorId: Client20_StorageServiceImpl_UploadFile_UploadFailed, VMware.VimAutoma
    tion.ViCore.Cmdlets.Commands.CopyDatastoreItem

    Are you sure the datastore drive is working?

    You can make a

    CD ds:

    dir

    before you actually do the DatastoreItem copy?

  • HOWTO delete a VMDK to a virtual machine without actually deleting the vmdk disk file?

    How to remove a file VMDK to a virtual machine without actually deleting the vmdk disk file?

    Details:

    My perl script, I need to temporarily remove a vmdk to a virtual machine file. However I do not want the vmdk file should be removed from the virtual machine. For example, the gui vsphere provides this option to delete a virtual disk without deleting the virtual disk from the disk files.

    In my script, I use the ReconfigVM_Task to do this. This does the job, but also removes the vmdk file. How can ensure me that the vmdk file will not delete the disk?

    The code snippet is something are:

    My $devspec = VirtualDeviceConfigSpec-> new)

    device = > $device,

    #device to delete above:

    operation = > VirtualDeviceConfigSpecOperation-> new ('remove'));

    Push (@$ devspec_list, $devspec);

    My $config_spec = VirtualMachineConfigSpec-> new)

    deviceChange = > $devspec_list

    );

    my $task = $template_view-> ReconfigVM_Task (spec = > $config_spec);

    would really appreciate your help

    s

    Take a look at this script: vmdkManagement.pl

    =========================================================================

    William Lam

    VMware vExpert 2009

    Scripts for VMware ESX/ESXi and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

    Twitter: @lamw

    repository scripts vGhetto

    Introduction to the vMA (tips/tricks)

    Getting started with vSphere SDK for Perl

    VMware Code Central - Scripts/code samples for developers and administrators

    VMware developer community

    If you find this information useful, please give points to "correct" or "useful".

  • VStorage different Motion - copy of the file on a data store vmdk

    Hi all

    Hoping that someone will be able to help with a problem I have right now.

    Configuration:

    NetApp SAN - vmfs data warehouses.

    Data for the migration store is synchronous to a recovery site.

    I planned a day to the next task to migrate a VMDK virtual machines to a non synchronous Datastore to synchronous data store.  When I arrived yesterday morning - the virtual machine has been turned on - but I couldn't access the console and migration was still sitting 89% full.

    Checked the Netapp Filer and found the copy of the snapshot is greater than the instant space on the volume.

    SnapMirror suspend and break.  Delete the copy of Netapp snapshot on the volume.  Once I had done this on the Netapp file server - virtual machine has begun to respond to ping and I was able to access the console.

    I restarted the VM Windows - to make sure everything was fine - as the date / time on the server was out of sync with the date and time - so again, I am happy that my virtual machine is now in place and running.

    Problem. : I migrated virtual disks - one both of the old data store to the new - no problems - until I'm gone make the last record and felt that there is not enough space on the data store - now it would have taken and further investigation found that the virtual disk I wanted to migrate — was already sitting on the new data store.

    Check the settings on the virtual machine shows that the file in question vmdk is still sitting on the old data store - but - I also have a copy of the vmdk - same size etc. - file sitting on the new data store.

    RVtools displays the disk on the new data as a Zombie VMDK store.

    Question: What vmdk file is the one I need to remove?  I think about the new data store - in addition, shown as a zombie in RVTools vmdk - also, shows only not the settings of the virtual machine.

    All find what vmdk file, the system uses permanently.

    Thank you very much

    Open the .vmx file and check the path to your vmdk here.

    If you can, backupo the VMDK at both ends before going any further.

    as the VC (and I hope that the .vmx), as well as RVtools indicate that the destination is a zombie. . I would lean towards this being the one to delete.

    In theory, if you use the browser to store data to try to remove a new and it's in use, you will get an error message, so if it removes OK, you should be good to continue from where you were before.

    Good luck.

  • Change of name of data store

    Dear all,

    I need to understand if this is possible or not, I have a data store who have a few VM in it, if for some reason any Naming Convention I want to rename the data store, it can be done without disruption of the VM? The confusion here is from VM disk shows that the data store in 'change settings' how this will change if the data store is renamed using vCenter server.

    waiting for response.

    Thank you

    You can rename your store data without problems and with the virtual machines running on it, since vSphere using the UUID data store and not the display name.

  • Find files on the data store that have been removed from inventory, but not deleted from the disk

    I have ESXi 4.1 and with vSphere Client to manage virtual machines.

    Some of my users continue to use the 'remove from inventory"rather than the option" remove disc "in vSphere when they want to delete the virtual machine.

    This leaves the computer virtual on the data store but not used. I have since removed this privilege among the offending users but I need to do a bit of cleaning.

    I have a lot of files on the data store where users have done this in recent years. Probably about 150 records but only 80 VM listed in the inventory.

    Is there a way I can output, a report showing the data of each machine store directory in inventory so that I can remove anything not on this list? ID rather not to manually check the parameters of all 80 VM in the inventory.

    Out ideal would be something like:

    MyVmNameHere 1, \MyVmDirectoryHere1\ [DataStore1]

    MyVmNameHere2, \MyVmDirectoryHere2\ [DataStore1]

    A great tool to discover all this and much more is RVTools

    André

  • "move a file of this data store...". »

    I see a white icon in the properties of the vCenter data and store when I go over it, it reads "move a file of this data store to another location accessible to vCenter.    I wonder if I could use this icon to move a VMDK to a VM in DataStore1 file to another virtual machine to the same data store (IE DataStore1) so that the VMDK is now up to the second VM.  I think about it because I need to migrate a virtual 2003 Windows computer to a Windows 2008 VM and the second vDisk in the Windows 2003 VM is strictly a big data VMDK (about 650 GB) drive.  The data store has a capacity of 1 TB with about 250 remaining GB... so I can not copy the file, BUT if I MOVE it so would not create a vmdk duplicate file and I would not approve the data store.   Anyone know?

    There are two files associated with each virtual disk. The disk.vmdk and the disc - flat hard the disk.vmdk is just a descriptor text for the virtual disk. You can read the disk.vmdk with vi or simply use

    cat disk.vmdk
    

    It will point to the disc - flat hard. The EI vmksftools will rename two files vmdk and change the pointer in the disk.vmdk file.

    MV does not change the pointer inside the disk.vmdk

  • Move the location of the VM swap file in another data store

    Hi all

    Was in a task to move the 1000 to the file location of VM swap on another data store which is newly assigned to Exchange us to the existing store database file that will be decommissioned.

    Eager to check if anyone has made movement swap of VM location of the files to a data store to another and that all measures taken to move.

    Require some VM downtime?

    Thanks in advance a ton.

    Yes it is possible without interruption of service to virtual machines.

    1. make sure that your cluster is configured to use swap data store specified by host

    2. take a host in the cluster in maintenance mode, change the location of the VM configuration file to point to the new data store

    3. do this for all hosts in the cluster

    When you vMotion a VM from one host to another the swap file will get moved to the new data store. Later when you take guests to the maintenance and return output mode, vMotion occurs for each computer in the cluster virtual and file is moved.

  • Get the size of the file for a particular file in a data store

    I was wondering if it was possible to get the size of a particular file on a data store. It seems that this should be trivial, but I'm new to PowerCLI and I see not all the properties of size when I invoke the cmdlet:

    PS fs:------> Get-ChildItem "somefile" * | Get-Member

    TypeName: VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.DatastoreFolderImpl

    Name MemberType definition

    ----              ----------   ----------

    Method of ConvertToVersion T ConvertToVersion [T])

    Equals method Boolean Equals (System.Object, obj)

    GetHashCode method int GetHashCode()

    Type of the method GetType GetType()

    IsConvertableTo method bool IsConvertableTo (type toType)

    String the ToString ToString() method

    PSChildName NoteProperty System.String PSChildName = XXXXXXXXXXXXXXXXX

    PSDrive NoteProperty VMware.VimAutomation.ViCore.Cmdlets.Provider.DatastoreProvider.DatastoreDriveInfo PS...

    PSIsContainer NoteProperty System.Boolean PSIsContainer = True

    PSParentPath NoteProperty System.String PSParentPath=VMware.VimAutomation.Core\VimDatastore::\XXXXXXXXXXXXXX

    PSPath NoteProperty System.String PSPath=VMware.VimAutomation.Core\VimDatastore::\XXXXXXXXXXXX

    PSProvider NoteProperty System.Management.Automation.ProviderInfo PSProvider=VMware.VimAutomation.Core\VimDa...

    Datastore property {get ;} VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.Datastore data store

    DatastoreFullPath property System.String DatastoreFullPath {get ;}

    DatastoreId property System.String DatastoreId {get ;}

    FolderPath property System.String FolderPath {get ;}

    FullName property System.String FullName {get ;}

    Property ItemType ItemType of VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.DatastoreItemType...

    System.Nullable'1 [[System.DateTime LastWriteTime, mscorlib, Version = 4.0.0.0 property, Culture = neutral, publ...

    Property System.String name {get ;}

    UID property System.String Uid {get ;}

    Faik, you must use the SDK API to find this HostDatastoreBrowser of information, i.e.

    .

    See for example Re: using SearchDatastore_Task

  • Migrated virtual machine appears in the two data stores

    Hi all

    A bit of background on our installation first. servers ESX 3.5 vcenter 4.0 (just improved 2.5) + 2 + 2 data warehouses configured in 1 box of MSA.

    Here is what happened. I've migrated a VM from A to B data store using "Migrate" in vSphere client on vCenter.

    On the vSphere client, virtual machine displays now two data warehouses. In the browser data store, the vme even appears in the two data stores. Datastore shows 20 GB to 20 GB provisioned and 0 GB to 20 GB used. B displays 20 of 20 put into service and used 20 20 GB.

    Migration seems to have succeeded. I migrated about 10 other vm and they reside only on a data store. All virtual machines are working properly. I tried to migrate the computer back to A virtual. He showed only a data store. But the problem appeared again when I migrated the vm to B. I tried to move the virtual machine back and forth between servers ESX, no difference.

    Any ideas? The virtual machine is working well, and it is not necessarily a critical problem. But it's annoying, because I intend to reorganize the data store has and the fear it could cause a problem.

    Thank you so much in advance!

    anything mounted on the CD/DVD drive, as an ISO which can be on A Datastore?

  • Unable to shrink the VMDK disk file

    I have a Winxp virtual machine, and it was created with a 40 GB SCSI disk, VMWare has recommended.  I used to transfer all kinds of data to and from it, and I noticed that kept virtual disk file becomes larger.

    The Windows file as well as all my personal files are total about 4.7 GB.  But the VMDK file is not less 21,7 GB...

    After that it shrinks normally did not work, I started the machine virtual in Parted Magic and effectively narrowed the entire NTFS partition up to 5 GB - the other 35 showing as empty space.  But still, I tried shrinking and he defragmentation on 7 times, he didn't budge 21,7 GB.  I even tried to make the option "Get ready to shrink" inside Windows itself, using VMWare Tools, which also did nothing...

    I tried in fact to create a new virtual machine identical with a 5 GB drive, then copy the partition through (I had copied on a flashdrive using CloneZilla) - but for some reason, XP does not start if I do that.  Even to make all stages of repair does not fix.

    So could someone please understand why this file on the disc is so obnoxiously huge for a 4.7 GB VM and how can I reduce the VMDK?  I really need keep the hard drive space and it seems really stupid...

    the other 35 showing as space vacuum

    That's the problem. The process of narrowing in VMware Workstation focuses first on the unused space on the partitions, and then shrink the VMDK file. The free space on the disc does contain not more than one partition, it will not be zero. To resolve this problem, you can temporarily create an additional NTFS partition on unused disk space.

    André

  • How to move a single virtual disk (vmdk file) of one data store

    Hi guys,.

    I have a VM with 4 virtual disks (for example, 1.vmdk, 2.vmdk, 3.vmdk and 4.vmdk) all located on a SAN volume (e.g., SANVOL03). How can I move one of the virtual disks (for example, 3.vmdk) of its current volume of SAN to another (e.g. from SANVOL03 to SANVOL04) without turning off the virtual machine? It's vsphere 4.1

    Detach the VMDK virtual machine and move it manually on the desired data store.

  • Using several data stores, cannot migrate the vmx file in a data store

    I am host migration between 3.5 and 4.0, and part of the migration requires me to vmotion data to a single shared LUN data warehouses.  From there on, I import the virtual machine in 4.0 and using the script to migrate the two VM disks at different stores of data below.  The problem I have is that the configuration (vmx) file not migrated and is left on the shared storage LUNS.  Anyone knows how to go beyond this?

    The Script:

    $VMDisk = 'disk 1 '.

    $VMName = 'TestVM '.

    $TargetDS = get-Datastore - VMHost (Get-VMHost-$S.id Id) | Where-Object {$_.} Name - like "PMV"} | "" FreeSpaceMB tri-objet-descending | SELECT name - first of all 1

    $vm = get-View - ViewType VirtualMachine-filter @{"Name" = $VMName}

    foreach ($dev in $vm. Config.Hardware.Device) {if ($dev. DeviceInfo.Label - eq $vmDisk) {$diskId = $dev. Key}}

    $spec = new-Object VMware.Vim.VirtualMachineRelocateSpec

    $diskspec = new-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator

    $diskspec. Data store = (Get-Datastore-name $TargetDS.Name |) Get - View). MoRef

    $diskspec.diskId = $diskId

    $spec. Disk = @($diskspec)

    $task = get-View ($vm. RelocateVM_Task ($spec, "lowpriority"))

    OK, I think I understand your problem now.

    I fear that in the current construction of PowerCLI, the Move-VM cmdlet does not destinations of individual data for each virtual hard disk store.

    With the RelocateVM_Task method, it is possible.

    The following script moves a guest at 3 different data warehouses:

    -the. VMX file for DS2

    -hard disk 1 for DS3

    -hard drive 2 TB DS4

    $vmName = "MyGuest"
    $vmxDS = "DS2"
    $osDS = "DS3"
    $dataDS = "DS4"
    
    $vm = Get-VM -Name $vmName
    
    $vm.Extensiondata.Config.Hardware.Device | %{
         if ($_.DeviceInfo.Label -eq "Hard disk 1"){
              $osDiskId = $_.Key
         }
         elseif($_.DeviceInfo.Label -eq "Hard disk 2"){
              $dataDiskId = $_.Key
         }
    }
    
    $spec = New-Object VMware.Vim.VirtualMachineRelocateSpec
    
    $osRelocate = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator
    $osRelocate.Datastore = (Get-Datastore -Name $osDS).Extensiondata.MoRef
    $osRelocate.diskId = $osDiskId
    
    $dataRelocate = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator
    $dataRelocate.Datastore = (Get-Datastore -Name $dataDS).Extensiondata.MoRef
    $dataRelocate.diskId = $dataDiskId
    
    $spec.Disk = @($osRelocate,$dataRelocate)
    $spec.Datastore = (Get-Datastore -Name $vmxDS).Extensiondata.MoRef
    $spec.Host = $vm.Extensiondata.Summary.Runtime.Host
    
    $task = Get-View ($vm.Extensiondata.RelocateVM_Task($spec, "lowpriority"))
    while("running","queued" -contains $task.Info.State){
         $task.UpdateViewData("Info")
         sleep 5
    }
    

    BTW, you can use the cmdlet Set - hard disk to a virtual disk that is specific to a data store.

    But as I understood what is not possible in your environment.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Automatic generation of file name with Date stamp

    Please see the attached VI. (LV2012)

    What I want to do is to generate a file name in the format: DayOfYear - month - day - year. txt

    The way I coded it, I was able to generate according to my condition. For example today it generated a file name ' 14-1-14 - 2016.txt ' on my computer.

    But the same code when it is run on the client computer generated this: 14-1 /-4 /-016 .txt and, of course, the VI ceased due to the illegal file name. I gues this is because how each computer formats the date, the time information.

    How to code a generic VI to create the name of the file that I need on any computer?

    Just let the Date/Time Format string to do all the work...

  • Fill the CSV file with the host name and the name of data store

    Hello

    How can include the hostname in my output csv file?

    The following code adds the name of the data store but not the host name:

    import-csv hosts | % {get-vmhost-name $_.name} | Get-Datastore. SELECT name.

    Export-csv ESX - Datastore.csv - notypeinformation - useculture

    How to watch your entry CSV file?

    If it's something like

    Name

    ESX1

    ESX2

    Do it like this

    &{foreach($esx in (Get-VMHost -Name (Import-Csv host.csv -UseCulture | Select -ExpandProperty Name))){    $esx | Get-Datastore |    Select @{N="VMHost";E={$esx.Name}},Name}} | Export-Csv report.csv -NoTypeInformation -UseCulture
    

Maybe you are looking for

  • How to cancel a delet of a password entry?

    Do things too quickly, I unintentionally highlighted all passwords and them deleted before I could see what I was actually doing. How can I undo this action and restore the years of collecitonas password?

  • Laptop HP Pavilion G6 does not illuminate

    I got this laptop a little over a year.  A few nights ago I used it, and it worked very well.  The next morning, he does not and would not charge. Any suggestions?

  • HP Pavilion tx1218au: HP Pavilion tx1218au

    Hello Help in upgrading my graphics driver for HP Pavilion tx1218au I can move to windows 10.  NVIDIA GeForce Go 6150 Thanks in advance

  • Restore Windows XP files saved via Windows Easy Transfer on the same computer

    After downloading and using Easy Transfer to back up files on an external hard drive (which is where they are now) for the purpose of upgrading Windows XP to Windows 7, I have now decided not to continue because the purchase of a new computer with Wi

  • My mouse wheel doesn't work anymore

    A few days ago I installed updates for my computer. One of them included my mouse and keyboard. After having installed the updates and restarted my computer. I reconnected in and everything was fine. Three days and my mouse wheel doesn't work anymore