How to create a virtual machine in bulk using a script (bottom)

Source: Internet
Author: User

In the previous article we described how to clone a virtual machine using VMware, although cloning allows us to avoid the tedious creation process, greatly simplifying our operations, but in the case of the need to create a large number of virtual machines, the steps are still more, obviously does not meet our high-efficiency requirements.


This article describes the use of VMware-provided command-line tools Vmrun.exe and the way you write batch scripts to create and manage virtual machines in bulk.


From the previous article we learned that cloning is the way to create virtual machines, using scripts to bulk create virtual machines is actually the same principle as cloning. The general idea is to clone the virtual machine through batch commands, and then implement batch creation by looping the batch command.


Here's a detailed description of how to create a virtual machine procedure using a script:

First we understand what Vmrun is. Vmrun is a command interface program provided in Vmwareworkstations, through which we can achieve multiple, continuous automation of virtual machines. such as the power management of virtual machines, quick-find management, cloning virtual machines and other functions.


How to use Vmrun.

Enter the Vmwareworkstation installation directory to locate the Vmrun.exe and copy its path. Win+r input cmd Open a command prompt and perform the actions in the following figure

Enter the Vmrun/? command to see its statement specification and help parameters


Now that we know the spec, we're going to start writing batch commands, like cloning steps, first to close the virtual machine we created earlier and then take a snapshot of it, with the following instructions:

Vmrun-t ws Stop "g:\ virtual machine \ Clone virtual Machine \WIN001.VMX"

' WIN001.VMX is the configuration file for the virtual machine, which is the path to the demo case Virtual machine configuration file

Vmrun-t ws snapshot "g:\ virtual machine \ Clone virtual machine \WIN001.VMX" VM001

"Create a snapshot named VM001 for our virtual machine

The cloning instructions are as follows:

Vmrun.exe-t ws clone "g:\ virtual machine \ Clone virtual machine \WIN001.VMX" g:\ virtual machine \ New Clone virtual machine \WIN002.VMX linked-snapshot=vm001-clonename=win002

"From a snapshot named VM001, a virtual machine named win002 saved under the path" g:\ virtual machine \ New Clone virtual machine "is cloned. Cloning is a "linked clone" and if you are creating a fully cloned virtual machine, the parameter is changed to full

With the above instruction, we can implement the clone virtual machine, and the Cycle Clone command can realize the mass creation of the virtual machine. Creating a text document writes the command to it and changes its file suffix to. bat to create the script. The script commands are as follows:

Click Script execution to create the following:

Finally, we should all have found that using script batch creation is actually just a loop execution of the clone command, the same principle. However, its automated implementation process can greatly improve our efficiency. There are many ways to achieve batch creation, and you are welcome to add to the comments section.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.