Tech Line

Virtual Time Freeze

Here’s how to get control of a VM’s virtual clock.

Chris: I often install 180-day eval editions of software. Every 180 days I flatten my VMs and reinstall my VM guest software. But, my tests are usually only two or three days long. How can I configure the VM so that when I fully reset it (i.e., revert to snapshot) that it doesn't realize how many "days" have passed? I want it to think that it's just been installed, like Day 1. Is that possible?
--Jeremy

Good question, Jeremy. Many of us that use VMs for periodic software testing run into the same problem. By default, VMs always attempts to synchronize with their physical host system's clock. This is usually a good thing, but sometimes administrators need complete control of a VM's virtual system clock. To isolate the VM's virtual clock from the physical host system's clock, you will first need to add these entries to a virtual machine's associated .vmx configuration file while the VM is powered off:

tools.syncTime = "FALSE"
time.synchronize.continue = "FALSE"
time.synchronize.restore = "FALSE"
time.synchronize.resume.disk = "FALSE"
time.synchronize.shrink = "FALSE"

 

To make the changes, navigate to the folder containing the virtual machine's configuration file and open the configuration (.vmx) file using a text editor such as Notepad. Once you have added the lines shown above, save the .vmx file. Note that the line tools.syncTime may already be present in the .vmx file, so you will just need to make sure that it is set to False. The lines starting with time.synchronize.continue should be added after the tools.syncTime line. For more information on VMware time synchronization, the document "Time Keeping in VMware Virtual Machines" is a very good read.

With these entries in the VM's .vmx file, each time you create a snapshot of the VM, the date and time of the VM's virtual clock will be preserved. So if you need to use the VM a week later and revert to the previous snapshot, the VM will resume running and with its system clock set to the date and time of the snapshot.

Tech Help—Just An
E-Mail Away

Got a Windows, Exchange or virtualization question or need troubleshooting help? Or maybe you want a better explanation than provided in the manuals? Describe your dilemma in an e-mail to the MCPmag.com editors at editor@mcpmag.com; the best questions get answered in this column and garner the questioner with a nifty Redmond T-shirt.

When you send your questions, please include your full first and last name, location, certifications (if any) with your message. (If you prefer to remain anonymous, specify this in your message, but submit the requested information for verification purposes.)

In VMware Workstation, you can create a snapshot by clicking the VM menu, selecting Snapshot, and then clicking Take Snapshot. In VMware Server, snapshots are created by clicking the Snapshots menu and then clicking Take Snapshot. To revert a VM to a previous snapshot in VMware workstation, click the VM menu, select Snapshot, and then click Revert to Snapshot. With VMware Server, you can revert to a snapshot by clicking the Snapshot menu and then selecting Revert to Snapshot.

To summarize, after preparing a new VM, installing the guest OS and applications and disabling time synchronization with the physical host, all you need to do is create a snapshot of the VM. When the snapshot completes, power down the VM. When you need to use the VM again, just open the earlier snapshot.

Now, suppose that you haven't used a VM in three months and want to make the VM think it is starting the minute after it was last shut down. You can force the VM's virtual clock to start at a pre-set time (such as one minute after the date/time stamp on the VM's virtual hard disk file) by adding the rtc.startTime value to the VM's .vmx configuration file. When present, the value associated with rtc.startTime sets the VM's clock to a specified Unix timestamp. For example, to make a VM think the date is Jan. 2, 2007 and the time is 4:24 p.m. Eastern time (GMT -5), you enter the following in the .vmx file:

rtc.startTime = 1167773040

If you're from this planet (like me) and can't convert current times to Unix timestamps in your head, try using the online Unix Timestamp Converter. Keep in mind that if you add the rtc.startTime value, you also need to add the lines (listed earlier) to disable time synchronization to the .vmx file as well.

While my planet of origin may be under debate, there is no debate on the usefulness of having full control of a VM's virtual clock.

About the Author

Chris Wolf is a Microsoft MVP for Windows --Virtual Machine and is a MCSE, MCT, and CCNA. He's a Senior Analyst for Burton Group who specializes in the areas of virtualization solutions, high availability, storage and enterprise management. Chris is the author of Virtualization: From the Desktop to the Enterprise (Apress), Troubleshooting Microsoft Technologies (Addison Wesley), and a contributor to the Windows Server 2003 Deployment Kit (Microsoft Press).learningstore-20/">Troubleshooting Microsoft Technologies (Addison Wesley) and a contributor to the Windows Server 2003 Deployment Kit (Microsoft Press).

comments powered by Disqus

SharePoint Watch

Sign up for our newsletter.

I agree to this site's Privacy Policy.