Ramblings from The Montopolis Group

Building better businesses… with Technology

Archive for the ‘Virtualization’ Category

Steps to Compact an XP Virtual Hard Disk

After many trial and error runs, I’ve finally been able to reduce my fully updated Windows XP SP2 Virtual Machine to a rather lean 802 MB (uncompressed) 276 MB (compressed). WOW!! :)

 In order to get the XP VM at a reasonable size, follow these steps:
*You must be using a Dynamically Expanding VHD, I’ve not tested the other formats VPC supports!

  1. Clean your VM by removing all unnecessary programs/documents.
  2. Defrag your drive, use Dave Whitney’s Defrag Utility (no need to install anything!) It works 10X better than Windows bulit-in defrag utility by completely evacuating files and then replacing them.
  3. Run a disk Pre-Compactor program, if using Virtual PC, mount the included Pre-Compactor under “Virtual Machine Additions” in the Virtual PC install directory. Immediately shut down the VM.
  4. Load the Virtual Disk Wizard and select “Edit an existing virtual disk”, enter the location of your vhd file and select “Compact It” then “Replacing the original file”.
  5. Watch your vhd file shrink like crazy!

This entire process could literally take a couple hours to 10 minutes, depending on the size of your vhd.

 Tips:

  • To reduce the size of your vhd, turn off the paging file temporarily, then defrag. Try leaving the paging file off for now, you can always turn it back on. This freed up 500MB of space, I’ll turn it back on later, XP will tell me it needs it when it needs it! :)
  • Don’t just defrag once, it took me 4 defrags to get my vhd to the size it is at…
  • Remove XP’s default loaded games, they take up 13 MB.
  • Only use Windows defrag utility to view a graph of your drive to check for fragmented files. You should see a solid blue bar followed by a solid green bar. The Windows defrag utility works, but not good enough!

**UPDATE**

“What does the pre-compactor do for the VHD?”

To understand how the pre-compactor works, you need to understand how a standard hard drive works!

When a hard drive saves data to the disk, it attempts to place all the data in a contiguous form. If data is deleted, that leaves a blank hole on the disk where data used to be stored. Now, for example, you install a program that takes up a large portion of your hard disk, the hard drive will fill in data where you previously deleted thus the new data will be fragmented or scattered throughout the various holes on the disk!

In a typical hard drive, when data is deleted the hard drive “un-links” the data from the OS so you cannot access it, but it is technically still written on the hard drive until it is overwritten by new data. This is why there are data recovery specialist in the world! :)

The same is true in a virtual environment! Since your virtual hard disk is continuously expanding, it sees this “un-linked” data as good data and keeps it stored in the VHD file which is really just wasted space! The pre-compactor program finds these data chunks and permanently deletes them by writing zeros in place of that data. The VHD compactor is able to then remove zero-ed data from your VHD file, thus reducing the size of the VHD!

“What is the whole purpose of compacting your VHD??”

Well, it really depends on what you’re doing with your Virtual Machine! It all boils down to efficiency when sending the VHD across

In our environment, we use VPC as a testing tool. When we need a fresh install of XP to test a new solution we grab our VHD from the network, load it in VM, and test away.

Unfortunately, installing a fresh XP each time you want to test takes a little while… It is far more efficient to stage a fresh XP and store it on the network, to be downloaded whenever needed. Changes can be made on an “Undo Disk”, which is a great feature of VPC 2007, thereby always maintaining a fresh XP VHD!

  • 2 Comments
  • Filed under: Virtualization
  • Speed up Microsoft Virtual Server

    I was recently speaking with a few clients who were both complaining about slow performance under Microsoft Virtual Server.

    After reviewing their setups, I realized they missed a few common optimizations.

    As with any virtual server enviornment, make sure your host is tweaked and optimized before you blame virtualization.

    There are easy best-practices which we have been following for years which are easily the most overlooked items.  You’ll have the fastest Virtual Server if you follow these recommendations.

    • Update All Firmware The #1 overlooked item.  And it has the most impact.

      Every device in your Virtual Server that has a firmware needs to be verified that its running that latest (stable) version provided by your vendor.

      If you have a whitebox or other non-big-3 server (HP, IBM, Dell) than this can take some work.

      But get this done.  It helps so much.

    • Disable all NIC Offloading Every NIC on your system should be manually verified to disable ALL offload options.  Different adapters call these options by different names, but if the setting has the word “offload” in it, turn it off ;)

      Years ago we found this out by seeing frequently corrupted virtual disk images.  Luckily Microsoft Virtual Server has stablized a lot since then and now its just a performance drainer.

      More info and gory details at: http://support.microsoft.com/kb/888750

    • Use SCSI virtual disks instead of IDE Without a lot of tech mumbo, IDE virtual disks should never be used.  They are slow in the physical world and guess what?  They are slow in the virtual world too ;)  Stick with SCSI.

      If you’ve added your disks as IDE already, the following steps should get you converted:

      • add the virtual SCSI adapter to your VM and restart it
      • reinstall the VM Extensions and make sure the Virtual SCSI adapter is there
      • reboot the VM again to be safe
      • remove the existing IDE Virtual disk and readd it as a SCSI disk
    • Run the latest versionThis goes without saying, but no list would be complete without it.  Run the latest version of Virtual Server.  We’re running the latest beta at all our clients with no ill-effect.  If you’re not that brave, than run the latest release.  Virtualization is “new” technology that is moving quickly.  It really helps to stay up to date.
  • 0 Comments
  • Filed under: Virtualization
  • Convert VMWare to Virtual Server/PC (VHD)

    I’ve been looking for a way to convert images made for VMWare over to Microsoft Virtual Server or Virtual PC.  I finally found something: http://vmtoolkit.com/files/folders/converters/entry8.aspx.  Sweet!

    One caveat - this doesn’t work with Linux VMWare images.  Darn.

    Please Microsoft, release the Linux compatible version of Virtual Server!!  I’m running the beta but until its released, none of the linux folks will take Virtual Server seriously ;)

  • 0 Comments
  • Filed under: Virtualization