Showing posts with label VMware Fusion 3 headless Mac OSX virtual machine vmx vmrun. Show all posts
Showing posts with label VMware Fusion 3 headless Mac OSX virtual machine vmx vmrun. Show all posts

Sunday, December 6, 2009

VMware Fusion 3 headless

VMware fusion has been out for a while now and I have just gotten round to trying to run a headless LAMP with client only networking for web development. Shock horror, the headless hack no longer works in Fusion 3, all is not lost. There is a little used tool introduced in Fusion 2 that most power users from the linux and windows community have been aware of for a long time. The command line vmrun is hidden away in /Library/Application Support/VMware Fusion/ directory. With a little digging one soon realizes the power of this tool to interact with virtual machines from the command line. It is now very easy to launch and run a virtual machine from the command line and interact with it in a variety of ways. I am going to give a brief tutorial on how to launch a headless virtual machine from the command line or a shell script. Remember to replace the USERNAME with your own username or the command will not work!! I have assumed that you have used headless mode before if not please refer to the full post on using the vmrun command.

1. You may or may not want to add the location of vmrun to your default path. I chose not to as I will mostly be interacting with vmrun through shell scripts.

2. To Launch the virtual machine named VA-LAMP.vmx which is located in the standard virtual machine directory enter the following command into the Terminal app.

/Library/Application\ Support/VMware\ Fusion/vmrun -T fusion start /Users/USERNAME/Documents/Virtual\ Machines.localized/VA-LAMP.vmwarevm/VA-LAMP.vmx nogui

To make this a command to launch the headless terminal from a file on the desktop just open text edit and enter the following text

#!/bin/bash
/Library/Application\ Support/VMware\ Fusion/vmrun -T fusion start /Users/USERNAME/Documents/Virtual\ Machines.localized/VA-LAMP.vmwarevm/VA-LAMP.vmx nogui

Save the file as plain text to the desktop as headless.command

Now to make it executable fire up the terminal application and type

chmod +x $HOME/Desktop/headless.command

Congratulations! You can now run headless again!