Home > Blogs > VMware Fusion Blog > Author Archives: Eric Tung

Author Archives: Eric Tung

Bonus Tip: Snapshots

People sometimes get confused about how snapshots work and how to use them. While snapshots are incredibly useful for many things, one major misconception is thinking that they are a form of backup – they’re not! If a lightning strike totally fries your computer, a snapshot won’t help if it’s on the same disk (because your snapshot just got fried too). Sure, you’ll probably get lucky – if your computer merely shut down uncleanly, your snapshot may still work. You might not even need to go use the snapshot. But this is not a backup, it’s gambling.

If you want to back up a normal virtual machine, shut down (or suspend) the virtual machine and quit Fusion — you never want to try to read or modify virtual machines when Fusion is working on them. From the Finder, copy the virtual machine to a suitable external drive. Done! If you’re feeling really backup-ful, keep the external drive offsite – this way you’re protected against disasters that affect your entire location (e.g. fire, flood, etc.) A snapshot is better than nothing, but it’s not true backup.

Continue reading

Tip: Defragmentation

As you use a computer, over time your files will tend to get scattered around the disk. This scattering is called fragmentation, and can slow down performance as the disk head has to seek back and forth between fragments (Note: doesn’t apply to solid state media, which doesn’t involve disk heads). Defragmentation (or defragging) is the act of reversing the process, putting order back into your system. With virtual machines, proper defragmentation is a little more complex than it is on a physical machine because of the layers involved.

Before we begin, it’s important to note that defragmentation isn’t a necessary task – your virtual machine will still work just fine even if you never defrag, and the effects of fragmentation are usually not noticeable. Personally, I’ve never feel the need to defrag. However, if for some reason you do feel the need to defrag, here’s how to do it. Note that snapshots get in the way of proper defragmenting.

Continue reading

VMware Fusion 201: Sparse Virtual Disks

If you’re new to virtualization and computers, you might be confused about why deleting a virtual machine doesn’t seem to free up the space you think it should, or why the guest might be complaining it’s out of space when there’s plenty left on the host (or vice versa). Why this happens becomes clearer when you start thinking in layers.

Before we begin, one common misconception is that Fusion somehow partitions the physical drive – not so! For normal virtual machines, a virtual disk is simply a (probably pretty large) file. We use normal OS X file operations to access it. For Boot Camp virtual machines, there is partitioning of the physical drive involved, but Fusion doesn’t do it – you did it when you set up the Boot Camp partition in the first place. While we do use raw disk access for Boot Camp virtual machines, again, it’s by standard OS X APIs.

By default, VMware Fusion uses what are called "sparse" disks. That is, we don’t grab space upfront, but rather as needed. In the diagram, chunks of space (for technical users, blocks) are represented as squares; colored ones are occupied, white ones are unused. The guest (green) thinks it has an entire 20 GB (or whatever) drive. However, if the guest has only ever written 5 GB to the drive, the .vmdk file (red) will only be 5 GB, not 20. The host (blue) can store the .vmdk however it wants on the actual hard drive, perhaps interspersed with other files (grey).

Since Fusion doesn’t grab space upfront, deleting a virtual machine with a 20 GB disk might not (actually, probably will not) free up exactly 20 GB of space. It can be less (as in this example) or more (if you have a snapshot, which I’ll cover in a later post). There are other files in a virtual machine, but the virtual disk is usually most of it.

Each layer is (at least somewhat) separated from the others, which can lead to some misunderstandings. For example, if you run out of space in the host, it doesn’t matter if you still have 10 GB left in the guest – there’s simply nowhere to put the data. Conversely, even if you have 100 GB left on the host, if the guest has used up the entire (virtual) hard disk, it can’t write any more data. Keep an eye on free space in both the host and the guest.

The main advantage of using sparse virtual disks is, well, that they take up less space. As always, there’s a tradeoff involved, but we think the benefits for most people outweigh the inconveniences. In the next VMware Fusion 201 post I’ll talk about your other option, preallocated virtual disks.

Tip: Resource Monitoring

Sometimes your Mac might not run as quickly as you expect, and you’d like to know why. A good first stop that all Mac users should be aware of is Activity Monitor, located in /Applications/Utilities/. This program lets you see various statistics about what’s running on your Mac, as well as overall statistics like RAM, disk, and network usage. If you select a process, you can choose to sample it – for a short period the state of the program is periodically recorded, which helps developers figure out where a program is spending all its time.

