Prepare a Virtual Environment for testing

by Mats Hellman on 14.May, 2010 under Windows, Windows Deployment

One of the more important tools I use in my day to day work is Virtual PC. To be honest I’ve been looking at VMware Workstation for a while because Virtual PC 2007 doesn’t support 64-bit guest operating systems. But that’s another story. Right now I manage with what I’ve got.

Why a virtual environment?

This might be the first question. Well it saves time and money. I can test different products and deployments without using a full expensive test lab. The virtual systems can’t replicate every possible scenario but I’ve managed fine so far.

You can’t test disk encryption and that’s to bad but almost anything else is possible without making changes to your production environment.

How to setup the environment

First of all you should create a few master images so you will be able to copy in servers and clients when you need new ones. This is simply done by installing a copy of Windows Server 2008, Windows 7 or any other system you might need in the future. I personally keep master images of

So if you need all of them you need to start installing. Just install the basic OS, install all/any tools you like to use. Maybe you even want install the Office suite. Another tool collection I suggest you install is the Sysinternals Suite. After you have installed all the basic Operating systems we need to Sysprep them so they can be used again and again without any collisions on SID:s etc.

Using Sysprep

After you have everything installed you need to sysprep your installation and let the guest operating system shut down so you can copy the virtual hard disk (.vhd) file. Sysprep has been integrated in Windows Vista and newer, XP and 2003 has the files on the installation media in the folder <DRIVE>:\Support\Tools\Deploy.cab . In Vista and newer you can find sysprep in the folder C:\Windows\System32\sysprep.

For Windows Server 2008 and Vista you need to install the Virtual Machine Addons to get it running smoothly and you really want them to be left alone by sysprep. After all we are running sysprep to get our master images for Virtual PC.

So to keep your Virtual Machine Additions in the image you need to create a sysprep.xml file in the sysprep folder. If you want to you can place anything in the Sysprep file but this is needed to keep the Virtual Machine additions for the next boot.

<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
   <settings pass="generalize">
      <component name="Microsoft-Windows-PnpSysprep" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="x86">
         <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
      </component>
   </settings>
</unattend>

Once you have the file saved in the C:\Windows\System32\Sysprep directory just run from the command prompt.

sysprep /generalize /unattend:sysprep.xml

After the computer shuts down you can move the .vhd file to a storage directory and name it something like Ws2008-master.vhd.

Windows 7 has a greatly improved support to run as a virtual machine so I’ve never had to install any of the additions on a Windows 7 image.

The result

The next time you need to “install” a new virtual Server or client just copy the .vhd file to another location and rename it. Create a new virtual machine and point it to the newly copied .vhd file. Boot the server or client and you’re done. Easy, fast and great for testing.

Virtual PC wants to store everything in your home folder but I like to keep my virtual machines in the root of a drive. So I know where to find them.

D:\VMS to keep the vmc files
D:\VMS\VHD to keep the .vhd files in use, not the master images
D:\VMS\Master to keep the master .vhd files
D:\VMS\ISOS to store any ISO files I might need.

You should set it up the way you like it but for me that keeps it in order and I know where to look for my files.

If you have any questions feel free to comment and I’ll answer anything I can.

Leave a comment

Shrink VHD in Windows 7

by Mats Hellman on 07.Dec, 2009 under Windows, Windows 7, XP Professional

I got a new HP Z400 Workstation to my office today and decided to recycle the old DC5800 to someone who needs a trusty workhorse and doesn’t work with memory intensive tasks like Virtual Systems like I do. Even if my old desktop was getting a new life I still wanted to keep it because I’ve installed many tools on it I still use and I like to do some Group policy testing on it.

I found the great tool Disk2VHD by Sysinternals. It converts your physical disk to a VHD file so you can use it in Virtual PC or some other virtualization software that supports Microsoft’s VHD format. Disk2VHD homepage http://technet.microsoft.com/en-us/sysinternals/ee656415.aspx

Before you start this you may want to make a backup of your VHD file in case something goes wrong.

Shrinking the VHD for Virtual PC

So I captured my old hard drive and moved it to my new workstation. The file was only 80Gb as Disk2VHD makes it a dynamically expanding disk. Everything looks fine so far. The problem is that Virtual PC only supports 127Gb drives or smaller and my physical drive was 250Gb so booting the drive in Virtual PC didn’t work. I had to get it resized to under 127Gb to get it booting. Googling around I found a few tools but none of them worked the way I needed them to. I had to get my drive size under 127Gb. Some researching later I found that the computer management console, disk management, in Windows 7 was able to mount and shrink my VHD. So fingers crossed I started compmgmt.msc and mounted the drive.

cmpmgmt1

Right clicking on Disk Management and selecting attach Virtual Hard disk worked like a charm. So now let’s shrink the drive. Select your drive from the list and right click selecting Shrink.

image

After the query is done it will tell you how much it will be able to shrink the volume. If it’s still over 127Gb you can activate the drive in Computer Management and go delete some files. I had a lot of downloaded files I had to delete before I could get it to shrink under 127Gb. When the shrink operation is done we still have to shrink the vhd file. This just made our Windows partition smaller and now we want to get rid of the unused partition from the VHD file to get it under the magic 127Gb line.

VHDResizer to the rescue

All you need to do now is get the software vhdresizer and have it resize your vhd. You can get VHDResizer from http://vmtoolkit.com/files/folders/converters/entry87.aspx

image 

Still no roses

I was hoping this would be the end of the journey and I would be able to boot the system. You could try it at this point but for some reason my system wont boot. I booted into the XP setup and ran FIXBOOT and FIXMBR and the system still won’t boot. So next I tried an Repair install. Victory!

The repair install fixed any issues but I’m tempted to go trough the same again to check where this really fails. I’m sure you can do this without the repair install.

But the result is the same, I have my old desktop OS back and can use the tools when I need to and I didn’t have to reinstall from scratch. If anyone else has had the same problems and solved them without repair install I would be curious to know what you did.

2 comments

Windows 7 report after 4 months of use

by Mats Hellman on 18.Oct, 2009 under Windows, Windows 7

I’ve now been a Windows 7 user for little over 4 months. And I must say the ride has been a lot better than it was back in the days I tried using Windows Vista.

Primarily I’ve been using Windows 7 64-bit on my Lenovo X200s and I’m amazed how well it runs on this laptop. The Vista drivers from the Lenovo download site work well on the machine and everything, yes every piece of hardware has been working from day one. You can read about my previous experience from this post.

I’ve since updated from the Beta to RTM version and decided to do a full reinstall instead of upgrading.

Sleep and hibernate

One of the things that in earlier versions of Windows has always annoyed me was the poorly working Sleep and Hibernate functions. Sleep never worked really well before Windows 7 and Hibernate, well it worked but had it’s glitches.

Since I started running Windows 7 I seldom turn of my laptop. Sleep works so darn well and it’s blazing fast (almost as fast as OS X) to start up when you need it to. I really only do some reboots to force the laptop to talk with the company domain controllers.

Antivirus and malware

We use F-Secure in our company network and it really was unusable in Windows 7 back when I installed Windows 7 RTM. It slowed the Lenovo down to a point I just had to remove it. The laptop was more or less unusable when F-Secure Client 8.01 was installed. So I had to remove it, I can’t wait 2 minutes when login in or even longer when trying to access the corporate network using VPN, sometimes not connecting at all.

Microsoft Security Essentials to the rescue

Microsoft security essentials is the new security suite by Microsoft. It has the basic Virus and Spyware scanner. What I really like about this one is it’s Microsoft Security Essentialslight if you compare it to most other suites. It doesn’t take 70% of my memory or processing power to run. And that, to me anyway,  is just as important as being protected. Why would I want to protect my computer if it makes it unusable, the point of the computer is to run software on it to make your life easier. If the reason to hardware upgrades is your antivirus suite is using all your resources the antivirus industry has really taken a step in the wrong direction somewhere along the way.

After installing Microsoft Security Essentials the first thing I notice is how light it is, I really don’t see an performance drop at all. It has a small memory footprint and it’s fast. We’ll see how well it protects users as soon as the first really bad worm hits the fan.

Virtualization in Windows 7

This has actually been the one thing I’ve had a bad experience in Windows 7 with. I’ve hear good things about the Virtual XP, but I have no use for it. What I do use is Windows Virtual PC for testing and learning. And I had to remove it from my system and install Virtual PC 2007 SP1 due to the fact Windows Virtual PC was really really slow. One problem might be I’m running it on a laptop, but the laptop does have 4 Gb RAM and support for hardware virtualization. So for now I’m sticking to Virtual PC 2007 SP1 because it works a lot faster and I can run more virtual machines in it than I could ever dream of doing in Windows Virtual PC.

Another thing I dislike in Windows Virtual PC is the way it is set up, I like to start my Virtual PC 2007 and be able to get the toolbar for settings and have at least some control over how the program works. And to my disappointment Microsoft has  removed (or I just can’t find it) this feature from the new Windows Virtual PC.

Libraries

Here is something I like. Really like. The new libraries, I use them like crazy. It’s a really good thing I can spread out files where ever librariesI see fit and still have them listed in Libraries. It’s also a fast way to access important data like documents, downloads, pictures or even movies. So it your not using these take a look at them try them and you will use them.

You can link basically any existing folder to your libraries and always have a fast access to that folder even if it’s stored somewhere else on the filesystem.

Conclusion

Is Windows 7 really worth the upgrade money. I’d say yes and no. If you are running Vista and you’re happy with it I se no reason to upgrade. On the other hand, if you have as many problems with Vista I’ve had Windows 7 isn’t a bad upgrade.

If you’re running Windows XP and you’re happy whit it I’d say the same thing. If you want a modern operating system with a few more bells and whistles and you feel ok to couch up some money to upgrade then it might be a good idea.

Windows 7 isn’t really a revolutionary product, it more of a evolutionary product  just as XP was for Windows 2000 (to whom ever who just almost had an heart attack, I’m not comparing 2000 to Vista). Windows 7 doesn’t bring as much to the table as it should to be a really attractive update if your current operating system fits your needs.

Leave a comment