clone a virtual machine to a vmdk file

I would like to clone a file vmdk from a virtual machine to another for some lab work. I have some experience with VMware, but not at this level.

Essentially, I would like to take a logical drive (let's say drive D:, not a system drive) Windows server VM that exists on a data store, copy to a different data store and use on another Windows Server VM as drive F: (again, not a system drive). If someone could point me to the reference documentation for this task or expose the steps for me, I would be very happy.

TIA. J

Did you saw the "*" in my example, the command? Who would take all the files that make up a virtual disk.

As André writes, essentially a virtual disk is represented by two files (under ESX). If you see several files with the same name, numbers like 00001 in it and a hard extension you have snapshots. Remove the sanpshot via Manager Snapshots (not the files directly) before copying the virtual disk.

AWo

VCP 3 & 4

Author @ vmwire.net

\[:o]===\[o:]

= You want to have this ad as a ringtone on your mobile phone? =

= Send 'Assignment' to 911 for only $999999,99! =

Tags: VMware

Similar Questions

  • Cannot create a virtual machine with a vmdk file copied from another location, please find the attached error

    Hi all

    I copied a file from one place vmdk and try to make a new virtual machine with this vmdk file. But when I turn on after the creation of vm error is coming. Error in the text and the image below

    Power on the virtual machine: cannot open scsi0:0 disc: disc not supported or not valid type 7. Ensure that the disk has been imported.

    See the error of the stack for more details on the cause of this problem.

    Time: 31/03/2015-14:40:05

    Target: DBServer

    vCenter Server: vcsa

    Error stack

    An error was received from the ESX host turning on DBServer VM.

    Unable to start the virtual machine.

    Power DevicePowerOn module has failed.

    Unable to create the virtual SCSI device for scsi0:0, ' / vmfs/volumes/543d140b-feb33d52-7640-90b11c9796c3/vmdk/kapuatdb.vmdk'

    Could not open scsi0:0 disc: disc not supported or not valid type 7. Ensure that the disk has been imported.

    This error message generally if the hard files have been copied hosted as VMware Workstation product, which uses a format of sparse file that is not supported on an ESXi host. Instead of the hard copy, you can use VMware Converter, or - if you prefer - you can convert the hard using vmware-vdiskmanager (before transfer) or vmkfstools (after downloading). I deal to use vmkfstools you will need to load the mutliextent module (see for example "Clone or migration operations involving virtual discs non-VMFS on ESXi fail with an error" vSphere 5.1 Release Notes)

    André

  • How to list virtual machines with associated vmdk files

    Hello.

    I have a folder vmfs and file vmdk with names that aren't like any virtual machine name (probably because that rename the virtual computer name).

    How can I find what VM is?

    Thank you

    Hello, biokovo-

    You can use the standard Get - VM and hard to find names of VMDK VMs-associated cmdlets Get-disc.  Or another, much more quickly elsewhere, would be to use everyone's favorite: Get-View.

    Since you know the path of the data store for the VMDK, you can check the property LayoutEx of virtual machines to find the virtual machine that said the file property with the name of the value as the games way to store data, as:

    $strVmdkDatastorePath = "[mydatastore] somefolder/somefile.vmdk"Get-View -ViewType VirtualMachine -Property Name,LayoutEx.File | ?{$_.LayoutEx.File | ?{$_.Name -eq $strVmdkDatastorePath}} | select name
    

    Where the path of the data store's format, "[datastoreName] folder/somefile.vmdk.  Yes, including the square brackets around the name of the data store and a space after the "]" (before the first character of the name of the folder).

    How does do for you?  (must be straight fast)

  • Script to the list of virtual machines with their VMDK on warehouses of data with their LUN ID.

    Hey gang - I have one here, I wonder if anyone has some ideas...

    Our storage team is looking for a report that can be generated to display each VM, each VMDK for this virtual machine and the data store on the VMDK is the canonical name of the data store - and throw in a delimited file of semicolon for their own transformation...

    I have thousands of VMS over hundreds of hosts and data warehouses and also have a handful of RDM. so, I'm looking for the most effective way to go about it.

    Should look like this:

    VMName; VMDKName, the data store; MONDAY

    somevm; somevm.vmdk; DATASTORE1; NAA.60050723145982asd29823blahblah1

    somevm; somevm_1.vmdk; DATASTORE2; NAA.60050723145982asd29823blahblah2

    Any ideas?

    The following PowerCLI script will give you the report requested on the virtual machines and their VMDK files. It also takes account of the fact that a data store can have several extensions:

    Get-VM |
    Get-HardDisk |
    Select-Object -Property @{N="VM";E={$_.Parent}},
    @{N="VMDK";E={$_.FileName.Split('/')[1]}},
    @{N="Datastore";E={$_.FileName.Split(']')[0].TrimStart('[')}},
    @{N="LunID";E={[string]::Join(',',((Get-Datastore $_.FileName.Split(']')[0].TrimStart('[')).Extensiondata.Info.Vmfs.Extent |
      Select-Object -ExpandProperty DiskName))}}
    
  • Clone a virtual machine to a Cluster data store

    Hello

    Really simple (hopefully), but I'm trying to write a workflow that includes the provision of a virtual computer to a cluster of data store. I'm a link to the workflow 'Clone the virtual machine, no customizations' that only accepts a store of input data.

    I hope that I am a bit stupid here and there is a simple answer?

    Thank you.

    There is no simple answer.  DRS clusters are actually a set of rules and not a real thing, you can deploy a VMDK.  I suggest to use Onyx to deploy a virtual computer to a DRS cluster and see what it generates.  If I remember correctly, it executes DRS rules to get a recommendation for where to put a VMDK fundamentally and then uses the exit in order to actually deploy the model.

    I opted to write just a simple workflow that finds the data store with the most of freespace that corresponds to a string - for example, if I have a DRS cluster named DSCluster_ugabuga, I have a lot of data stores named something like "ugabuga... ».  So you ask these storages of data and find the one which most freespace.

  • Create the virtual machine by using the file PowerCLI and csv

    I know there is a lot of info out there on this and I think I have a working script prety good.  Much was borrowed from this thread, http://communities.vmware.com/thread/315193 many thanks to LucD.

    My code is as follows:

    # Deploy virtual machines from CSV file
    # Much borrowed from http://communities.VMware.com/thread/315193?start=15 & tstart = 0


    # CSV import file
    Import-Csv "C:\guests.csv" - UseCulture | %{
    # Gets the customization information to configure the static NETWORK card and assign the static IP address
    Get-OSCustomizationSpec $_. Customization | Get-OSCustomizationNicMapping | `
    Game-OSCustomizationNicMapping - UseStaticIP - IpAddress IpMode $_. ""IP address""
    -Subnet mask $_. Subnet - DefaultGateway $_. Gateway - Dns $_. DNS
    $vm = New-VM-Name $_. "" Server name "-model $_. Model-host $_. ' "The ESX host" '
    -Datastore $_. Data store - OSCustomizationSpec $_. Customization"
    -Confirm: $false - RunAsync
    ## .......
    }

    He's going to cross and clone the virtual machine, and looks like he's running of the OSCustomizaitonSpec then it bombards.  It cleans bad VM.  Recent tasks shows "failed virtual machine clone that a specified parapeter was not correct." hostname ".

    The problem is that I don't mean to set a hostname with the OSCustomixationSpec, I try only to IP address info.

    I'm runningn PowerCLI 5.0.1 build 581491

    My ESXi host is 5.0.0 build 914586

    My vCenter Server is Ver 5.0.0 build 623373

    I opened a new thread, because the age of the old thread.  Not sure if this is the best way to do things.

    A very simple and intuitive brake system :-)

    ## Deploy VMs from CSV File
    ## Much borrowed from http://communities.vmware.com/thread/315193?start=15&tstart=0  
    
    $maxJobs = 3 $currentJobs = 0
    ## Imports CSV file
    Import-Csv "C:\temp\TestDeploy1" -UseCulture | %{
    ## Gets Customization info to set NIC to Static and assign static IP address
        Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | ` ## Sets the Static IP info
        Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_."IP Address" `        -SubnetMask $_.Subnet -DefaultGateway $_.Gateway -Dns $_.DNS## Sets the name of the VMs OS
        $cust = Get-OSCustomizationSpec -Name Test    Set-OSCustomizationSpec -OSCustomizationSpec $cust -NamingScheme Fixed -NamingPrefix $_.VMName## Creates the New VM from the template
        $vm=New-VM -Name $_."Server Name" -Template $_.Template -Host $_."Esx Host" `        -Datastore $_.Datastore -OSCustomizationSpec $_.Customization `        -Confirm:$false -RunAsync
    
        $currentJobs = Get-Job -State Running | Measure-Object | Select -ExpandProperty Count    while($currentJobs -ge $maxJobs){
          sleep 30      $currentJobs = Get-Job -State Running | Measure-Object | Select -ExpandProperty Count    }
    ## .......
    }
    

    You can be more selective about the current jobs. For example, you can check if the name of the job shows that they are actually cloning jobs.

  • How to install an operating system on a virtual machine using the ISO file?

    Hello

    I use vmware workstation version 6. I have different kinds of opersting systems likeFedora, Ubuntu, Windows xp CD to install on my virtual machines using the CD-ROM drive.  . I want to know is possible to install a virtual machine via an ISO file?

    Thank you

    mypass

    Yes

    Click on "Menu" > "new" > "virtual machine".

    Click on "Customize."

    Select "next".

    Select "install-disk (iso)".

    Click 'Browse '.

    the rest is explained

    _________________________

    VMX-settings- WS FAQ -[MOAcd | http://sanbarrow.com/moa241.html]- VMDK-manual

  • Clone a virtual machine directly from single ESXi host

    Hi, I want to clone a virtual machine with all the related feathers which the Associate ID (CPU ID, UUID, BIOS ID, etc.) and redeployed on another single ESXi host. It could help me how can I do?

    Hello

    without vCenter server you can accomplish this by check script PowerCLI this useful post below:

    Tools of HL - part 1 - clone a virtual machine without vCenter - notes LucD

    If you want to clone individual disks check this KB:

    VMware KB: Cloning of disks to the individual virtual machine through the ESX/ESXi terminal host

    _________________________________________________________________________________________

    If you have found this device or any other answer useful, please consider to award points. (use the useful or correct)

    Kind regards

    P.

  • VCo workflow to clone a virtual machine of centos. Network interface problem

    Hello

    I use vco workflows to clone a virtual machine of vcenter. The virtual machine is running centos 6.0. When cloning is complete. I see the network eth0 and eth1 interfaces set correctly the static gateway ip and address information I provided. I deleted the 70 - persistent - net .rules on the basic vm form which I clone. So, I get the correct interface names. But when vm powers on and I run "ifconfig eth0" I don't see the IP address of this interface has all the details.  same for the other interface also.

    But if I do a system restart network without changes to networking and then do an ifconfig I see the IP with the previous information.   I don't know why the service network restart is necessary so that he can recognize the ip address.

    Any ideas what I could do wrong. or to avoid this manual step of the execution of the service network restart command on the creation of the vm.

    Thank you

    Kiran

    Yes I'm restarting after after the application of customization.

    Has been able to solve the problem... In CentOS, the network service does not work by default. This is why it does not have network interfaces at startup. So now the machine instant, I started the network services and stop the Network Manager service

    using chkconfig network on

    chkconfig NetworkManager off

    and then cloned from this virtual machine... and apply the customization settings. during the start now it shows the interfaces properly without needing a service restart

  • Error trying to clone a virtual machine

    Hello

    I'm trying to use the vsphere api 5.0 to clone a virtual machine that was created in the web client.

    Here is my XML SOAP message:

    <? XML version = "1.0" encoding = "UTF-8"? >

    " < SOAP-SOAP ENV:Envelope - ENV:encodingStyle = ' http://schemas.xmlsoap.org/SOAP/encoding/ "xmlns:SOAP - ENV =" " http://schemas.xmlsoap.org/SOAP/envelope/ "container =" " http://www.w3.org/2001/XMLSchema "" xmlns: xsi = " " http://www.w3.org/2001/XMLSchema-instance "xmlns:SOAP - ENC =" " http://schemas.xmlsoap.org/SOAP/encoding/ ">

    < SOAP - ENV:Body >

    < CloneVM_Task xmlns = "urn: vim25" >

    < _this type = 'VirtualMachine' > vm-xxxxx < / _this >

    < folder > datacenter-xxxxx < / case >

    < name > clone-test-1 < / name >

    < spec >

    < location >

    store of data <>data store - xxxxx < / datastore >

    resgroup-xxxxx < pool > < / pool >

    < / location >

    false < template > < / template >

    false < powerOn > < / powerOn >

    < / spec >

    < / CloneVM_Task >

    < / SOAP - ENV:Body >

    < / SOAP - ENV:Envelope >

    but I get the error "the application refers to an unexpected or unknown type".

    Here is the entire response in a table:

    {Array (15)}

    'key' = >

    String(11) "task-xxxxxxx".

    "task" = >

    String(11) "task-xxxxxxx".

    'name' = >

    (12) a string "CloneVM_Task".

    'descriptionId' = >

    (20) a string "VirtualMachine.clone".

    'entity' = >

    String (8) "vm-xxxxx".

    "entityName" = >

    (8) a string 'xxxxxx '.

    'State' = >

    String(5) "error".

    'cancelled' = >

    String(5) "false."

    'Cancel' = >

    (4) a string 'true '.

    'error' = >

    {Array (2)}

    'fault' = >

    {Array (1)}

    "argument" = >

    (22) a string "ManagedObjectReference".

    }

    'localizedMessage' = >

    String (52) "request refers to an unexpected or unknown type."

    }

    'reason' = >

    {Array (1)}

    'userName' = >

    String (10) "myusername".

    }

    'queueTime' = >

    (26) string "xxxx".

    "startTime" = >

    (27) string "xxxx".

    'completeTime' = >

    (26) string "xxxx".

    'eventChainId' = >

    String (7) 'xxxxxxx '.

    }

    Thanks in advance for any help, it will be greatly appreciated!

    Yes, login and vcenter.

    Thanks for trying to help, but I managed to solve it.  It turns out that it was

    1. I was providing the setting wrong folder (should have been the result of FindByInventoryPath('your_data_center_name/vm') instead of FindByInventoryPath ('your_data_center_name')

    2. I didn't need to provide anything inside the 'location' parameter, it comes to be present

    Thank you again and hope that the above comments help someone else trying to do the same thing

  • Clone the virtual machine to the local data store

    Hi all

    I'm looking to automate a task daily (or almost) of my friends with a small script with powercli.

    I'm trying to "backup" or to clone a virtual machine, I work in a storage of one of our servers.

    The servers are managed by a 5.1 vCenter and the machine is on a shared storage.

    From time to time, I clean, stop the machine, remove all snapshots and clone the virtual machine to one of the local server as a backup storage. So I put together a small script which almost works. It works as long as the target data store is a shared storage, but not with a local storage.

    I get always an error that claims it can not access the local data store and is not a permissions problem...

    Given that I can accomplish this via the customer without problem I thought it is possible via powercli too, or I'm wrong?

    My Script up to now:

    # Variables
    $VC = "vc.domain.com" #vCenter Server
    $User = "domain\user" #User
    $Pass = 'test123' #User PW
    $VMName = 'scripttest' #VM
    $BackupSuffix = "backup" #Suffix to add the name of VM to mark this as a backup
    $VmHost = "esx2.domain.com".
    $Datastore = 'ESX2-LocalData' #Datastore
    $BackupFolder = 'Backup' #Folder the VM gets classified


    # Register cmdlets to VMware

    If (-not (Get-PSSnapin VMware.VimAutomation.Core - ErrorAction SilentlyContinue)) {}

    Add-PSSnapin VMware.VimAutomation.Core

    }


    # Connect to the server

    SE connect-ViServer $VC - user $User-password $Pass


    # Remove the old clone

    $OldBackups = get - VM | WHERE {$_.} {Name: corresponds to '$VMName - $BackupSuffix'}

    If ($OldBackups - don't "")

    {

    If ($OldBackups.Count - gt 1)

    {

    Write-Host "better check! "Found several results:

    Foreach ($VM to $OldBackups)

    {

    Write-Host $VM. Name

    }

    }

    on the other

    {

    Remove-VM - VM $OldBackups - DeleteFromDisk-confirm: $false

    }

    }


    # Clone VM

    $VMInfo = get - VM $VMName | Get-View

    $CloneSpec = new-Object Vmware.Vim.VirtualMachineCloneSpec

    $CloneSpec.Snapshot = $VMInfo.Snapshot.CurrentSnaphshot

    $CloneSpec.Location = new-Object Vmware.Vim.VirtualMachineRelocateSpec

    $CloneSpec.Location.Datastore = (get-Datastore-name $Datastore |) Get - View). MoRef

    $CloneSpec.Location.Transform = [Vmware.Vim.VirtualMachineRelocateTransformation]: sparse

    $CloneFolder = $VMInfo.Parent

    $CloneName = "$VMName - $BackupSuffix".

    $TaskCloneID = $VMInfo.CloneVM_Task ($CloneFolder, $CloneName, $CloneSpec)


    # Check if the task is completed


    $Check = $false

    While ($Check - eq $false)

    {

    $Tasks = get-job | Select State, id | Where {$_.} State - eq "Running" - and $_. State - eq "pending"}

    ForEach ($Task in $Tasks)

    {

    If ($Task.id - eq $TaskCloneID)

    {$Check = $false}

    on the other

    {$Check = $true}

    }

    Start-Sleep 10

    }

    # Move clone to the backup folder

    Move-VM - VM '$VMName - $BackupSuffix' - Destination $BackupFolder


    # Disconnect

    Disconnect-VIServer-confirm: $false

    Can you show us the complete error message you get?

    BTW, the clone step can be replaced by the New-VM cmdlet with the setting of the virtual machine.

  • Clone a virtual machine and change is the network settings?

    I'm looking to clone a virtual machine several times change the network connection and the IP he uses, any help appreciated.

    NP, alternative, will host this script:

    $vmlist=Import-CSVC:vms.csv
    foreach($itemin$vmlist) {
     # I like to map out my variables
     $vmname=$item.vmname
     $ipaddr=$item.ipaddress
     $subnet=$item.subnet
     $gateway=$item.gateway
     $pdnswins=$item.pdnswins
     $sdnswins=$item.sdnswins
     #Get the current interface info
     $GuestInterface= Get-VMGuestNetworkInterface -VM $vmname -HostCredential $HostCred-GuestCredential$GuestCred
     #If the IP in the VM matches, then I don't need to update
     If ($ipaddr-ne$($GuestInterface.ip)) {
         Set-VMGuestNetworkInterface-VMGuestNetworkInterface$GuestInterface -HostCredential $HostCred -GuestCredential $GuestCred -IP $ipaddr -Netmask $subnet -Gateway $gateway -DNS $pdnswins,$sdnswins-WINS  $pdnswins,$sdnswins
     }
    }
  • How to clone a virtual machine using ESXi 4.1 and vSphere?

    Instructions for I have seen that you can click with the right button on a virtual machine and choose "Clone", but I think it's only for vCenter

    Is there a way to clone a virtual machine in vSphere?

    Thank you

    If you have a licensed copy of ESXi (not vSphere Hypervisor, the free version), you can try the document below.  However, if you do not have a licensed copy you vCenter for cloning function

    http://communities.VMware.com/docs/doc-11708

  • Can not power on virtual machines "cannot access the file because it is locked.

    Virtual machines have been working well - then the storage system is down.  After the storage system returns upwards that I can't turn on a number of virtual machines.  Get this error when I try to turn it on:

    Cannot power on vmname on esxhostname.xxxxx.com. Unable to access file < unspecified file name > because it is locked
    error

    1. To check the locks on the Service Console on non ESXi servers, run the command:

      lsof | grep

      COMMAND PID USER FD TYPE SIZE NŒUD NOM_PERIPHERIQUE
      71fd60b6-3631 root 4r REG 0.9 10737418240 23533

      Note: If there is no Console of Service process the locking file, you should receive no printed output. If you receive results, however, file a support request to identify the process and to determine the causes.  If it is a third-party process, however, contact the appropriate provider to determine the cause before you kill the process ID, because it can happen again in the future.

      Stop the process and the lock ID using the kill command. In the example above, the process ID is 3631:

      kill the 3631

      After the termination of the process, you can try to turn on the virtual machine or access the file resource.

    2. To check if the virtual machine is always a world ID assigned, run these commands on all ESX/ESXi hosts:

      CD/tmp
      VM-support - x

      Available to debug worlds:
      WID =

      On the ESX/ESXi host where the virtual machine still works, kill the VM, which releases the lock on the file. To kill the virtual machine, run the command:

      VM-support - X

      Where the is the ID of the world of the virtual machine with the locked file.

      Note: this command takes 5-10 minutes to complete. Answer No to "can I include a screenshot of the virtual machine", and answer Yes to all subsequent questions.

      After the termination of the process, you can turn on the virtual machine or access the file resource.

    Deleting the file .lck (NFS only)

    The virtual machine files can be locked via NFS storage. You can identify this as reported by .lck files. # (where # is the ID of the world that holds the lock file) at the end of the file name. It is a NFS file lock and appears only when you use the ls command as it is the hidden file.
    Beware: they can be removed safely only if the virtual machine is not running.

    Note: VMFS volumes have no .lck files. The locking mechanism for VMFS volumes is managed within VMFS metadata on the volume.

    You must kill the process that is locked, if it is not the case, you probably need to restart the VMware host.
    I tell you from experience most likely end up rebooting it.

  • How to clone a virtual machine with the drive?

    Hello

    Previously, I used VMware Workstation and has a mastery of "clone". Now I use the reader and I would like to clone my current VM and there is no special orders. Simply copy the directory would probably not there a lot of information such as DNS name, etc. that are likely to be changed. Is it possible to clone a virtual machine with player or do I Workstation?

    Many thanks in advance,

    Nicolas

    In my computer a full clone is nothing more then is not a copy that was made unique in the process and the players of VMware capacity but there is nothing stopping you from manually making a copy and then manually by making the changes to make it unique.

Maybe you are looking for