vmware开机自启

Posted on Posted in virtualization, windows
Tips: 本文创建于2013年11月27日,已超过 2 年,内容或图片可能已经失效!

前几天有同学公司那有个特殊的需求,一台机器上要安装两个独立linux系统,而且必须开机同时运行,就是类似于安装双系统后,可以同时运行xp和window7一样。

我在谷歌上确实搜到了一点蛛丝马迹(朱时茂,陈佩斯,马季……),但感觉配起来太麻烦,所以没有继续。 想到的最简单的方案就是机器上安装vmware,再跑一个系统,就OK了。

但有个问题,开机自启怎么实现? linux的虚拟化可以实现linux系统里再跑一个系统,并且开机自启。

下面说的是windows下的,安装就不说了。 vmware的安装目录下有个vmrun.exe文件,利用这个文件我们可以实现开机自启。vmrun命令

### dos到vmrun的文件夹,或者添加到环境变量  
### 开启Debian 7 64 位.vmx虚拟机,分号里是虚拟机文件  
vmrun -T ws start "D:\Program Files (x86)\VMware\Virtual Machines\Debian 7 64 位\Debian 7 64 位.vmx" nogui # 无图形界面,后台运行
### 关闭Debian 7 64 位.vmx虚拟机  
vmrun -T ws stop "D:\Program Files (x86)\VMware\Virtual Machines\Debian 7 64 位\Debian 7 64 位.vmx"  
### 挂起  
vmrun -T ws suspend "D:\Program Files (x86)\VMware\Virtual Machines\Debian 7 64 位\Debian 7 64 位.vmx"  
### 暂停  
vmrun -T ws pause "D:\Program Files (x86)\VMware\Virtual Machines\Debian 7 64 位\Debian 7 64 位.vmx"  
### 取消暂停  
vmrun -T ws unpause "D:\Program Files (x86)\VMware\Virtual Machines\Debian 7 64 位\Debian 7 64 位.vmx"  

还有个参数,reset,这个和虚拟机的重置是一样的,但是我不知道这个重置是什么意思,按了重置之后重启了,也没看见重置什么,自己也没用过

暂停这个也不常用,效果如图

pause.png

把命令写入到bat文件,放到开机自启里就OK了,实现开机自启。 下面是vmrun的说明文档

Invalid argument: --help  
  
vmrun version 1.13.1 build-1379776  
  
Usage: vmrun [AUTHENTICATION-FLAGS] COMMAND [PARAMETERS]  
  
AUTHENTICATION-FLAGS  
  
--------------------  
  
These must appear before the command and any command parameters.  
  
-h <hostName> (not needed for Workstation)  
  
-P <hostPort> (not needed for Workstation)  
  
-T <hostType> (ws|server|server1|fusion|esx|vc|player)  
  
for example, use '-T server' for Server 2.0  
  
use '-T server1' for Server 1.0  
  
use '-T ws' for VMware Workstation  
  
use '-T ws-shared' for VMware Workstation (shared mode)  
  
use '-T esx' for VMware ESX  
  
use '-T vc' for VMware vCenter Server  
  
-u <userName in host OS> (not needed for Workstation)  
  
-p <password in host OS> (not needed for Workstation)  
  
-vp <password for encrypted virtual machine>  
  
-gu <userName in guest OS>  
  
-gp <password in guest OS>  
  
POWER COMMANDS PARAMETERS DESCRIPTION  
  
-------------- ---------- -----------  
  
start Path to vmx file Start a VM or Team  
  
[gui|nogui]  
  
stop Path to vmx file Stop a VM or Team  
  
[hard|soft]  
  
reset Path to vmx file Reset a VM or Team  
  
[hard|soft]  
  
suspend Path to vmx file Suspend a VM or Team  
  
[hard|soft]  
  
pause Path to vmx file Pause a VM  
  
unpause Path to vmx file Unpause a VM  
  
SNAPSHOT COMMANDS PARAMETERS DESCRIPTION  
  
----------------- ---------- -----------  
  
listSnapshots Path to vmx file List all snapshots in a VM  
  
[showTree]  
  
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  
  
[andDeleteChildren]  
  
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  
  
[-noWait]  
  
[-activeWindow]  
  
[-interactive]  
  
Complete-Path-To-Program  
  
[Program arguments]  
  
fileExistsInGuest Path to vmx file Check if a file exists in Guest OS  
  
Path to file in guest  
  
