Sunday, October 15, 2006

How to Optimize your Virtual PC Vista virtual drive...

This is likely going to be one of my last posts on Microsoft's Virtual PC 2004/2007 for a while.

I haven't found a way around the prohibition of running Virtual PC 2007 on a XP Home system yet. I've tried some obvious things...no luck yet. It appears the program/installer runs a check against a registry entry or two to validate it being allowed to install and/or run. If you don't have the correct key (which XP Home does not) then there will be no running Virtual PC 2007 on it. Sorry home users, the Virtual PC development team doesn't seem to see your needs as a priority at this moment.

However, I did manage to copy the Virtual PC 2007 "Additions" file (VMAdditions.iso dated 10/06/06) that was installed on my XP Pro system's load of Virtual PC 2007 onto a USB stick. I then transferred that newest version into my Virtual PC 2004 folder on my XP Home system. Then I attempted to install this newer additions version on a new virtual machine setup of Vista RC2 running within Virtual PC 2004. It took just fine and seems to be running well with no errors. So at least that is something! (Your mileage may vary....)

Anyway...back to the original post subject.

Introduction

When you've been running Virtual PC for a while, you may notice that your virtual drive files are getting a little bit larger. By performing some simple steps, you can often shrink the virtual drive files down a bit and maybe gain some performance improvements.

I've read a number of posts on doing this (listed at the end of this post) and simplified the steps.

You must have sufficient free-space on the drive where your virtual hard-drive files reside. If there isn't enough space, the Virtual Disk Wizard will tell you and not allow you to continue. If this happens, make some room on your drive or move the virtual disk files you are interested in to another partition or drive that has sufficient space. Then put them back when you are done.

Also, on some of my virtual Vista machines I ran into "user rights" issues for some reason trying to perform these steps. I ended up just adding the Administrator account login and then ran the steps under that account instead. It worked fine. See further down near the end of the post on how to get the "Administrator" user icon to display at the login screen.

Simple How-to on Optimizing your Virtual PC disk files

Starting size: My virtual Vista RC1 system consisted of two vhd files of just under 4.3G each.

1) Clean out temp files/downloaded setup files, etc from virtual hdd. From within your Virtual machine session, look around and try to uninstall any extra windows components/games/etc. that you just don't need or use. Look for copies of downloaded setup files you may have already installed. Delete those if you can. Maybe get rid of some of the sample pictures or videos or music clips installed with your system. Just use your judgement on what you need and what to get rid of...it's up to you.

2) Empty the trash.

3) Turn off system restore. I recommend taking this step only because I don't really worry about system restores in virtual machines. To turn off System Restore in Vista right click on "Computer" (assuming the icon is on your desktop) and select "Properties." In the window that appears, look on the left side column and click "System protection." Now unselect any drives listed using the checkbox. Apply your change and click OK.

4) Run Disk Cleanup. Go to "Vista start" button, click "All Programs" and expand the "Accessories" folder. Now browse down for the "System Tools" folder and expand that one. You should see "Disk Cleanup" click to launch. Select the "Files from all users" cleanup option. After it gets done calculating, select all the checkboxes you want to perform the cleanup action on. I picked them all.

5) Set compression on your virtual drive. Double click the desktop "Computer" icon. Right-click on your drive(s) and select "Properties" then under the "General" tab, check the option at the bottom to "Compress this drive to save disk space." Click "Apply" and I elected to apply the changes to the drive and subfolder's. There may be a few files it is unable to perform the action on, I just clicked the "Ignore all" and it kept going. Note: this process may take a while to finish up.

6) Defrag your drives. Go to "Vista start" button, click "All Programs" and expand the "Accessories" folder. Now browse down for the "System Tools" folder and expand that one. You should see "Disk Defragmenter." Click to launch and run your defrag right now. Once done, I'd recommend a reboot.

7) Zero out the virtual drive. This is really important to do!

Method A

1) Mount the precompact iso file from the windows virtual pc program files folder.

2) On the Virtual PC menu-bar, click "CD" then "Capture ISO Image..."

3) Browse to the "Virtual Disk Precompactor.iso" file. Mine was located at the C:\Program Files\Microsoft Virtual PC\Virtual Machine Additions\ folder.

4) This should capture that ISO file as a virtual drive in your virtual Vista system.

5) Open your "Computer" window and browse to the virtual drive you just mounted. On mine it was the D: drive.

6) On this drive, find the "precompact" application and double-click to run. It runs pretty fast depending on how large your virtual drive is.

6) Follow the steps and shut your system down when done.

Method B

Get a 3rd party tool and do the same thing.

Method C

Download and install Heidi's Eraser in your virtual Vista system and use tool that to set and run a custom "zeroing" wipe of freespace.

8) Shut down your running virtual pc when the precompact utility has completed (it may take a while).

9) Compact it with the Virtual PC Wizard tool.

1) Your Virtual PC icon should be running in the system tray. Right click it and select the "Virtual Disk Wizard".

2) Choose the option to "Edit an existing virtual disk"

3) Browse to wherever the .vhd file is for the virtual disk you are working on.

4) Choose the option to "Compact it."

5) Now decide how you want to compact it. I just go ahead and use the option for "Replacing the original file", but if you have enough free-space, you can save the original one also.

6) The compaction will run. It usually runs pretty fast.

10) Done!

Ending size: One vhd file of just under 4.3 G and the second just under 1.7G.

Not amazing, but quite a bit better than I started with.

Additional Notes:

Getting the "Administrator" account login icon to display.

Go to the "Control Panel", select the "Administrative Tools", select the "Local Security Policy." On the left side, expand the "Local Policies" folder. Select the "Security Options" folder and they will display on the right. Enable the "Accounts: Administrator account status" policy. Close out the windows and log off then, back in as "Administrator." Easy.

If for some bizarre reason you can't use the "Capture ISO image..." feature to grab the ISO, you may wish to try 1) Install the MagicDisc (freeware) within your virtual Vista session. Then modify the virtual machine settings to share the folder that has the "Virtual Disk Precompactor" ISO file. Finally, use the MagicDisc tool to open the ISO out of that shared folder. You shouldn't need to do this, however.

This technique works fine under both Virtual PC 2004 and Virtual PC 2007 (Beta).

Supporting links for detailed reading:

Creating Smaller Virtual Machines - Coding Horror by Jeff Atwood

Optimize Virtual PC 2004 Images - Opsan Blog by Michael Coates

Virtual PC 2004 SP1 - Wes' Puzzling Blog (a few details of Virtual Disk Precompactor ISO usage)

Bonus Tip:

Starting a Microsoft Virtual PC session without using Virtual PC Console - via Windows IT Pro

Enjoy,
--Claus

No comments: