eMarcel.com

Oracle Database, Fusion Middleware, Linux

Managing VMware images from command line using vmrun tool

Managing VMware images in VMware Server 2.x can be done in several ways. One way is to utilise Web based GUI and the second way is the command line.

To login to the Web based GUI

  • (SSL) https://hostname:8333/ui/#
  • http://hostname:8222/ui/# (How to disable redirect to SSL could be found here)

Let’s get focused on Shell commands – application: vmrun

Usage: vmrun [AUTHENTICATION-FLAGS] COMMAND [PARAMETERS]

Listing VM’s 

#To List registered VMs
[email protected]:~$ vmrun -T server -h 'http://localhost:8222/sdk' -u user \
-p password listRegisteredVM

Total registered VMs: 10
[standard] MyImageDir/my_wmware_image.vmx

# To List all running VMs
[email protected]:~$ vmrun -T server -h 'http://localhost:8222/sdk' -u user \ 
-p password list

### LINUX SCRIPT ###
#privileged user:
user=`whoami`

read -s -p "Password: " PASS
echo
echo "Registered VMS:"
vmrun -T server -h 'http://localhost:8222/sdk' -u ${user} -p ${PASS} listRegisteredVM

echo "Running VMs:"
vmrun -T server -h 'http://localhost:8222/sdk' -u ${user} -p ${PASS} list

Start/Stop

#Starting a virtual machine with Workstation on a Linux host
[email protected]:~$ vmrun -T server -h 'http://localhost:8222/sdk' -u user -p password start "[standard] MyImageDir/my_wmware_image.vmx"

#Stopping a virtual machine
[email protected]:~$ vmrun -T server -h 'http://localhost:8222/sdk' -u user -p password stop "[standard] MyImageDir/my_wmware_image.vmx"

#make sure you will use exact syntax as above (including [standard] - which is a storage name)
#additional tasks: reset, suspend, pause, unpause

Snapshots

#Creating a snapshot of a virtual machine
[email protected]:~$ vmrun -T ws snapshot "/home/user/MyVms/MyImageDir/my_wmware_image.vmx" mySnapshot

#Reverting to a snapshot
[email protected]:~$ vmrun -T ws revertToSnapshot "/home/user/MyVms/MyImageDir/my_wmware_image.vmx" mySnapshot mySnapshot

#Deleting a snapshot
[email protected]:~$ vmrun -T ws deleteSnapshot "/home/user/MyVms/MyImageDir/my_wmware_image.vmx" mySnapshot mySnapshot

For more options please refer to $vmrun –help pages.

Cheers!!

(Visited 108 times, 1 visits today)

,

Tweet
Share
+1
Share
0 Shares

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close