Linux.com

Feature

How to use VMware Player to create your own images

By Joe 'Zonker' Brockmeier on June 14, 2006 (8:00:00 AM)

Share    Print    Comments   

A few months ago, VMware released a free version of its desktop virtualization software, VMware Player. It's a great application for running a second operating system on your desktop; the only problem is you can't create new virtual images using VMware Player. With a little work, however, you can use VMware Player to create guest operating systems.

The easiest way to get a virtual image is to have someone with VMware Workstation create one for you, or to download a pre-made image from VMware. If you don't know anyone with a copy of Workstation, or the OS you want isn't available as a VMware appliance, you're out of luck. For example, if you want to test a development release of Ubuntu or Debian, it's unlikely that you'll find a VMware image available.

If you plan to make extensive use of VMware -- i.e., if you need to run more than a single OS, if it's for your work, or if you're doing more than just tinkering for fun -- go ahead and buy a copy of VMware Workstation. It's much easier to use VMware Workstation to create virtual machines than to do it manually. Also, Workstation has a number of features you won't find in VMware Player, such as the ability to take snapshots of the guest OS, take movies of the virtual machine, and use virtual SMP.

But VMware Player will get the job done if you just want to run a virtual host under Linux or Windows. You can also modify your virtual machines for VMware Workstation using the tips here for VMware Player, but you should be able to do most if not all of this through the VMware Workstation GUI. I'll walk through the process of creating a guest OS on Linux; this should also work under Windows, but you may need to change things such as pathnames.

Getting started

The easy way to do this is to grab a VMware appliance from the VMware site, and then make a few modifications. I'll use the Gentoo appliance for this example.

Download the appliance and unzip it into the ~/vmware directory. Under the Gentoo directory, you'll find a file called Gentoo.vmx; if you've chosen another virtual image, look for its .vmx file. This is the configuration file used by VMware to hold information about the virtual environment. It specifies the location of the disk image, the amount of RAM, and so on.

Look for the lines ide1:0.fileName and ide1:0.deviceType. If you want to install a new guest OS from a CD-ROM or DVD, the defaults are fine. If you'd like to use an ISO image instead of a CD-ROM, however, you'll need to tweak this a bit. To use an ISO image, change the fileName and deviceType lines to this:

ide1:0.fileName = "/path/to/cd.iso"
ide1:0.deviceType = "cdrom-image"

Once that's done, fire up VMware Player. However, instead of letting it boot into the virtual machine, press Esc when you see the screen in Figure 1. VMware will give you the option of booting from the hard disk or booting from other devices. Select the CD-ROM drive from the boot menu instead of the hard drive. You should be able to move through your installation normally after that.

By the way -- and this is one of my favorite features of VMware Workstation -- you can download an ISO for a Linux distro and try it out in VMware without even having to take the time to burn it to CD. This feature has helped me avoid wasting a lot of CD-Rs.

Creating your own virtual image from scratch

Modifying an existing guest OS is pretty easy, but it has its drawbacks. For one thing, you can't specify the size of the virtual disk -- you're stuck with whatever size the virtual image had when it was created. The VMware site doesn't actually specify what the size of the virtual images is, so you might have to download several to find one the size that you like.

Also, most if not all of the virtual images I've seen use virtual SCSI hard drives rather than IDE. Some operating systems don't like SCSI and won't detect the disk. So, if you want to use an IDE disk, or just want to specify the size of the disk, you'll have to create a guest disk image without using VMware's tools.

To do this, you'll need to have Qemu installed. Specifically, you'll need the qemu-img program that creates disk images for Qemu. This handy application writes disk images in several formats, including VMware's. To create a disk image, run qemu-img create -f vmdk imagename.vmdk nG, where n is the size of the disk image you want to create. Note that the size of the disk image is the size it can eventually grow to -- not the size it will be when it's first created. So, if you create a 20G image, it will only occupy about 3MB on disk without any data.