If you’ve read A Beginner’s Guide to VMware Fusion, you know that Fusion really consists of two processes – a UI process called "VMware Fusion", which handles user input, and a backend process called vmware-vmx which does all the real work of virtualizing your guest. If you run multiple virtual machines, you’ll have a vmware-vmx for each guest but only one UI process. One catch is that vmware-vmx is root-owned, so if you want to see it in Activity Monitor, you need to select All Processes to be shown.

If you recall my previous post, we should try to think in layers. Activity Monitor only covers the host and Fusion layers, but things aren’t broken down beyond that. To see what’s going on inside the guest, we need guest-specific tools. A virtual computer is very similar to a physical computer, so we start with the same tools you would use on a real machine.

For Windows guests, a good next step is to check out Task Manager. You can get to Task Manager by Virtual Machine > Send Ctrl-Alt-Del. Note that unlike Activity Monitor, Task Manager has an entry for unused time, which falls under System Idle Process. In this example, I’ve just started Steam.

For Linux guests, a good next step is to use a tool like top or ps. These are both command-line programs, so open a terminal in the guest and run one. In this example, I’m applying a system update.

If you’re interested in this sort of thing, much more has been written on the subject by other people. This is just the very basics, intended to get you thinking about how to keep track of what’s going on in a virtual machine.

VMware Fusion 201: Layers

When you run an application in a virtual machine, there are several things going on at the same time. At the lowest level is the host – in our case, OS X. On top of that is the virtualization layer, Fusion. Then there’s the guest OS, and finally any applications you’re running in the guest. If you want to think about, troubleshoot, or simply appreciate virtualization, you need to think in layers.

Suppose you ran into a problem in iTunes – maybe a song skips every time it reaches 1:17. It wouldn’t make much sense to try to fix the problem in iChat. Similarly, if something’s wrong at one layer of a virtual environment (say in the guest OS), the first thing you should do is probably not to try to fix it in a completely different layer (say the host OS).

If some program is displaying a message and you’re not sure what it means, a good first step is to pay attention to where it comes from – does it look like something you expect to see in the host or the guest? If the message is from Fusion, does it specifically mention the host or the guest? For example, if a message refers to a C: drive, it’s probably not from OS X or Fusion. Conversely, if you’re in single window mode and get a message outside the console window, it’s probably not from the guest.

This isn’t to say the layer theory is completely perfect – it’s possible for problems in one layer to affect others. However, it’s a useful first step.

Tip: Security

One of the nice things about virtualization is that you can run just about any program you can on a physical computer. One of the drawbacks of virtualization is that you can run just about any program you can on a physical computer. Why the seeming contradiction? While most programs are useful things you’ll install yourself, malware like trojans, viruses, worms, and so on are also all programs – and will happily run in a virtual machine. Unfortunately, malware authors frequently forget to set the Evil Bit, so it’s not simple to only run "good" programs.

From a security standpoint, you should treat a virtual machine just like you would a physical computer. For most users, this means you should have a firewall, antivirus, and software updates turned on. If you don’t need networking, disable it. Don’t visit shady websites or run untrusted programs.

If you’re a longtime Mac user, you’ve probably never needed to worry about this sort of thing; simply running OS X is a good first line* of defense in a Windows-centric world. But if you run Windows in a virtual machine, you need to be able to think like a Windows user.

* Disclaimer: Using a Mac is not a silver bullet, so
don’t get too complacent – malware could still theoretically hit us.
But it’s less likely.

Personally speaking, most of my virtual machines have no need for network access, so I disable networking (and actually remove the virtual network card to make sure I can’t accidentally enable it). With no networking, there’s no need for a firewall. If I need to get programs or data into the virtual machine, I use drag-and-drop or a read-only HGFS shared folder. I don’t keep important data in my virtual machines or allow them write access to HGFS shared folders, so even if something somehow gets through to the guest and runs amok, I won’t lose anything important. My setups are pretty simple, but if I had a complex one (e.g. if I had to spend hours installing software), I would back up a clean copy. Because of all this, I feel like I can get away without antivirus.

I suppose the managers and PR folks would want me to point out that Fusion 2.0 comes with a complimentary 1-year subscription to McAfee VirusScan Plus, which will run on 32-bit Windows 2000, XP, Vista, and 64-bit Vista. If you’re not a McAfee fan or are using other guest OSes, that’s cool; you can use whatever you want. My point is simply that you do need to take precautions even with a virtual machine.

VMware Fusion 101: Unique Identifiers

