Differencing Disks in Virtual PC 2007

Yesterday I mentioned I was going to get SQL Server 2008 installed in a Virtual PC (VPC). Now, I could have setup a virtual machine from scratch, or copied an existing one. But there’s a better way: differencing disks. Differencing disks allow you to create a virtual machine, then use it as a base for new machines. Much like you would create a base class and then let new classes inherit from your base.

My first step was to create a brand new virtual PC. I chose Windows Server 2003, using the one from my MSDN license. I could also have gone with XP, or the advanced versions of Vista licenses you to install up to four virtual machines in addition to itself as the host. So I get my VPC setup with Windows Server 2003, and make sure all of the windows updates have been applied, service packs, etc. In addition, if there are any additional tools / utilities I’d like to have available for every machine I’ll be wanting create from it I’ll install those as well. I’m thinking of things like UltraEdit / Notepad++, IE7, AllSnap, etc. I finally conclude by shutting down the machine.

Exit Virtual PC, and go to the folder where your virtual PC’s reside. First delete the VMC file (the small one) of your Virtual PC. You won’t need it any more, as you’ll never open this VPC directly. If you did, you would break all the machines that inherit from it. Again, not unlike changing the signature of a base class.

Next, mark the VHD, the hard drive as Read Only. Again this is for your protection, to keep you from doing something accidental to the base. At this point we have our base machine created, and can now make new machines from it.

Launch Virtual PC again. Click on File, Virtual Disk Wizard. You are given a simple dialog that lets you know you’re in the Virtual Disk Wizard. Click Next to move along.

[Picture 1 - Welcome to Virtual Disk Wizard]

Next it asks if we want to create a new disk or edit an existing one. We’ll want to create a new one, so just click Next.

[Picture 2 - Create a new virtual disk]

Now it wants to know what kind of disk to create. We’re doing a hard disk, so just take the default of virtual hard disk and click next.

[Picture 3 - Disk Type]

Now it asks where you want to put your virtual hard disk. I keep mine on my D drive, and use a naming convention. I start with the OS, then the main software I am using. I then use either the word Working, to indicate it’s alright to launch and work in it, or Base, to show the vhd should only be used to inherit from and not be launched. In this case I will be using this as a working area for my SQL Server 2008 CTP6, so I used Working. You are free of course to name it whatever you want, use a name like “Hanselman is cool.vhd” if you like I just prefer something a bit more logical.

[Picture 4 - Disk Location]

OK, this is where you need to pay attention, as this is the first time you’ll need to change a default. Here you are asked what type of virtual hard drive to create. The default is dynamically expanding, and it’s what you’d want to use if you are installing an OS from scratch or are creating a second hard drive for your virtual machine. Fixed size would be used if you are creating a disk for something like a USB drive and want to make sure it won’t get too big. Again, this would be used when you need an empty drive.

In our case we want the third option, Differencing. What this does is tell the Virtual PC application to base the new hard drive on an existing one. From here on out, only the changes you make to the virtual drive will be recorded. This has a lot of benefits. First it saves you disk space, in that you can use the same base with multiple virtual machines. Second, it lets you install the base OS only once, and not have to keep recreating it over and over. Finally, you can create multiple generations of disks. For example, I could create a base of Windows 2003, then another base with Visual Studio added. I could then use that base to inherit from, and create two drives. One could be used with SQL Server 2008, the other with SQL Server 2005. In our case we’re keeping it simple, so pick Differencing and click next.

[Picture 5 - Hard Disk Options]

Next we need to pick the virtual hard drive we want to base our new machine on. In this case I am selecting my Windows Server 2003 core base, and clicking next.

[Picture 6 - Pick Base Hard Drive]

Next we are told it has all the info it needs. All we have to do is click Finish and we’ll have our new Virtual Hard Disk.

[Picture 7 - Complete Disk Creation]

Virtual PC thoughtfully tells us it was successful.

[Picture 8 - Confirmation Message]

OK, we have a new disk, but now we need to tell Virtual PC we want to use it. Back on the Virtual PC Console, Select File, New Virtual Machine Wizard OR click the New… button on the console. Virtual PC has a need to tell us what we just picked, so just click Next.

