vmware vmrun命令简介

来源:互联网 发布:hash 统计海量数据 编辑:程序博客网 时间:2024/06/03 17:58

1、简介

       VMWare提供了vmrun与VIX API两种手段使用户可以通过程序对虚拟机进行控制。vmrun是一种命令行控制的手段,但是可以通过Shell脚本实现连续多个操作的自动化。


2、语法

Usage: vmrun COMMAND [PARAMETERS]
Authentication flags
-gu <userName in guest OS>
-gp <password in guest OS>


POWER COMMANDS           PARAMETERS           DESCRIPTION
start                    Path to vmx file     Start a VM or Team
                         or vmtm file
                         [gui|nogui]
stop                     Path to vmx file     Stop a VM or Team
                         or vmtm file
                         [hard|soft]
reset                    Path to vmx file     Reset a VM or Team
                         or vmtm file
                         [hard|soft]
suspend                  Path to vmx file     Suspend a VM or Team
                         or vmtm file
                         [hard|soft]


SNAPSHOT COMMANDS        PARAMETERS           DESCRIPTION
listSnapshots            Path to vmx file     List all snapshots in a VM
snapshot                 Path to vmx file     Create a snapshot of a VM
                         Snapshot name
deleteSnapshot           Path to vmx file     Remove a snapshot from a VM
                         Snapshot name
revertToSnapshot         Path to vmx file     Set VM state to a snapshot
                         Snapshot name


GUEST OS COMMANDS        PARAMETERS           DESCRIPTION
runProgramInGuest        Path to vmx file     Run a program in Guest OS
                         Program
                         [Program arguments]
fileExistsInGuest        Path to vmx file     Check if a file exists in Guest OS
                         Path to file in guest
setSharedFolderState     Path to vmx file     Modify a Host-Guest shared folder
                         Share name
                         New host path
addSharedFolder          Path to vmx file     Add a Host-Guest shared folder
                         Share name
                         Host path
removeSharedFolder       Path to vmx file     Remove a Host-Guest shared folder
                         Share name
listProcessesInGuest     Path to vmx file     List running processes in Guest OS
killProcessInGuest       Path to vmx file     Kill a process in Guest OS
                         process id
runScriptInGuest         Path to vmx file     Run a script in Guest OS
                         Interpreter path
                         script_text
deleteFileInGuest        Path to vmx file     Delete a file in Guest OS
                         File
createDirectoryInGuest   Path to vmx file     Create a directory in Guest OS
                         Directory path
deleteDirectoryInGuest   Path to vmx file     Delete a directory in Guest OS
                         Directory path
listDirectoryInGuest     Path to vmx file     List a directory in Guest OS
                         Directory path
copyFileFromHostToGuest  Path to vmx file     Copy a file from host OS to guest OS
                         Path on host
                         Path in guest
copyFileFromGuestToHost  Path to vmx file     Copy a file from guest OS to host OS
                         Path in guest
                         Path on host
renameFileInGuest        Path to vmx file     Rename a file in Guest OS
                         Original name
                         New name

GENERAL COMMANDS         PARAMETERS           DESCRIPTION
list                                          List all running VMs
upgradevm                Path to vmx file     Upgrade VM file format, virtual hw
installtools             Path to vmx file     Install Tools in Guest OS


3、示例

        1)开启虚拟机

        vmrun start "/opt/VM_OS/RH_OS_B/Red Hat Enterprise Linux 5 64-bit.vmx" nogui|gui

        2)停止虚拟机

        vmrun stop "/opt/VM_OS/RH_OS_B/Red Hat Enterprise linux 5 64-bit.vmx" nogui|gui

        3)重启虚拟机
        vmrun restart "/opt/VM_OS/RH_OS_B/Red Hat Enterprise Linux 5 64-bit.vmx" nogui|gui

       4)列出正在运行的虚拟机
        vmrun list