Beruflich Dokumente
Kultur Dokumente
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,documentsthevmrunutility,whichhelpsyoumanage thecollectionofvirtualmachinesonaVMwarehost.
Revision History
Thisbookisrevisedwitheachreleaseoftheproductorwhennecessary.Arevisedversioncancontainminor ormajorchanges.Table 1summarizesthesignificantchangesineachversionofthisguide. Table 1. Revision History
Revision 20080623 20080815 Description FirstdraftofthismanualfortheVMwareServer2.0RC1andWorkstation6.5Beta2releases. ThirddraftofthismanualfortheVMwareServer2.0RC2andWorkstation6.5RCreleases.
Intended Audience
Thisbookisintendedfordevelopersandsystemadministratorswhowanttocontrolvirtualmachineson variousplatforms,includingVMwareWorkstationandVMwareServer.
Documentation Resources
ToaccessthecurrentversionsofVMwareAPIandSDKdocumentation,goto: http://www.vmware.com/support/pubs/sdk_pubs.html ToaccessthecurrentversionsofotherVMwaremanuals,goto: http://www.vmware.com/support/pubs
Documentation Feedback
VMwarewelcomesyoursuggestionsforimprovingourdocumentation.Sendyourfeedbackto: docfeedback@vmware.com
Online Support
YoucansubmitquestionsorpostcommentstotheDeveloperCommunitySDKsandAPIsforum,whichis monitoredbyVMwaretechnicalsupportandproductteams.Toaccesstheforum,goto: http://communities.vmware.com/community/developer
VMware, Inc.
Support Offerings
TofindouthowVMwaresupportofferingscanhelpmeetyourbusinessneeds,goto: http://www.vmware.com/support/services
VMware, Inc.
Power Commands
Virtualmachinepoweroperationsgiveyoutheseoptions:start(poweron),stop(poweroff),reset(reboot), suspend(butallowlocalworktoresume),pause(withoutinterrupting),andunpause(continue). Onsomeproducts,youcangroupvirtualmachinesintoteams,andapplypoweroperationstothewholeteam.
Snapshot Commands
Asnapshotcapturesthestateofavirtualmachineatthetimeofthesnapshot,includingalldataonvirtual disks.Youcantakeasnapshotofavirtualmachineinanypowerstateandreverttothesnapshotatanytime. Snapshotsareusefulforexperimentationandespeciallyusefulforbackups. Thesecommandslistexistingsnapshotsofavirtualmachine,createanewsnapshot,deleteasnapshot,and revertavirtualmachinetoitsstateasofaspecificsnapshot.VMwareServerlimitsyoutoonesnapshot.
VMware, Inc.
Maintenance Commands
Thiscategoryincludescommandstolistallrunningvirtualmachines,upgradethevirtualmachinehardware version,andinstallVMwareToolsintheguestoperatingsystem. Additionally,exceptonVMwareServer,youcancloneanyvirtualmachineimagetoanothervirtualmachine. VMwareServerallowsyoutoregisterandunregistervirtualmachines.
VProbes Commands
YoucanusevmruntoscriptVProbes,afacilityfortransparentlyinstrumentingapoweredonguestoperating system,itsrunningprocesses,andvirtualizationsoftware.SeetheVProbesProgrammingReferencefordetails.
3 4
Inacommandwindow,typevmruntoseecommandlineoptions. ContinuewithFlagstoSpecifyVirtualMachineTypeonpage 7.
2 3
Inacommandorterminalwindow,typevmruntoseecommandlineoptions. ContinuewithFlagstoSpecifyVirtualMachineTypeonpage 7.
VMware, Inc.
TosetthehosttypeforremoteaccesstoVMwareServer2.0,usethefollowingflags:
-T -h -P -u -p server https://<hostName or IPaddr>/sdk <portNumber> <adminLogin on VMware Server> <adminPassword on VMware Server>
ForVMwareWorkstation,usethe-Tflagasfollows:
vmrun -T ws
ForVMwareServer1.0,usethe-Tflagasfollows:
vmrun -T server1
VMwareWorkstationforWindowspath:
C:\Documents and Settings\<username>\My Documents\My Virtual Machines\Win XP\Win XP.vmx
VMwareWorkstationforLinuxpath:
/home/<username>/VirtualMachines/Ubuntu/Ubuntu.vmx
VMware, Inc.
VMware, Inc.
Guest Operating System Commands runProgramInGuest Runsaprogramintheguestoperatingsystem. The-noWaitoptionreturnsapromptimmediatelyafter theprogramstartsintheguest,ratherthanwaitingforit tofinish.Thisoptionisusefulforinteractiveprograms. The-activeWindowoptionensuresthattheWindows GUIisvisible,notminimized.IthasnoeffectonLinux. The-interactiveoptionforcesinteractiveguestlogin. ItisusefulforWindowsVistagueststomakethe programvisibleintheconsolewindow. Providethefullpathnameofaprogramaccessibletothe guest.VMwareToolsandvalidguestloginarerequired. Alsoprovidefullaccessiblepathnamesforanyfiles specifiedintheprogramarguments,whichareoptional accordingtorequirementsofthenamedprogram. runScriptInGuest Runsacommandscriptintheguestoperatingsystem. VMwareToolsandavalidguestloginarerequired. Theinterpreterpathisthecommandthatrunsthescript. Providethecompletetextofthescript,notafilename. setSharedFolderState (VMwareServerdoesnot supportsharedfolders.) Modifiesthewritabilitystateofafoldersharedbetween thehostandaguestvirtualmachine(.vmxfile). Thesharenameisamountpointintheguestfilesystem. Thepathtofolderistheexporteddirectoryonthehost. Asharedfoldercanbemadewritableorreadonly. Addsafoldertobesharedbetweenthehostandguest. Thesharenameisamountpointintheguestfilesystem. Thepathtofolderistheexporteddirectoryonthehost. <pathto.vmxfile> <interpreterpath> <scripttext> <pathto.vmxfile> <sharename> <pathtofolderonhost> writable |readonly <pathto.vmxfile> <sharename> <pathtofolderonhost> <pathto.vmxfile> [-noWait | -activeWindow | -interactive ] <programname> [<programarguments>]
VMware, Inc.
killProcessInGuest
<pathto.vmxfile> <processID>
deleteFileInGuest
renameFileInGuest
deleteDirectoryInGuest
listDirectoryInGuest
copyFileFromHostToGuest
readVariable
10
VMware, Inc.
<pathto.vmxfile>
<pathto.vmxfile>
VProbes Commands (VMwareServerdoesnot supportVProbes.) vprobeVersion vprobeLoad ShowstheVProbesversiononthevirtualmachine. LoadstheVProbesscriptonthevirtualmachine. DisablesallVProbesonthevirtualmachine. ListstheactiveVProbesonthevirtualmachine. ListsVProbesglobalvariablesonthevirtualmachine. <pathto.vmxfile> <pathto.vmxfile> <textofVProbesscript> vprobeReset vprobeListProbes vprobeListGlobals <pathto.vmxfile> <pathto.vmxfile> <pathto.vmxfile>
Reboot Commands
RebootavirtualmachinerunningonVMwareWorkstationforLinux:
vmrun -T ws reset /path/to/vm/RHEL4/RHEL4.vmx soft
RebootavirtualmachinerunningonVMwareWorkstationforWindows:
cd "C:\Documents and Settings\<user>\My Documents\My Virtual Machines" vmrun -T ws reset "WindowsXP\WindowsXP.vmx" soft
VMware, Inc.
11
RebootavirtualmachinerunningonVMwareServer:
vmrun -T server -h https://10.0.1.8/sdk -u root -p <pass> reset "[storage1] WinXP/WinXP.vmx" soft
Power Commands
PoweronavirtualmachinewithVMwareWorkstationonaWindowshost:
vmrun start "C:\Documents and Settings\<user>\My Documents\My Virtual Machines\WinXP\WinXP.vmx"
ThiserrormessageindicatesthattheinstalledVIXpackagedoesnotsupportVMwareServer:
vmrun -T server start "My Virtual Machines\WinXP\WinXP.vmx" Error: The specified service provider was not found
PoweroffavirtualmachinewithVMwareWorkstationonaWindowshost:
vmrun stop "C:\Documents and Settings\<user>\My Documents\My Virtual Machines\WinXP\WinXP.vmx"
UsingVIXtocontrolaVMwareServerwithIPaddress10.0.1.8,poweronavirtualmachine:
vmrun -T server -h https://10.0.1.8/sdk -u root -p <pass> start "[storage1] WinXP/WinXP.vmx"
IfHTTPSserviceisnotconfiguredonport443,specifytheappropriateportafteracolonseparator:
vmrun -T server -h https://10.0.1.9:8333/sdk -u root -p <pass> start "[storage1] WinXP/WinXP.vmx"
UsingVIXtocontrolaVMwareServerwithIPaddress10.0.1.8,poweroffthevirtualmachine:
vmrun -T server -h https://10.0.1.8/sdk -u root -p <pass> start "[storage1] WinXP/WinXP.vmx"
ForVMwareServerinstalledonWindowshosts,the-uuserisusuallyAdministrator,notroot.
Snapshot Commands
CreateasnapshotofavirtualmachinewithVMwareWorkstationonaLinuxhost:
vmrun -T ws snapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot
Listsnapshotsonthevirtualmachine,showingtheonejustmade:
vmrun -T ws listSnapshots /path/to/vm/Ubuntu/Ubuntu.vmx Total snapshots: 1 mySnapshot
Reverttothesnapshotjustmade,whichsuspendsthevirtualmachine,andresumeoperation:
vmrun -T ws revertToSnapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot vmrun -T ws start /path/to/vm/Ubuntu/Ubuntu.vmx
Deletethesnapshot,specifyingitbyname:
vmrun -T ws deleteSnapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot
Whenyoustoprecording,theuserinterfacemightaskyoutonameyoursession:
vmrun -T ws -gu <user> -gp <pass> endRecording WinXP\WinXP.vmx
Reverttothevirtualmachinesnapshotandstartreplayingyourrecordingofuserevents:
vmrun -T ws -gu <user> -gp <pass> beginReplay WinXP\WinXP.vmx session1
Pausereplay,whichyoucanalsodofromtheuserinterface:
vmrun -T ws -gu <user> -gp <pass> pause WinXP\WinXP.vmx
Resumereplay,whichyoucanalsodofromtheuserinterface:
vmrun -T ws -gu <user> -gp <pass> unpause WinXP\WinXP.vmx
12
VMware, Inc.
Endreplay,whichyoucanalsodofromtheuserinterface:
vmrun -T ws -gu <user> -gp <pass> endReplay WinXP\WinXP.vmx
StartthecommandtoolonaWindowsguest,asanactivewindowonthedesktop:
vmrun -T ws -gu <user> -gp <pass> runProgramInGuest WinXP\WinXP.vmx -activeWindow cmd.exe
RunabatchscriptonaWindowsguest,usingcmd.exe/casacommandinterpreter:
vmrun -T ws -gu <user> -gp <pass> runProgramInGuest WinXP\WinXP.vmx cmd.exe "/c C:\runit.bat"
WithVMwareWorkstation,runaBashshellscriptonaLinuxguest:
vmrun -T ws -gu <user> -gp <pass> runScriptInGuest Ubuntu/Ubuntu.vmx /bin/bash /home/<user>/runit
StartanXclockonaLinuxguest(requires-displayoptiontoappearontheconsole):
vmrun -T ws -gu <user> -gp <pass> runProgramInGuest Ubuntu/Ubuntu.vmx /usr/bin/xclock -display :0
Sameasabove,butimmediatelyreturntocommandlinecontrol:
vmrun -T ws -gu <user> -gp <pass> runProgramInGuest Ubuntu/Ubuntu.vmx -noWait /usr/bin/xclock -display :0
ListprocessesinaLinuxguest,andkilltheprocessnumbered8192:
vmrun -T ws -gu <user> -gp <pass> listProcessesInGuest Ubuntu/Ubuntu.vmx vmrun -T ws -gu <user> -gp <pass> killProcessesInGuest Ubuntu/Ubuntu.vmx 8192
RunaprograminaLinuxvirtualmachineonVMwareServer:
vmrun -T server -h https://10.0.1.8/sdk -u root -p <pass> -gu <user> -gp <userpass> runProgramInGuest "[storage1] RHEL4/RHEL4.vmx" /usr/X11R6/bin/xclock -display :0
RunaPerlscriptonaLinuxguesttoremoveDOSstylecarriagereturnsfromafile:
vmrun -T ws -gu <user> -gp <pass> runProgramInGuest Ubuntu/Ubuntu.vmx /usr/bin/perl -e "open(FILE, '>/tmp/unix.txt'); while (<>) { s/\r\n/\n/ ; print FILE}" /tmp/dos.txt
RunaPerlscriptonaWindowsguesttoinsertDOSstylecarriagereturnsintoafile:
vmrun -T ws -gu <user> -gp <pass> runProgramInGuest WinXP\WinXP.vmx C:\cygwin\bin\perl.exe -e "open(FILE, >C:\dos.txt); while (<>) { s/\n/\r\n/ ; print FILE}" C:\unix.txt
Tocopyanarbitraryfilefromaguesttothehost,theusermusthavereadpermissiononthesourcefile:
vmrun -gu <user> -gp <pass> copyFileFromGuestToHost Ubuntu\Ubuntu.vmx /home/<user>/addr addr.txt
Beforeusingsharedfolders,youmustenablethembyselectingVM>Settings>Options>SharedFolders> Enabledintheuserinterface.ToshareafolderonaWindowshostwithaparticularLinuxguest:
vmrun -T ws addSharedFolder Ubuntu\Ubuntu.vmx /mnt/hgfs/Share C:\Share
Sharedfoldersarewritablebydefault.Tomakeasharedfolderreadonly:
vmrun -T ws setSharedFolderState Ubuntu\Ubuntu.vmx /mnt/hgfs/Share C:\Share readonly
Tostopsharingthefolder:
vmrun -T ws removeSharedFolder Ubuntu\Ubuntu.vmx /mnt/hgfs/Share
VMware, Inc.
13
Maintenance Commands
ListrunningvirtualmachinesonVMwareWorkstation:
vmrun -T ws list Total running VMs: 2 C:\Documents and Settings\user\My Documents\My Virtual Machines\Ubuntu\Ubuntu.vmx C:\Documents and Settings\user\My Documents\My Virtual Machines\WinXP\WinXP.vmx
RegisteranewvirtualmachineinstalledonVMwareServer:
vmrun -T server -h https://10.0.1.8/sdk -u root -p <pass> register "[storage1] RHEL5/RHEL5.vmx"
UnregisteranoldvirtualmachinegoingoutofserviceonVMwareServer:
vmrun -T server -h https://10.0.1.8/sdk -u root -p <pass> unregister "[storage1] RHEL3/RHEL3.vmx"
14
VMware, Inc.