is there an action to add a disk to a virtual machine by specifying a vmdk file?


I'm trying to reproduce the functionality of the GUI to add a drive (not create new) existing in a virtual machine and specifying the hard file that will be used.  You would change from the GUI, then add and choose the hard drive.  Then choose Select the use an existing hard drive and dig into the specific to the hard file data store.

After selecting the hard, then choose the SCSI device and channel and complete the wizrard.  After you add the disk, then go back and select the hard disk and choose manage paths to change the walkway on the MRU policy.

Ideally, the user would be able to use something like VC:Datastore use a tree view to point to the vmdk when adding the drive, however I tried VC:Datstore and it only allows you to go as far as the data store but not more to specify the drive.

Thank you

Here is the script updated with the VCVirtualDiskRawDiskMappingVer1BackingInfo backup type.

backup of var = new VcVirtualDiskRawDiskMappingVer1BackingInfo();
backing.fileName = diskPath;
backing.diskMode = "independent_persistent";

backing.thinProvisioned = false;

backing.eagerlyScrub = true;

backing.writeThrough = false;

backing. Split = false;

connectable var = new VcVirtualDeviceConnectInfo();
connectable.startConnected = true;
connectable.allowGuestControl = false;
connectable. Connected = true;

Like var = [];

do we need a Comptroller?
If (scsiControllerKey< 0)="">
controller of var = new VcVirtualLsiLogicSASController();
controller.sharedBus = VcVirtualSCSISharing.fromString ("physicalSharing");
controller.busNumber = scsiBusNumber;
Controller.Key = - 100;
scsiControllerKey = - 100;

var deviceChange = new VcVirtualDeviceConfigSpec();
deviceChange.operation = VcVirtualDeviceConfigSpecOperation.add;
deviceChange.device = controller;

dcArr.push (deviceChange);
}

device of var = new VcVirtualDisk();
Device.Key = - 101;
Device.backing = support;
Connectables = device.connectable;
device.controllerKey = scsiControllerKey;
device.unitNumber = scsiChannelNumber;

device.capacityInKB = size * 1024 * 1024;

var deviceChange = new VcVirtualDeviceConfigSpec();
deviceChange.operation = VcVirtualDeviceConfigSpecOperation.add;
deviceChange.device = device;

dcArr.push (deviceChange);

spec var = new VcVirtualMachineConfigSpec();
spec.deviceChange = like;

This enables the multi-writer on disk

option of var = new VcOptionValue();
option. Key = 'scsi' + scsiBusNumber + ': ' + scsiChannelNumber + '.sharing;
option. Value = "multi-writer";

var extraConfig = [];
extraConfig.push (option);
spec.extraConfig = extraConfig;

task = vm.reconfigVM_Task (spec);

Tags: VMware