If you enter a room and want to get someone’s attention, you might call out their name so they know you want to talk to them (and not, say, the person standing next to them). Computers have various unique identifiers that serve a similar purpose, and if these identifiers conflict, they might not be able to communicate with each other. A common identifier is the MAC (short for Media Access Control) address. Every network adapter has one of these. VMware virtual machines have another identifier called the UUID – this isn’t important to the guest, but is how Fusion (or other VMware products) keeps track of virtual machines.

Whenever you move or copy a virtual machine, Fusion needs to know which happened — if you’ve moved the virtual machine, the UUID and MAC address(es) remain the same. In the people-in-a-room analogy, you just walked over to a different spot. If you’ve copied the virtual machine, Fusion assigns a new UUID and MAC address(es) — in the people-in-a-room analogy, your twin sibling just walked in and needs a different name so people don’t confuse the two of you. Maintaining the same unique identifier is less disruptive for the virtual machine, while creating a new identifier is required if you’re going to use an original and a copy at the same time.

So far so good, but to make things more complicated, there are potentially other unique identifiers associated with each computer that Fusion doesn’t know about and so can’t change. If your guest has one of these, you’ll need to update it if you copy the virtual machine or else things may not work. One example is Windows, which has a Security Identifier, or SID. Even if two computers have independent MAC address, if the SID is the same, one won’t be able to access the network. You may need to use a tool like NewSID to update the SID of a copied Windows virtual machine. Another example is older versions of Ubuntu, which stored the MAC address in /etc/iftab; networking didn’t work if the MAC address changed and this file wasn’t updated.

Tip: Force a Virtual Machine to Power Off

If you’ve ever used a computer and had it freeze or otherwise lock up, you may have had to pull the power cord, either literally or by holding the power button. But how do you do this for a virtual machine?

In the Virtual Machine menu, there are of course power commands: Shut Down Guest, Suspend Guest, and Restart Guest. However, these are what are known as soft power commands – they’re requests to the guest OS, which it can ignore (or in the case of a deadlocked guest, might not be able to handle). In contrast, hard power options are not ignorable by the guest – it’s the virtual equivalent of yanking the power cord. To get these hard power options, hold down the option key on the Virtual Machine menu to change the power commands to Power Off, Suspend, and Reset.

Obligatory note of caution: Just like with a physical computer, you risk corrupting the contents of the (virtual) disk if the guest OS isn’t in a quiesced state.

Side note: Some virtual machines have the default options switched (i.e. hard power options by default, and pressing the option key changes to soft power options).

Bonus tip: Holding down the option key to get alternate menu items is used in other Mac applications – for example, try it in Finder.

VMware Fusion 101: Virtual Hardware Version

VMware virtual machines have a property known as the virtual hardware version – if you’re into .vmx-file diving, it’s the virtualHW.version field. The virtual hardware version is how we manage the file format, and is sort of like Word 98 vs. Word 2008 – newer file formats are needed to support new features that were unthought of years ago. The virtual hardware version is analogous to a motherboard in a physical computer – upgrade the virtual hardware version to upgrade the virtual machine. Many times, new features like enhanced 3D or more device support depends on extending various parts of the file format (for example, for the technically minded, we might have to add more registers or card slots).

If you upgrade from VMware Fusion 1.x to Fusion 2.0, you’ll probably be asked if you want to upgrade a virtual machine; in other words, you’re being asked if you want to upgrade to the newer file format. If you want improved 3D in XP or Vista, upgrading the virtual hardware is a good idea. On the other hand, there’s not much point in upgrading a DOS virtual machine since at best DOS will ignore the new hardware and at worst will freak out. You can always upgrade later by selecting "Virtual Machine > Upgrade Virtual Machine…"

If you downgrade from VMware Fusion 2.0 to Fusion 1.x, you might see a warning that a virtual machine was created with newer features that Fusion 1.x doesn’t know how to handle. To get around this, have Fusion 2.0 downgrade the virtual hardware by selecting "Virtual Machine > Downgrade Virtual Machine…" This way, Fusion 1.x will recognize the virtual machine.

Since we use the same virtual hardware version to mean the same thing across all our products, what I’ve said also applies to Workstation, Player, Server, and so on. Fusion 2.0 uses virtual hardware version 7, the same as Workstation 6.5, Player 2.5, and Server 2.0. Fusion 1.x uses virtual hardware version 6, the same as Workstation 6.0.x, Player 2.0.x, and Server 1.x.