directoryExistsInGuest Path to vmx file Check if a directory exists in Guest OS  
  
Path to directory in guest  
  
setSharedFolderState Path to vmx file Modify a Host-Guest shared folder  
  
Share name  
  
Host path  
  
writable | readonly  
  
addSharedFolder Path to vmx file Add a Host-Guest shared folder  
  
Share name  
  
New host path  
  
removeSharedFolder Path to vmx file Remove a Host-Guest shared folder  
  
Share name  
  
enableSharedFolders Path to vmx file Enable shared folders in Guest  
  
[runtime]  
  
disableSharedFolders Path to vmx file Disable shared folders in Guest  
  
[runtime]  
  
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  
  
[-noWait]  
  
[-activeWindow]  
  
[-interactive]  
  
Interpreter path  
  
Script text  
  
deleteFileInGuest Path to vmx file Delete a file in Guest OS  
  
Path in guest  
  
createDirectoryInGuest Path to vmx file Create a directory in Guest OS  
  
Directory path in guest  
  
deleteDirectoryInGuest Path to vmx file Delete a directory in Guest OS  
  
Directory path in guest  
  
CreateTempfileInGuest Path to vmx file Create a temporary file in Guest OS  
  
listDirectoryInGuest Path to vmx file List a directory in Guest OS  
  
Directory path in guest  
  
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  
  
captureScreen Path to vmx file Capture the screen of the VM to a local file  
  
Path on host  
  
writeVariable Path to vmx file Write a variable in the VM state  
  
[runtimeConfig|guestEnv|guestVar]  
  
variable name  
  
variable value  
  
readVariable Path to vmx file Read a variable in the VM state  
  
[runtimeConfig|guestEnv|guestVar]  
  
variable name  
  
getGuestIPAddress Path to vmx file Gets the IP address of the guest  
  
[-wait]  
  
VPROBE COMMANDS PARAMETERS DESCRIPTION  
  
--------------- ---------- -----------  
  
vprobeVersion Path to vmx file List VP version  
  
vprobeLoad Path to vmx file Load VP script  
  
'VP script text'  
  
vprobeLoadFile Path to vmx file Load VP file  
  
Path to VP file  
  
vprobeReset Path to vmx file Disable all vprobes  
  
vprobeListProbes Path to vmx file List probes  
  
vprobeListGlobals Path to vmx file List global variables  
  
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  
  
checkToolsState Path to vmx file Check the current Tools state  
  
register Path to vmx file Register a VM  
  
unregister Path to vmx file Unregister a VM  
  
listRegisteredVM List registered VMs  
  
deleteVM Path to vmx file Delete a VM  
  
clone Path to vmx file Create a copy of the VM  
  
Path to destination vmx file  
  
full|linked  
  
[-snapshot=Snapshot Name]  
  
[-cloneName=Name]  
  
Examples:  
  
Starting a virtual machine with Workstation on a Windows host  
  
vmrun -T ws start "c:\my VMs\myVM.vmx"  
  
Stopping a virtual machine on an ESX host  
  
vmrun -T esx -h https://myHost.com/sdk -u hostUser -p hostPassword stop "[storage1] vm/myVM.vmx"  
  
Running a program in a virtual machine with Workstation on a Windows host with Windows guest  
  
vmrun -T ws -gu guestUser -gp guestPassword runProgramInGuest "c:\my VMs\myVM.vmx" "c:\Program Files\myProgram.exe"  
  
Running a program in a virtual machine with Server on a Linux host with Linux guest  
  
vmrun -T server -h https://myHost.com:8333/sdk -u hostUser -p hostPassword -gu guestUser -gp guestPassword runProgramInGuest "[standard] vm/myVM.vmx" /usr/bin/X11/xclock -display :0  
  
Creating a snapshot of a virtual machine with Workstation on a Windows host  
  
vmrun -T ws snapshot "c:\my VMs\myVM.vmx" mySnapshot  
  
Reverting to a snapshot with Workstation on a Windows host  
  
vmrun -T ws revertToSnapshot "c:\my VMs\myVM.vmx" mySnapshot  
  
Deleting a snapshot with Workstation on a Windows host  
  
vmrun -T ws deleteSnapshot "c:\my VMs\myVM.vmx" mySnapshot  
  
Enabling Shared Folders with Workstation on a Windows host  
  
vmrun -T ws enableSharedFolders "c:\my VMs\myVM.vmx"  
» 转载请注明来源:呢喃 » vmware开机自启