Professional Documents
Culture Documents
You can find the most up-to-date technical documentation on our Web site at: http://www.vmware.com/support/ The VMware Web site also provides the latest product updates. If you have comments about this documentation, submit your feedback to: docfeedback@vmware.com
2008 VMware, Inc. All rights reserved. Protected by one or more U.S. Patent Nos. 6,397,242, 6,496,847, 6,704,925, 6,711,672, 6,725,289, 6,735,601, 6,785,886, 6,789,156, 6,795,966, 6,880,022, 6,944,699, 6,961,806, 6,961,941, 7,069,413, 7,082,598, 7,089,377, 7,111,086, 7,111,145, 7,117,481, 7,149,843, 7,155,558, 7,222,221, 7,260,815, 7,260,820, 7,269,683, 7,275,136, 7,277,998, 7,277,999, 7,278,030, 7,281,102, 7,290,253, 7,356,679, 7,409,487, 7,412,492, and 7,412,702; patents pending. VMware, the VMware boxes logo and design, Virtual SMP and VMotion are registered trademarks or trademarks of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies.
VMware, Inc.
Thismanual,UsingvmruntoControlVirtualMachines,introducesthevmruncommand,aconvenientcommand tohelpyoumanagethecollectionofvirtualmachinesonaVMwarehost.
Revision History
Thisbookisrevisedwitheachreleaseoftheproductorwhennecessary.Arevisedversioncancontainminor ormajorchanges.Table 1summarizesthesignificantchangesineachversionofthisguide. Table 1. Revision History
Revision 20080623 20080815 Description FirstdraftofthismanualfortheVMwareServer2.0RC1andWorkstation6.5Beta2releases. ThirddraftfortheVMwareServer2.0RC2andWorkstation6.5RCreleases.
Intended Audience
Thisbookisintendedfordevelopersandsystemadministratorswhowanttocontrolvirtualmachineson variousplatforms,includingVMwareWorkstation,VMwareFusion,andVMwareServer.
Document Feedback
VMwarewelcomesyoursuggestionsforimprovingourdocumentation.Sendyourcommentsto: docfeedback@vmware.com
Online Support
YoucansubmitquestionsorpostcommentstotheDeveloperCommunity:SDKsandAPIsforum,whichthe VMwaretechnicalsupportandproductteamsmonitor.Youcanaccesstheforumat: http://communities.vmware.com/community/developer
VMware, Inc. 3
Support Offerings
TofindouthowVMwaresupportofferingscanhelpmeetyourbusinessneeds,goto: http://www.vmware.com/support/services
VMware, Inc.
VMwareprovidesanapplicationcalledvmrunforcontrollingvirtualmachines,orteamsofvirtualmachines, fromthecommandline.ThevmruncommandisavailableonanyVMwareproductthatincludestheVIXAPI libraries,orwhenthelibrariesareseparatelyinstalled.Thischaptercontainsthefollowingsections: AboutthevmrunCommand,below. UsingvmrunonWindowsonpage 6 UsingvmrunonLinuxonpage 6. VirtualMachineRunFlagsonpage 7. VirtualMachineRunCommandsonpage 7. ExamplesofUsingvmrunonpage 11.
Power Commands
Virtualmachinepoweroperationsgiveyoutheseoptions:start(poweron),stop(poweroff),reset(reboot), suspend(butallowlocalworktoresume),pause(withoutinterrupting),andunpause(continue). Onsomeproducts,youcangroupvirtualmachinesintoteams,sopoweroperationsapplytothewholeteam.
Snapshot Commands
Asnapshotreproducesvirtualmachinestateatthetimeofthesnapshot,includingalldataonvirtualdisks. Youcansnapshotavirtualmachineasyouchoose,inanypowerstate,andreverttothesnapshotatanytime. Snapshotsareusefulforexperimentation,andespeciallyusefulforbackups. Thesecommandslistexistingsnapshotsofavirtualmachine,createanewsnapshot,deleteasnapshot,and revertavirtualmachinetoitsstateasofaspecificsnapshot.VMwareServerlimitsyoutoonesnapshot.
VMware, Inc.
General Commands
Thiscatchallcategoryincludescommandstolistallrunningvirtualmachines,upgradethevirtualmachine hardwareversion,andinstallVMwareToolsontheguest. Additionally,exceptonVMwareServeryoucancloneanyvirtualmachineimagetoanothervirtualmachine. VMwareServerallowsyoutoregisterandunregistervirtualmachines.
VProbes Commands
ThesecommandssupportVProbes,afacilityfordynamicallyandstaticallyinstrumentingportionsof VMwaresoftwareandarunningguestoperatingsystem.SeetheVProbesProgrammingReferencefordetails.
Inacommandwindow,typethevmruncommandinthefollowingform
vmrun <flags> <command> <parameters>
ContinuewithVirtualMachineRunFlagsonpage 7.
Inacommandorterminalwindow,typethevmruncommandinthefollowingform
vmrun <flags> <command> <parameters>
ContinuewithVirtualMachineRunFlagsonpage 7.
VMware, Inc.
TosetthehosttypeforremoteaccesstoVMwareServer2.0,usethefollowingflagsinconjunction:
-T -h -P -u -p server <hostName> <portNumber> <adminLogin on Server> <adminPassword on Server>
Forexample,thiscommandlistsallrunningvirtualmachinesonaremoteserver:
vmrun -T server -h https://example.com/sdk -u root -p secretpw list
ForVMwareWorkstation,usetheTflagasfollows:
vmrun -T ws
ForVMwareServer1.0,usetheTflagasfollows:
vmrun -T server1
datastoreonVMwareServer:
[storage1]Win XP/Win XP.vmx
OnLinux pathonVMwareWorkstation:
/home/<username>/VirtualMachines/Ubuntu/Ubuntu.vmx
datastoreonVMwareServer:
[storage1]Win XP/Win XP.vmx
VMware, Inc.
<pathto.vmxor.vmtmfile> [hard|soft]
<pathto.vmxor.vmtmfile> [hard|soft]
<pathto.vmxor.vmtmfile> [hard|soft]
VMware, Inc.
Guest Operating System Commands runProgramInGuest Runaprogramintheguestoperatingsystem.Provide thefullpathnameofaprogramaccessibletotheguest. VMwareToolsandvalidguestloginarerequired. Alsoprovidefullaccessiblepathnamesforanyfiles specifiedintheprogramarguments. The-noWaitoptionmeanstoreturnimmediatelyafter theprogramstartsintheguest,ratherthanwaitingforit tofinish.Thisisusefulforinteractiveprograms. The-activeWindowflagensuresthattheWindowsGUI isvisible,notminimized.IthasnoeffectonLinux. The-interactiveflagforcesinteractiveguestlogin andisusefulforWindowsVistaguests,tomakethe programvisibleintheconsolewindow. fileExistsInGuest Checkwhetherthespecifiedfileexistsintheguest operatingsystem.VMwareToolsandvalidguestlogin arerequired. Modifythewriteabilitystateofafoldersharedbetween thehostandaguestvirtualmachine(.vmxfile). Thesharenameisamountpointintheguestfilesystem. Thepathtofolderistheexporteddirectoryonthehost. Asharedfoldercanbemadewritableorreadonly. Addafoldertobesharedbetweenthehostandguest. Thesharenameisamountpointintheguestfilesystem. Thepathtofolderistheexporteddirectoryonthehost. Removeaguestvirtualmachinesaccesstoashared folderonthehost.Thesharenameisamountpointin theguestfilesystem. Listallprocessesrunningintheguestoperatingsystem. VMwareToolsandvalidguestloginarerequired. <pathto.vmxfile> <pathtofileinguest> <pathto.vmxfile> <sharename> <pathtofolderonhost> writable|readonly <pathto.vmxfile> <sharename> <pathtofolderonhost> <pathto.vmxfile> <sharename> <pathto.vmxfile> <pathto.vmxfile> [-noWait| -activeWindow| -interactive] <programname> [<programarguments>]
VMware, Inc.
createDirectoryInGuest
deleteDirectoryInGuest
listDirectoryInGuest
copyFileFromHostToGuest
readVariable
General Commands list upgradevm installtools Listallrunningvirtualmachines. Upgradeavirtualmachinetothecurrentversionof virtualhardware.Hasnoeffectifalreadycurrent. PreparetoinstallVMwareToolsintheguestoperating system.InWindowsguestswithautorunenabled,the VMwareToolsinstallerstartsbyitself.InLinuxguests withoutautorun,thiscommandconnectsthevirtual CDROMdrivetotheVMwareToolsISOimagesuitable fortheguest,buttheinstallerdoesnotstart,soyoumust completetheinstallationwithadditionalmanualsteps, asdescribedinyourproductdocumentation. None <pathto.vmxfile> <pathto.vmxfile>
10
VMware, Inc.
<pathto.vmxfile>
VProbes Commands (VMwareServerdoesnot supportVProbes.) vprobeVersion vprobeLoad ShowVProbesversion. LoadVProbesscript. DisableallVProbes. ListactiveVProbes. ListVProbesglobalvariables. <pathto.vmxfile> <pathto.vmxfile> <textofVProbesscript> vprobeReset vprobeListProbes vprobeListGlobals <pathto.vmxfile> <pathto.vmxfile> <pathto.vmxfile>
New Examples
StartanXterminalonaLinuxguest(requires-displayoptiontoappearontheconsole):
vmrun -gu <user> -gp <password> runProgramInGuest Ubuntu/Ubuntu.vmx /usr/bin/xterm "-display :0"
ListprocessesinaLinuxguestonWorkstation,andkilltheprocessnumbered20001:
vmrun -T ws -gu guestUser -gp guestPassword listProcessesInGuest Ubuntu/Ubuntu.vmx vmrun -T ws -gu guestUser -gp guestPassword killProcessesInGuest Ubuntu/Ubuntu.vmx 20001
RunabatchscriptonaWindowsguestusingWorkstation:
vmrun -T ws -gu guestUser -gp guestPassword runProgramInGuest WinXP.vmx "C:\Workarea\script.bat"
RunacommandscriptonaWindowsguestusingWorkstation:
vmrun -T ws -gu guestUser -gp guestPassword runProgramInGuest WinXP.vmx C:\Windows\System32\cmd.exe "/c C:\Workarea\script.cmd"
RunaPerlscriptinaLinuxguesttoremoveDOSstylecarriagereturnsfromafile:
vmrun -T ws -gu guestUser -gp guestPassword runScriptInGuest Linux.vmx /usr/bin/perl -pi open(DOS, /tmp/dos.txt); while (<DOS>) { s/\r\n/\n/ ; print <DOS>}
RunaPerlscriptinaWindowsguesttoinsertDOSstylecarriagereturnsintoafile:
vmrun -T ws -gu guestUser -gp guestPasswd runScriptInGuest WinXP.vmx C:\cygwin\bin\perl.exe -pi open(UNIX, C:/Temp/unix.txt); while (<UNIX>) { s/\n/\r\n/ ; print <UNIX>}
VMware, Inc.
11
StopavirtualmachinewithServeronaLinuxhost:
vmrun -T server -h https://myHost.com/sdk -u hostUser -p hostPasswd stop "[storage1] vm/myVM.vmx"
RunaprograminavirtualmachineonaWindowshostwithaWindowsguest:
vmrun -T ws -gu guestUser -gp guestPassword runProgramInGuest "c:\my VMs\myVM.vmx" "c:\Program Files\myProgram.exe"
RunaprograminavirtualmachinewithVMwareServeronaLinuxhostwithaLinuxguest:
vmrun -T server -h https://myHost.com/sdk -u hostUser -p hostPasswd -gu guestUser -gp guestPasswd runProgramInGuest "[storage1] vm/myVM.vmx" /usr/bin/X11/xclock -display :0
CreateasnapshotofavirtualmachinewithVMwareWorkstationonaWindowshost:
vmrun -T ws snapshot "c:\my VMs\myVM.vmx" mySnapshot
ReverttoasnapshotwithVMwareWorkstationonaWindowshost:
vmrun -T ws revertToSnapshot "c:\my VMs\myVM.vmx" mySnapshot
DeleteasnapshotwithVMwareWorkstationonaWindowshost:
vmrun -T ws deleteSnapshot "c:\my VMs\myVM.vmx" mySnapshot C:\Program Files\VMware\VMware Workstation
ResetavirtualmachineonWindows:
vmrun reset C:\Virtual Machines\<virtual_machine_name>.vmx soft
12
VMware, Inc.