Disk Fragmentation in a VMware Environment

 

The purpose of a virtual machine is to allow the user to allocate physical systems resources to multiple tasks.  In many computer operations, the CPU and memory resources are underutilized. Virtual machines allow an organization to get better resource utilization without the added expense of new hardware.  They also provide a portable environment that can keep a system going on an alternative platform when there is a hardware failure.

In the case of VMware, a virtual machine is created on a host disk.  Many administrators believe it is a good practice to keep all their virtual machines in one directory. The virtual machine consists of two main files: the VMX file and the VMDK file.  The VMX file is the primary configuration file for a virtual machine. When you create a new virtual machine, you provide information about the operating system, disk sizes, and networking; those answers are stored in the VMX file. The VMDK file is the disk drive for the virtual machine; and while it looks like a drive to the user, it is actually a container file on the host drive.  When the VMDK is created, you specify whether it is a fixed size or dynamic.  A fixed drive is not created in one big chunk.  For example, a fixed 10GB VMDK file would have an initial VMDK file of 2GB and four additional VMDK files of 2GB each.  If there is less than 2GB of contiguous free space, the VMDK file will be created in as many fragments as necessary to accommodate the fixed VMDK allocation.  The VMX file keeps track of all the fragments of the VMDK file.

 

 A dynamic drive starts with some nominal amount of file header information and grows as needed up to 2GB.  When the 2GB is exceeded, VMware will create another VMDK file and data will expand until another 2GB is used. A dynamic VMDK file will fragment like any other Windows file.  Due to the nature of the Windows file system allocation algorithms, it is unlikely any expansion of the VMDK file would be contiguous to the original file. The file system will look for a piece of contiguous free space that approximates the size of the expansion. If it cannot find a single piece that fits; it will fragment the VMDK file into as many pieces as necessary to accommodate the expansion. 

 

Virtual machine performance suffers when the VMDK file(s) on the host system gets fragmented. Like any other file, the fragmentation slows down the I/O speed of the physical system.  The use of virtual machines often means that multiple processes are accessing the VMDK files. The growth of dynamic VMDK files is the kind of activity that can accelerate the fragmentation of the VMDK files on the host drive.

 

There is a second component that can affect VMware performance and disk space utilization. As mentioned above, VMDK files are usually set up to grow dynamically. If a VMDK grows to 10GB and the user deletes 5GB of data, the VMDK file remains 10GB. This causes two problems: the VMDK file can become internally fragmented as files are created and deleted. Accessing these files takes longer due to the system overhead incurred in keeping track of their fragments. Secondly, the unused space in a VMDK is wasted space because it cannot be used by anything other than its own virtual machine.

 

VMware provides a utility that shrinks a VMDK file.  Like the Exchange Eseutil utility, this is usually done manually and it is a somewhat complicated process. In PerfectDisk, we have automated this process, with the net result that the wasted space will be recovered and the files themselves with be compacted. In the case of our sample dynamic VMDK, the end of disk pointer will be at the end of the 5GB of data.  The compaction should improve access within the VMDK and the free space recovered goes back to the host Windows file systems pool of free space.

 

While virtualization provides organizations with some excellent convenience benefits, there are some performance drawbacks. Fragmentation of the host drive, internal VMDK fragmentation and wasted disk space are a few of the things that kill virtual machine performance. PerfectDisk defragments the VMDK on the host drive, defragments files in the guest drive, compacts the files in the VMDK and recovers the unused white space from within a VMDK file.   Keeping the host and guest drives contiguous while recovering wasted disk space eliminates the primary culprits affecting VMware I/O performance.  Only PerfectDisk delivers a fully automated host/guest defragmentation and compaction solution for VMware systems.