Posts Tagged ‘vmware’

Copying a VMWare Player virtual machine

Monday, December 14th, 2009

Over the past couple months I’ve been comparing VMWare Workstation against VMWare Player.  Workstation costs $200, while Player is free. While the “free” part is enough for me to keep using Player, there are some things I miss about Workstation.  One of the things I miss is the ability to make snapshots and copies of virtual machines.  However, with a little bit of work, it’s possible to create a copy of a virtual machine you created with Player. Here’s an example of how I did it with a minimalist installation of Fedora 12.

Copy the original “golden” virtual machine directory within the Virtual Machines directory.  The original virtual machine directory was named Fedora12Mini, and the new directory was renamed Fedora12Firewall. The first step is to change all the file names in the copied directory to match the new directory name (which will become your virtual machine’s name in Player).  The virtual machine directory contains (at least) five files that have the same name as the virtual machine’s name, differing only by their extension.  In the example below, all instances of Fedora12Mini need to be changed to Fedora12Firewall.

How the copied directory looks before changing file names

How the copied directory looks before changing file names

Once that’s complete, open the new Fedora12Firewall.vmx file.  The .vmx file contains most of the configuration settings for the virtual machine. Modify all instances of the original virtual machine name (Fedora12Mini) to the new name (Fedora12Firewall) in the .vmx file. While you have the .vmx file open, note two lines you’ll need to look for later.  These are the lines that start with ‘ethernet0.generatedAddress‘ and ‘uuid.location‘. These values are equivalent to the HWADDR (or MAC) and UUID values in your operating system’s configuration.  Both of those values are intended to uniquely identify your network card and computer, respectively. When you start the virtual machine, these values will be regenerated for your new virtual machine, and you will need to update your virtual machine’s configuration with those new values. Before starting the new virtual machine, you still need to make one more file name change, this one in the .vmxf file; change the original virtual machine name to the new name, just like you did in the .vmx file earlier.

The generatedAddress and uuid lines in the .vmx file

The generatedAddress and uuid lines in the .vmx file

Start the VM by starting VMWare Player, and then clicking “Open a Virtual Machine”. Navigate to the new directory and open the .vmx file in that directory.  Now click “Play Virtual Machine.” Shortly after doing that, you will be asked if you moved or copied the virtual machine.  When asked, say that you “copied”.  The virtual machine will then start up.

VMWareCopy3

The network adapter will fail upon startup. You’ll know this because you will not be able to make any network connections.  Verify this by executing ifconfig and looking for the IP address of the eth0 controller:

Results of ifconfig

Results of ifconfig

Note there is no ethernet controller (there should be at least an eth0 setting). This is happening because Fedora’s configuration files do not match the changes made to the virtual hardware that were made when you told Player that you copied the virtual machine.  To fix this, open up the .vmx file on the host and note the new ethernet generatedAddress and UUID location values.  Open /etc/sysconfig/networking-scripts/ifcfg-eth0 on the virtual machine and enter the contents of the ethernet0.generatedAddress line into the HWADDR line in ifcfg-eth0, and the uuid.location contents into the UUID line in ifcfg-eth0. Copying ethernet0.generatedAddress to ifcfg-eth0 is straightforward, but the UUID value isn’t formatted the same as in the .vmx file.  When updating ifcfg-eth0 with the new UUID, just ensure that it follows the same pattern of 4 bytes-2 bytes-2 bytes-2bytes-6 bytes.  The easiest way I found to do this was to just add a new UUID underneath the existing UUID, then deleting the original UUID when finished:

ifcfg-eth0 after updating HWADDR and UUID, but before deleting original UUID

ifcfg-eth0 after updating HWADDR and UUID, but before deleting original UUID

After deleting the original UUID value and saving ifcfg-eth0, restart the virtual machine. (An aside: I’m not completely sure a full system restart is necessary here.  I tried to restart the networking service [service network restart], and the changes didn’t seem to take effect until after the full system restart.) You should now have an IP address, and all will be good with the world.

Someone’s been eating my shared folders

Thursday, November 19th, 2009

You’re probably noticing a theme in the last couple of posts. There are weeks where tech is my friend. This week is not such a week. Today’s problem involves losing critical functionality on my home PC’s VMWare install.

I love VMWare.  I’ve been a user of their server products for a few years, and with the recent purchase of a beefy i7-based PC, I started looking into VMWare Workstation and Player.  One of the features of these desktop versions of VMWare is that you can share folders from the host operating system on the guests. In my specific case, the host operating system is Windows 7, and the guest OS is Fedora 11. In order to backup my Fedora installation, I use the shared folders feature to copy from Fedora onto the Windows 7 host, where it’s backed up onto an external USB drive using Acronis Home.

This system worked for a few days, but suddenly stopped working one day.  It occurred after doing a software update on the Fedora guest. I checked the usual suspects for when things go wrong on Linux: firewall settings on both the host and guest, selinux, disk space issues, but no problem was found.  I deleted the shared folder settings and restored them, and I still couldn’t access the shared folders. I even went so far as to reboot both the guest and the host, and the shared folders still wouldn’t work.

It was as that point I realized the significance of shared folders disappearing after doing a Fedora system update.  Among the updates was a security update to the Linux kernel. It was then I realized what had gone wrong.

Shared folders will work with a guest OS only if VMWare Tools are installed on the guest.  On a Fedora guest, that involves recompiling the kernel, and when the kernel was overwritten by the system update, the VMWare changes to the kernel were lost, and thus no more shared folders.

To resolve the issue, I just reinstalled VMWare tools.  Since they were previously installed, all I needed to do was to go to where I had expanded the VMWare Tools tar file and run the vmware-install.pl script again.  I used all the default selections for the prompts during the re-install, and when it finished, shared folders reappeared as quickly as they had disappeared.