Similar Questions

  • Cannot add to the inventory if virtual machine running on the other guests - iSCSI and VMFS5

    5.5 ESXi hosts free standalone version

    iSCSI mounts with multiple paths - relatively new unit with more modern hardware

    CHAP not used

    I'm running a few hosts in order to climb the same iSCSI data stores. The iSCSI LUN is visible and editable by all hosts. If Host1 is to map the iSCSI LUN (VMFS5) and a VM is powered, Host2 can add that VM to the inventory. It's possible with NFS iSCSI for a reason any. This is for a specific reason? Only when I turned off the virtual computer can I add it to both hosts. Other that just lock files are placed in the directory, I missed something related to the lock?

    From now on, adding new esxi hosts does not allow me to add existing virtual machine, less than the voltage first. Once again, NFS does, iSCSI, this isn't. Any ideas?

    It is not specific to ISCSI but rather to the use of VMFS. NFS has no awareness VM VMFS is and why it is not possible to do that with iSCSI / VMFS. There is a lock on the disk for each virtual machine of (race), and that's why the second host is not able to add this host to its inventory. With vSphere HA, this lock is released when a failover should occur.

  • Cannot open the hard file. One of the disks in this virtual machine is already in use by a virtual machine or a snapshot

    Hi all

    Tried my level best to solve, but still the same problem persists. . Lck tried but as soon close VMware workstation, it disappears. This problem starts when yesterday instead of powering down, suspended. The next resume when it gives captioned error. Tried creating new virtual machine using an existing vmdk file but my mainly all the data disappeared. Now I want to resume the suspended state. Kindly help on the same. Thank you

    OK, we will first focus on the first virtual disk (System) on the D: drive which has enogh of disk space to create a clone.

    The "Windows Server 2003 Enterprise Edition.vmdk" dated from 19/07/13 is probably exactly what we need, and if it has approximately the same size of file than current/changing, then you can replace the one changed with it. Once restored, proceed as follows (with VMware Workstation closed):

    from the command line run:

    cd /d "C:\Program Files (x86)\VMware\VMware Workstation"
    cd /d D:\win2k3
    md Clone
    C:vmware-vdiskmanager.exe -r "Windows Server 2003 Enterprise Edition-000002.vmdk" -t 0 "Clone\Windows Server 2003 Enterprise Edition.vmdk"
    

    Once the cloning done so, create a subfolder "Backup" and move all over existing files (as a backup). Copy the .vmx file and .vmxf the subdirectory "Backup" in the D:\win2k3 folder, then do the same with the file hard cloned since the 'Clone' subdirectory, so that you end up with the following files:

    Windows Server 2003 Enterprise Edition.vmx

    Windows Server 2003 Enterprise Edition.vmxf

    Windows Server 2003 Enterprise Edition.vmdk

    Before you can try to start the virtual machine, you must edit the .vmx file and replace

    scsi0:0. FileName = "Windows Server 2003 Enterprise Edition - 000002.vmdk"

    with

    scsi0:0. FileName = "Windows Server 2003 Enterprise Edition.vmdk"

    Please do the above and report. If you have any questions please ask.

    André

  • Connect physical hard disks to the virtual machine (and leave the data intact)

    Hello

    I'm looking to virtualize a SOHO headless server, that I use mainly for secure file storage.

    Currently, the system runs Linux installed on a small disc and has two drives 1.5 TB, used exclusively for data, in a cluster of ZFS mirroring. (I use the ZFS-fuse Linux-based application).

    I want virtualization for two reasons. One is to make administration easier and safer - avoid having to connect a keyboard and the physical monitor to the box from time to time. The other is that the machine is a bit more powerful to handle the load, and I'm hoping to make it work on other, more challenging tasks.

    Now, there is a catch. These discs are as highly important. I mean the data on them. What I need is to convert the current Linux system to a virtual machine, or re - install Linux on a virtual machine (don't like that), then connect the physical disks to the virtual machine as if they were actually connected.

    I certainly don't want to vmware touches those disks somehow.

    I've read the documentation, but I'm a noob when it comes to server virtualization and system engineering and don't quite understand if this is possible or not. These discs are not a SAN, they are physically connected to the server, I want to install vSphere on. (Of course, I'll log out when I run the setup of vSphere. But I need plug them again later, and they need to be sure that vmware will leave them alone and pass them to the virtual machine transparent.)

    Sigmoid wrote:

    Oh yes, the cluster mirrored ZFS. It is essentially a software RAID type thingie.

    http://en.Wikipedia.org/wiki/ZFS

    A material, or the point of view of virtualization, it appears two hard drives with a single huge partition on each that is not transparent to anyone, except the implementation of ZFS.

    OK, means that you can break the RAID, connect the drives to different host and configure RAID once again, right?

    Let's do it this way

    1. We will need a disc player more for VM, cause on flash, we install ESXi
    2. I will share ZFS :-), all you need to do with that before you install ESXi
    3. make the BACKUP!
    4. Disconnect the data host drives
    5. install ESXi 4.1 U1 free version on flash
    6. Download the site VMware vSphere client
    7. Connect the VM disk to ESXi
    8. customer help create the virtual machine and install the OS on it
    9. stop the virtual machine and esxi
    10. connect DATA drives to the ESXi host
    11. begin to ESXi
    12. See how to add RDM on youtube, after client use, change first hardware VM--> add a new hard disk--> choose Raw Device Mapping--> (physical or virtual) mode--> store it with folder VM - FACT
    13. Start the virtual machine, now your VM should see both drives, with good data course :-)

    I have just made this procedure (add ROW with data in Linux VM) on ubuntu VM, works well

  • How to make a visible USB hard disk for a virtual machine on ESXI 4.1?

    Hi all

    As I am new to the world of vmware ESXI, I always make mistakes or I don't undertand all therefore be complete :-).

    So I have a HP Proliant ML 350 G6 Server installed with ESXI 4.1 and I want to connect a USB hard disk to a virtual machine (SBS 2K 8). Currently, the virtual machine is not able to see the hard drive.

    I already add a USB controller to the virtual machine, but my USB HARD drive is still not visible to my virtual machine.

    Can you help on that?

    Thank you

    Michael

    Next, add a USB device to the virtual computer (in the change settings tab), there are different things, USB controller and USB devices. Sometimes, you may have to restart the virtual machine.

    Greetings

  • Allocation of disk space to virtual machines

    I played around with assigning physical disk space to a virtual machine, in the "Add Hardware Wizard", I selected hard drive & gt; Create a new virtual disk & gt; He gave a size of 100 GB stored with the virtual machine and not independent.

    When I started the VM space, which is all that I wanted to check if I stop the virtual machine. Rather than remove the new hard drive 2 settings of the virtual machine, I have restored a previous snapshot without the new HD. Now when I check the free space on datastore1, it seems that the 100 GB does not have to be added to the free space.

    I did something wrong?

    UPDATE:

    I just tried the process again but this time assigned 8 GB.  Then I checked free space on datastore1, and now I have the 100 GB back, less the 8 GB I just posted.  Any ideas?

    If you take out it just of the virtual machine, it does not actually remove the virtual disk that you created. As you say, there are 2 options when you remove the drive, we need to remove the virtual machine, and we need to remove the disc. If you remove the disk from the virtual machine, it will always keep the file even if it is not associated with a virtual machine. There is no question to delete this file. Just make sure that you delete the correct VMDK. It's easy, if it's the only drive of 100 GB or 8 GB, you have created.

  • How can I get the number of disks for a virtual machine and PAHO are / s of a disc?

    Hi all

    I would like to know if there is a command that returns the number of disks having a virtual machine.

    and also if there is no command to obtain and change the number of the IOPS / disk s.

    Thanks in advance

    Carlos

    It will give you hard drives attached

    Get - VM | Hard drive


    It will give you count

    Get - vm | Select name, @{N = "TotalHDD"; E={($_ | (Get-harddisk).count}}


    It is possible to retrieve the number of the IOPS / disk s, but what do you mean by editing.

  • Move ROW with dynamic disk to another virtual machine

    Hello

    I'm in a situation where I have to leave my RDM Win2003 VM to win2008, but the complexity and multiple physical RDMs here make only dynamic partition (RDM1 1.5 TB, RDM2 1.5 TB, is drive G RDM3 1 TB 4 TB),

    Now my question is if I can move this partition of G (which includes 3 disks RDM) again an another VM (win2008)

    Thanks, SD

    Hello

    This does not resemble a specific question VMware.  On the contrary, seems like a question of Microsoft Windows.  Just make sure the hosts on which the virtual machine of 2008 runs can see the same ROW and follow this procedure to remove dynamic disks of the virtual machine of 2003 and add them to the virtual machine of 2008.

    Move disks to another computer

    All the best,

    Mike

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

    Remember to mark this reply 'proper' or 'useful', if you found it useful.

    Mike Brown

    NetApp, VMware and Cisco data center guy

    Consultant engineer

    [email protected]

    Twitter: @VirtuallyMikeB

    Blog: http://VirtuallyMikeBrown.com

    LinkedIn: http://LinkedIn.com/in/michaelbbrown

  • delete a virtual disk of the virtual machine of broken storage

    I have a virtual disk to a virtual machine on a broken iSCSI storage,

    now I can not remove the disc from the virtual machine.

    ESX 4.1 does not see the now broken iSCSI storage.

    See attach.

    Remove the virtual machine from the inventory and edit VMX manually deleting the reference to this disk. After that, add the machine virtual back again for the inventory.

  • Hot add option missing from all virtual machines.

    I'm under esx4.0, with all kinds of guest virtual machines (2003, 2008, 2008r2, std, ent, x 64). I don't have the option add hot for one of these clients.  It is simply absent on options & gt; Advanced tab.  What am I misssing here?

    Thank you.

    It will show only if it is an option for the operating system for some versions it won't be there.  Also, what version of material are your virtual machines?  Must be version 7 I think.

    See this link for more information.  http://www.Boche.net/blog/index.php/2009/05/10/vSphere-memory-hot-add-CPU-hot-plug

  • Can I convert a server disk to a virtual machine?

    I have a number of OS X 10.5 servers running on hardware that is incredibly underused.  Since the Fusion 3 supports running OS X Server virtualized, is it possible to convert a live server disk to a virtual machine to the BootCamp to VM? I could run all 5 of my server on a single Xserve systems. I dug around, but everything points to a new facility to achieve this.

    Thank you

    Tim

    Yes, it is possible to convert physical machines to Mac OS X Server VM. I've posted instructions on how to do this in the following thread: Re: Snow Leopard Server VM existing?

    In your case, the only thing that needs to change is the version of the OS - pick instead of 10.6 10.5. I tried this with one of my machines so far, I would be interested to comment on the question of whether instructions to work for you. I'll probably convert this post into a document at some point...

    I also thought the ability to hire only the OS X physical disk partitions without copying the data (like Fusion for Boot Camp). However, Fusion currently only supported the MBR partition tables to access raw partitions, and most Macs are partitioned GPT (or hybrid MBR + TPG). You can try to use Library/Application Support/VMware Fusion/vmware-rawdiskCreator to see if it recognizes the OS X partitions. If so, you should be able to create a virtual disk that references the partitions and boot from it as you would for a machine virtual Boot Camp.

    It is also possible to use a physical disk full (instead of individual partitions), but you would need to have partitions not mounted before using virtual machines that reference the physical disks. If you are interested in, there is a link in this thread as well.

  • How can I add a tag to a virtual machine?

    What is the best way to be part of an workflow add a label to a virtual machine? The closest I found is System.getModule("com.vmware.library.vc.customattribute").setOrCreateCustomField (), but given that the custom fields do not appear in the web client, I need a way to do the same with the tags in place.

    Unfortunately the vSphere API does not yet provide a way to create (vCenter) tags. The only way is to use the provided of the vCO powershell cmdlets.

  • Copy of the data of the disk of the virtual machine on a Local disk is too slow

    We have recently implemented vMware view.   We vSphere 5.5 and 5.2 and made Desktop visualization server.

    We have SAN as HP 3Par and Esxi hosts are HP ProLiant DL380p Gen8

    Now all trying to copy the data from the disk of the virtual machine disk of the local computer are too slow. But if we are writing data from Local disk on the disk of the virtual machine is normal. And copying data between the two virtual machine disk is also fast.

    Thanks in advance for your help

    Dear all,

    Thanks for your help.

    We have analyzed the issue in 360 degrees, and we also examined your entries. Finally, we found the problem. It was that a defective fiber link has been creating the problem.

    We have recently implemented vMware and this flaw in fiber can also happened during this period. That's why we thought it may be because of vmware.

    Thanks again for your help

  • Maximum number of virtual disk for a virtual machine in vSphere 4.1

    I read the maximum record rate and see that the maximum number of virtual disk is 16 for FT.

    I have the same document I seem not to be able to see the number max of virtual disk that can be taken in charge for a virtual machine.

    The number will be the same as the number of LUNS per host which is 256?  I know the max is for the host, but that be will come the number of Director to the total number of virtual disk that can be supported in the virtual machine?

    In fact, in a logic unit number, we can have more than one data store that can be mapped to a virtual disk.

    I'm confused.

    Thank you and have a nice week,

    Anthony.

    If I am not mistaken, you can attach up to 60 virtual disks to a virtual machine. 15 for each of the 4 virtual SCSI controllers.

    André

  • How to add a script to a virtual machine using vmwrae api?

    Hello

    I am trying to add a new disk to an existing VM (Linux).

    To do this.


    Now to use the new drive on a run a series of commands, like:

    -format the drive

    -mount the drive

    -put this information to disk in the file/etc/fstab


    My question is how we can automate this task without actually going inside the virtual machine?

    This is precisely what my advice is intended to accomplish. There are many examples available online to use Invoke-VMScript to automate actions in a Linux VM.

    http://www.Google.com/search?q=invoke-vmscript+examples

    This was done from my Windows using PowerCLI workstation to a virtual machine running SLES:

    PowerCLI C:\> Invoke-VMScript -vm $vm -HostCredential $hc -GuestCredential $gc -ScriptText "uptime"
    
    ScriptOutput
    ---------------------------------------------------------------------------------------------------
     08:32:52 up 88 days,  7:27,  0 users,  load average: 0.00, 0.00, 0.00
    |
    ---------------------------------------------------------------------------------------------------
    

Maybe you are looking for