Once you've created the image, you'll need to modify the configuration file to tell VMware Player about it. First, comment out all the lines that begin with scsi0, because the Qemu disk will be seen by VMware Player as an IDE disk. Then add two new entries to the configuration:

ide0:0.present = "TRUE"
ide0:0.fileName = "filename.vmdk"

Note that you don't need to include the full path if the file is in the same directory as the configuration file.

If you use qemu-img to create your hard disk, you don't really even need to download a virtual guest at all -- you'll just need a sample configuration and a virtual disk. You can use the following as a template to get started:

#!/usr/bin/vmware
config.version = "8"
virtualHW.version = "4"
memsize = "256"
ide0:0.present = "TRUE"
ide0:0.fileName = "newvm.vmdk"
ide1:0.present = "TRUE"
ide1:0.fileName = "/path/to/iso"
ide1:0.deviceType = "cdrom-image"
floppy0.fileName = "/dev/fd0"
ethernet0.present = "TRUE"
usb.present = "TRUE"
sound.present = "TRUE"
sound.virtualDev = "es1371"
displayuName = "Test Machine"
guestOS = "otherlinux"

scsi0:0.redo = ""
ethernet0.addressType = "generated"

displayName = "DisplayName"

checkpoint.vmState = "test.vmss"

ide0:0.redo = ""

I'm not sure how much difference it makes, but you may also want to tell VMware Player what type of guest OS you'll be installing. Look for the line guestOS and change it to whatever OS you're going to install. I found a full list of supported OSes on a site called Forever For Now. The site also hosts some SCSI and IDE guest images, which is a quick way to get started if you don't want to install Qemu.

One of the things that I've added to the configuration that you might not find in many of the guests you can download is the information to add a soundcard via the sound.virtualDev and sound.present directives. I don't usually need a soundcard for testing server operating systems like CentOS, but it comes in handy if you want to use a desktop OS in VMware Player.

Virtual floppy

Another thing you might want to do is to change floppy.fileName. I haven't had a diskette drive on my main systems for quite a few years, and it gets annoying to have VMware complain about the missing floppy each time you restart the virtual machine. To silence it, add this to the configuration:

floppy0.startConnected = "FALSE"

If for some reason you don't have a floppy drive on the computer but want to use a floppy inside the virtual machine, you could try this instead:

floppy0.startConnected = "TRUE"
floppy0.fileName = "/path/to/floppy.img"

This might be useful if you wanted to use a diskette image rather than an ISO image to boot your system -- if you were installing OpenBSD, for example.

Multiple network interfaces

If you want to use multiple network interfaces, rather than adding virtual interfaces inside the OS, you can add a second (and possibly third, fourth, etc. -- I've only tried working with two) Ethernet interface by adding this line:

Ethernet1.present = "TRUE"

You might notice that the .vmx file includes a couple of other lines related to the first Ethernet device:

ethernet0.addressType = "generated"
ethernet0.generatedAddress = "00:0c:29:03:31:3d"
ethernet0.generatedAddressOffset = "0"

You don't have to worry about those -- simply start up VMware player and it will add those lines the first time it sees the Ethernet1 device.

That's really all there is to it. You can tinker a little bit with the configuration to add more hard disks if you need to, but this should be enough to get going with just about any OS you'd want to run.

Again, if you're going to be using VMware extensively, I strongly recommend buying VMware Workstation rather than using this method to create new virtual machines. But, if you just need to run a virtual guest for a one-off project, this is a good way to get a guest OS up and running with VMware Player.

Share    Print    Comments   

Comments

on How to use VMware Player to create your own images

Note: Comments are owned by the poster. We are not responsible for their content.

Why go through all this?

Posted by: Anonymous Coward on June 15, 2006 04:10 AM
Why go through all this fuss when VMware Server is free (as in beer)? I've been using it on my workstation successfully for weeks.

#

Re: VMWare Server

Posted by: Anonymous Coward on June 15, 2006 12:30 PM
I have also been using VMWare Server, which is just as free as VMWare Player. No reason to manally hack the config files, when the more capable app is free.

One interesting feature that I haven't seen before is that you can connect to the virtual machine over the network. It's kind of like combining qemu and vnc into one product.

#

You can use Qemu to do the same things.

Posted by: Anonymous Coward on June 15, 2006 06:40 AM
You can use <a href="http://fabrice.bellard.free.fr/qemu/" title="bellard.free.fr">Qemu</a bellard.free.fr> to do the same things.

Jade @ <a href="http://linux.coconia.net/" title="coconia.net">http://linux.coconia.net/</a coconia.net>

#

Opps. Should have read the whole article,...

Posted by: Anonymous Coward on June 15, 2006 06:44 AM
Opps. Should have read the whole article before commenting.

#

Why go through all this?

Posted by: Anonymous Coward on June 15, 2006 06:43 AM
Why go through all this fuss when <a href="http://fabrice.bellard.free.fr/qemu/" title="bellard.free.fr">QEMU</a bellard.free.fr> is free (as in freedom)? I've been using it on my desktop successfully for years.

Quick start:

Install QEMU:
# aptitude install qemu
# emerge qemu
# yum install qemu
# cd<nobr> <wbr></nobr>/usr/pkgsrc/emulators/qemu && make install clean clean-depends

Create a hard disk image (900MB):
$ dd if=/dev/zero of=img bs=1M count=900

Install the operating system:
$ qemu -cdrom install.iso -hda img -boot d

Run the operating system:
$ qemu -hda img -net user -net nic

There are, of course, more options (copy-on-write disk images, networking, saving and loading VM state, serial console,<nobr> <wbr></nobr>...); see the <a href="http://fabrice.bellard.free.fr/qemu/qemu-doc.html" title="bellard.free.fr">documentation</a bellard.free.fr> for details.

If QEMU isn't fast enough, there's an optional proprietary accelerator: <a href="http://fabrice.bellard.free.fr/qemu/qemu-accel.html" title="bellard.free.fr">kqemu</a bellard.free.fr>

and a free one: <a href="http://savannah.nongnu.org/projects/qvm86/" title="nongnu.org">qvm86</a nongnu.org>

#

Just use the program dd.

Posted by: Anonymous Coward on June 15, 2006 07:02 AM
If you just want a Qemu/VMWare image, simply use the program dd to copy a partition (say Windows on<nobr> <wbr></nobr>/dev/hda1) to a file (say image-file)

dd if=/dev/hda1 of=image-file bs=1M

Although this "works" you may run into problems with the NT boot sector having the wrong initial data (see eg

<a href="http://linux.coconia.net/copyingXP.htm" title="coconia.net">http://linux.coconia.net/copyingXP.htm</a coconia.net>

) and all your drivers will need to be reinstalled for Qemu/VMWare's choice of hardware.

Jade.

#

Re:Just use the program dd.

Posted by: Anonymous Coward on June 15, 2006 04:30 PM
vmware does not recognize images made this way. you'd still have to use qemu-img to convert the image made with 'dd' to a *.vmdk file.

#

I stopped using vmware.

Posted by: Anonymous Coward on June 16, 2006 08:26 AM
"vmware does not recognize images made this way."

Maybe. But Qemu does. And Qemu is as good as vmware anyway (I haven't used vmware for a couple of years now -- I stopped using it when I found qemu (although I still have the vmware program around somewhere)).

#

Re:I stopped using vmware.

Posted by: Anonymous Coward on June 16, 2006 08:37 AM
"And Qemu is as good as vmware anyway (I haven't used vmware for a couple of years now..."

No it is not. Might have been true the last time you used it (I doubt this), but you many want to play around with VMWare Server Beta. The amount features VMWare has clearly out classes Qemu. VMWare performs better then Qemu; if you are going to use the non-free kernel module for Qemu, you might as well use VMWare. No one is going to use Qemu in a business. VMWare and Qemu are in two different leagues though: one being a emulator and the other a virtual machine.



<a href="http://www.vmware.com/products/server/" title="vmware.com">http://www.vmware.com/products/server/</a vmware.com>

#

Antoher simple way !

Posted by: jarjar26 on June 15, 2006 07:49 AM
Create with help of this site a preconfigured<nobr> <wbr></nobr>.vmx <a href="http://www.easyvmx.com/" title="easyvmx.com">http://www.easyvmx.com/</a easyvmx.com><nobr> <wbr></nobr>... Very easy<nobr> <wbr></nobr>:) And its work great with VmPlayer !

#

Another good option.

Posted by: Anonymous Coward on June 15, 2006 03:58 PM
You can find a lot of usefull tools for VMware at:

<a href="http://petruska.stardock.net/Software/VMWare.html" title="stardock.net">http://petruska.stardock.net/Software/VMWare.html</a stardock.net>

Especially VMX Builder will allow you to create/edit/launch virtual machine(s) a trivial task.

#

How to create virtual machines using VMware Player

Posted by: Anonymous Coward on June 15, 2006 04:08 PM
Hello,
For people who want to understand how to create and configure a vmx file, you could read the "How to create virtual machines using VMware Player" article on <a href="http://www.lorenzoferrara.net/" title="lorenzoferrara.net">http://www.lorenzoferrara.net/</a lorenzoferrara.net> (Choose "Blog")

Also, you can download prebuilt clean vmware hd images (of different sizes - search for virtual_machine.tar.gz)

Lorenzo Ferrara

#

Running any Linux in Windows without a CD-Rom free

Posted by: hombrelobo on June 15, 2006 06:44 PM
Easier: <a href="http://wolfb.com/?q=linux-windows-cdrom" title="wolfb.com">http://wolfb.com/?q=linux-windows-cdrom</a wolfb.com>

#

rBuilder Online

Posted by: Anonymous Coward on June 20, 2006 09:50 AM
<shamelessplug>You can easily create, maintain, update, and share customized vmware appliance images with <a href="http://www.rpath.com/rbuilder/" title="rpath.com">rBuilder Online</a rpath.com></shamelessplug>

-mkj

#

You can also use vmcreator.com

Posted by: Anonymous Coward on July 01, 2006 12:46 AM
"Use this [web-based] application to create a Virtual Machine for VMware's VMPlayer. Once you submit this form, you will be prompted to download a ZIP file containing a VMware config file (.vmx) and a VMware disk image (.vmdk). Uncompress the ZIP file and open the<nobr> <wbr></nobr>.vmx file using VMPlayer. The disk images are blank, you can now install your operating system of choice. NOTE: This application does not use any VMware applications or code. It uses QEMU to generate disk images." <a href="http://vmcreator.com/" title="vmcreator.com">http://vmcreator.com/</a vmcreator.com>

#

Re:You can also use vmcreator.com

Posted by: Anonymous Coward on July 23, 2006 02:30 AM
I'd tried vmware player/workstation/server, ms virtual pc/virtualserver, qemu. The best for me is qemu. It's simple, affidable, opensource !!!!
There is a gui front-end for win host at <a href="http://www.davereyn.co.uk/download.htm" title="davereyn.co.uk">http://www.davereyn.co.uk/download.htm</a davereyn.co.uk>, there is also a integrated distribution (qemu+frontend).
Bye

#

How to use VMware Player to create your own images

Posted by: Anonymous [ip: 91.179.57.117] on February 09, 2008 09:15 AM
typo in lines
scsi0.present = "TRUE"
scsi0.virtualdev = "lsilogic"

should be

scsi0.0.present = "TRUE"
scsi0.0.virtualdev = "lsilogic"

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya