Thursday, June 7, 2007

Virtual machine on your flash drive

Today we'll discuss deployment of virtual machine on generic flash drive. Of course, there’s nothing difficult to copy virtual machine files to flash drive and then open .vmx file and start virtual machine, but I’ll try to “do it right way” and automate process of launching machine as much as possible.

Everybody knows about Windows “autorun” feature. That’s exactly what we need! To enable autorun behavior we should place file named autorun.inf to the root directory of flash drive. Let’s find out exact content of this file for our purposes. Starting from simple things: let’s change default drive icon to virtual machine one. All we need is a config.ico file from VMware installation and one line in .inf file. Copy config.ico to the root folder of flash drive and rename it to config.icon (otherwise Windows will suspect graphical media content on flash drive and may be will prompt to view it). Hence the first line of our file is:

[autorun]
icon=config.icon

Second step is a new drive label. I’ll install Ubuntu on my flash drive, so the new file line is:

[autorun]
icon=config.icon
label=Ubuntu


The main thing: how to launch virtual machine? Open command does not work, but shellexecute is a thing we need. Simply type shellexecute=ubuntu.vmx – this will launch installed virtualization software.

Looks pretty good, but there are small problems here:

1) Workstation does’not run virtual machine, it just opens vmx file (-X command line parameters solves this)

2) Player 2.0 does not understand gui.fullScreenAtPowerOn = "TRUE" vmx entry anymore, so we can’t just launch virtual machine in full screen.

I wrote a small application called vmlauncher that detects installed virtualization software and launches it appropriately. It also configures shared folder from the host’s My Documents folder. If no virtualization software detected, vmlauncher offers to install VMware Player (distributive should be placed on the same flash drive in “VMware\VMware Player” folder).

The final autorun.inf content:

[autorun]
icon=config.icon
label=Ubuntu
shellexecute=vmlauncher.exe .\ubuntu\ubuntu.vmx
UseAutoPLAY=1

Plus vmlauncher.exe in the flash drive’s root directory.

10 comments:

Anonymous said...

Hy Oleg, how do you configure the Shared Folders? Have you found out how the hash stored in the preferences.ini is calculated?
A short test with the Player 2.0 didn't configure any shared folders...

Oleg said...

I just make changes to .vmx file. If Shared Folders are disabled in Player, User still have to manually enable SF through VMware Player/Shared Folders menu. Currently I don't know how to enable SF using preferences.ini (if it's possible).

Manlio Frizzi said...

Hi Oleg,
I'm writing you to exchange blog links. I would like to link your blog to mine virtualaleph.blogspot.com

If you like to do the same I'll appreciate it very much.

thank you

cheers

Manlio

Oleg said...

Hi Manilo!
I've made a link to your blog.

Oleg.

Anonymous said...

Hello
how can I contact you for a "custom" version of vmlauncher?
Thank you
Fabio

Oleg said...

Hi Fabio.
Sorry for delayed reply - I had a vacation. Please contact me via oleg.monakhov at gmail.com

Anonymous said...

The link for vmlauncher.exe does not work. I tried this http://www.vmunit.com/vmlauncher.exe and it worked.

Greg

Oleg said...

I've fixed donwload link. Thanks!

Todaydownload.com said...

Resources like the one you mentioned here will be very useful to me ! I will post a
link to this page on my blog. I am sure my visitors will find that very useful
VMware Player

Jacek Bogucki said...

vmlauncher.exe cannot be found :( ..and this tool looks really promising for me..