[Picture 9 - Create Machine Wizard]

This time we are creating a new virtual machine, which will be based on the virtual hard drive we just created, so take the default and click next.

[Picture 10 - Create a machine]

Next we need to give our machine a name. I usually give it the same name as the hard drive, except for the vmc extension. Name yours and click next.

[Picture 11 - Macine name and location]

Now it asks what OS we’ll be using. Note it has automatically detected that I’m using Windows Server 2003, so all I have to do is click next.

[Picture 12 - Confirm Operating System]

Now it asks what my default RAM size will be. I figure 256 MB is a bit small, since I have the ram I upped it to 768 MB. Set yours according to the free space you can spare and click next.

[Picture 13 - Select default amount of memory]

Now we’re asked if we want to use an existing disk or create a new one. Obviously we want to use the differencing one we just created, so click next.

[Picture 14 - Existing Disk or New Disk - We want existing]

Next it asks where our existing drive is, pick it out using the Browse… button or type it in.

[Picture 15 - Pick name of existing disk]

Let me call your attention to the Check Box, “Enable undo disks”. If you leave this unchecked, your virtual machine will behave like a normal computer. Any changes you make are applied and saved. If you check the undo option on, then during your session any changes are written to a temporary file. When you exit the VPC, you are asked if you want to save any changes you made. If you say yes, they will be permanently applied to the virtual machine. If you say no, they are discarded, lost forever. Undo disks are ideal for test situations where you want to run the same changes over and over but not save them. Testing software installs, for example, or in a classroom where you want the students to do labs but not save them.

While Undo Disks can be very helpful, in this situation I don’t really need them as I want to keep all my changes so I will leave this unchecked and click next.

[Picture 16 - Complete Machine Wizard]

OK, we’re at the finish line. All we have to do is click Finish to complete the creation of our new virtual machine.

Let me call your attention to the file sizes of our new machine. Take a look at them in explorer…

[Picture 17 - Explorer snapsho showing small size of vhd]

Note how tiny the vhd file is right now. That’s because it’s based on another drive, where all the OS bits are. As we open it and apply changes (such as installing SQL Server 2008) it will grow in size, but we’ll always be able to save the disk space of the OS as it’s coming from another file.

The down side to differencing disks is speed, because they are in multiple files the performance won’t be as great. Additionally you can’t update the base machine without breaking its descendants. However, differencing disks offer several advantages as well. They save you time, in that you can create a base OS once and use it over and over. As you can see above they can also save you disk space, in that the core OS only takes up space once on your drive and not over and over.

Consider Differencing Disks, and whether they might be appropriate to your development environment.

Downloading a Virtual PC Image of Visual Studio 2008 Beta 2

During last week’s WPF class, several of my coworkers expressed an interest in using the 2008 edition to experiment with WPF. They were concerned installing the beta on their production box could damage their boxes, even though in theory part of the beauty of .Net is the ability to run multiple versions of the framework side by side.

To alleviate those fears, Microsoft has provided a Beta of 2008 already in a ready to run Virtual PC. First, you’ll need to have Microsoft Virtual PC 2007 installed on your box. If you don’t, you can grab a copy from

http://www.microsoft.com/downloads/details.aspx?familyid=04D26402-3199-48A3-AFA2-2DC0B40A73B6&displaylang=en

(Even though the instructions indicate it should work with VPC 2004 SP1 or Virtual Server, I haven’t tried it with them. Virtual Server should be fine, but I would highly suggest upgrading your VPC 2004 to 2007 if you haven’t done so already, there’s lots of nice new features that make it worth the effort.)

Now you can grab the 2008 image. You will actually need two sets of files, the base image and the 2008 Beta 2 image. You can download the 2008 Beta 2 from

http://www.microsoft.com/downloads/details.aspx?FamilyID=3b72271c-e996-4989-898d-72d684966ce6&DisplayLang=en

The download is in the form of 7 files, the first is an exe and the rest are rar files. Download all 7 to a folder and run the exe, and it will combine all 7 to create the virtual pc image.

