Changes

Jump to: navigation, search
Virtual Machine Snapshots with vmrun
<pre>
vmrun -T server -h https://xps:8333/sdk -u root -p mypassword deleteSnapshot "[Vol1] CentOS 5.2/CentOS 5.2.vmx" MySnapshot
</pre>
 
== Using vmrun to Work with Guest Operating Systems Files and Directories ==
 
A particularly powerful feature of ''vmrun'' is the ability to interact with files residing in a guest operating systems from either host, or a remote system. For example, vmrun can be used to identify the existence of a file in a specific virtual machine guest, delete a file, create a directory and copy files between guest and host. In each case, a user name and password valid for logging into the guest operating system must be provided using the ''-gu'' and ''-gp'' flags.
 
The following command require that VMware Tools be installed in the guest operating system. For more details on VMware Tools refer to the chapter entitled [[Understanding and Installing VMware Tools]].
 
To check for the existence of a particular file:
 
<pre>
vmrun -T server -h https://xps:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd fileExistsInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/MyFile
 
The file exists.
</pre>
 
To delete a file on a guest:
 
<pre>
vmrun -T server -h https://xps:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd deleteFileInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/MyFile
</pre>
 
To create a new directory in a guest filesystem:
 
<pre>
vmrun -T server -h https://xps:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd createDirectoryInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/nas/foo
</pre>
 
To remove a directory from a guest filesystem:
 
<pre>
vmrun -T server -h https://xps:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd deleteDirectoryInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/nas/foo
</pre>
 
To list the files in a guest system directory:
 
vmrun -T server -h https://xps:8333/sdk -u root -p 3579xps -gu fred -gp guestpasswd listDirectoryInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred
Directory list: 5
.esd_auth
.dmrc
.gconfd
.recently-used.xbel
Desktop
</pre>
 
To copy a file from the host system to the guest operating system (i.e copy the file /home/fred/MyFile on the guest to /tmp/MyFile on the host):
 
<pre>
vmrun -T server -h https://xps:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd copyFileFromGuestToHost "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/MyFile /tmp/MyFile
</pre>
 
Conversely, the copy a file from the host to the guest:
 
<pre>
vmrun -T server -h https://xps:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd copyFileFromHostToGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /tmp/MyFile /home/fred/MyFile
</pre>
 
To rename a file on the guest:
 
<pre>
vmrun -T server -h https://xps:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd renameFileInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/MyFile /home/fred/MyNewFile
</pre>
 
== Capturing a Virtual Machine Screenshot ==
 
A screenshot of the console of a running virtual machine may be captured and written to a file on the host using the vmrun ''captureScreen''. The name of the file to which the image is to written is supplied as a parameter to the command. Note that the image is created in PNG format, so the file should be given the appropriate ''.png'' filename extension. For example:
 
<pre>
<pre>
vmrun -T server -h https://xps:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd captureScreen "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/images/vm_screen.png
</pre>

Navigation menu