Make sure to read all of the instructions on this page! The user ID and password to login to the virtual image, along with a link to the needed base image, are contained in the instructions!

Now you need the Orcas base image. If you read through the instructions you saw the link to the compressed file, right above the user id / password. Right click on the link and “Save As…” to the same folder where you saved the other items. Run it to uncompress the base image.

OK, in a folder you should now have OrcasBeta2_VSTS.vmc, OrcasBeta2_VSTS.vhd, Base01.vmc, and Base02.vhd. I also copied the user id and password from the above linked page and saved it in a text file called “Orcas Beta 2 user id and password.txt”, just so I could remember it easily.

When you login, it tells you that the password expries today, and asks if you wish to change it. I’ve always just said no, and it seems to work fine, but you are welcome to change it if you want.

When you shut down the Virtual PC, you will be prompted first for why you are shuting down. This is a Windows Server 2003 prompt, I just select “Other (Planned) under the option and put an ‘x’ for the comment. Once you do the OK button will be enabled.

Next, Virtual PC prompts you, to see if you want to commit your changes or abandon them. If you select “Commit changes to the virtual hard disk”, any changes you made will be saved and ready for next time. If you choose “Delete undo disk changes”, everything you did during that session will be lost forever.

Since it’s just a virtual image, I usually pick commit, but if you have really hosed things up you might want to know about the Delete option.

All of the software I’ve mentioned here is free, so there’s no reason why you can’t run this at home, even if you don’t have an MSDN subscription. Be warned, although Microsoft hasn’t specified a date I would think the image will expire not long after the release of the full Visual Studio 2008 product.

Using the virtual image will allow you to experiment with WPF, as well as the new 2008 features in a safe, risk free environment.

Note: If you want to use Visual Studio 2005 to write WPF (as well as other .Net 3.0 projects), I have documented the bits you need to download in this post:

http://arcanecode.wordpress.com/2007/08/20/installing-the-wpf-bits/

SQL Server Integration Services and the “The script files failed to load” Error

I have an SSIS job that has been running on our test server since April, with no issues. Last week it just quit working. About the fourth package in I started getting “The script files failed to load” error when loading a very simple VB Script inside a package.

A web search led me to this forum page:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=267047&SiteID=1

To save you from wading through all the messages, the two causes of this error could be 1) Package’s PreCompile was set to False, or 2) I had breakpoints in the package.

So I check, and nope my PreCompile was set to true (the default) and there were no breakpoints. In addition, most of the people posting in the forum link above couldn’t get their packages to run in the first place, this didn’t seem to occur in packages like mine that had been running fine for a while.

Next I thought, OK what about environmental issues? Mining our extensive logs I was able to determine the time when one moment the scripts work, then 15 minutes later they no longer worked.

With that exact 15 minute interval known, the DBA team reviewed what had happened on the server, and sure enough a security patch for the .Net 1.1 Framework had been applied on the server during that exact time. Bingo!

It took us 2 days to work through the issue, the team, and I have to be honest and include myself here, had the thought process “well, the error is just on the test server, we’ll get to it when we can.” Since it was just a test server, and we weren’t testing anything at the time, we weren’t stressing over it.

We should have been. The very same patch was scheduled to be rolled to our production server just an hour and a half after we found it. Had that scheduled deployement occurred we would have been in deep diaper filling.

Let me make a quick distinction here, in that it’s not necessarily fixing the issue that’s urgent, but identifiying it. Once you have it identified, you can control it. By not quickly identifying the issue, we nearly rolled the same patch into production.

So the first point here, if your SSIS package which has been running for a while suddenly starts getting “The script files failed to load” error, check to see if any .Net Framework 1.1 patches were applied.

Second, this shows you how important good logging can be. With our extensive logging I was able to determine with a fifteen minute window when the problem occurred.

Finally, never treat issues that occur on your test server as if they are not important. We were quite lucky, narrowly avoiding disaster on our production server. Identify the cause quickly, so you can control it.

Update: We found a fix that worked, see http://arcanecode.wordpress.com/2007/07/18/ssis-issue-from-monday/ for more detail.

Follow

Get every new post delivered to your Inbox.

Join 104 other followers