Skip navigation

Making a Large Virtual Lab Using Minimal Hard Drive Space

As a presenter and author one of the biggest problems that I come across is running out of hard drive space when building virtual machines (VMs) for demos and screenshots.  Up until very recently I was using a brand new virtual machine for each virtual machine that I needed and space was very tight.  I even picked up a home NAS to use to store the VMs when I wasn't using them so my laptop would only need the VMs that I was actively using on my laptop.  But even with doing this I could only keep about 5 or 6 VMs on my laptop at a time as each VM was taking up about 20-30 Gigs of disk space.

Recently one of my friends reminded me that VMware Workstation can take a snapshot of a VM and that Snapshot can be used as a brand new VM allowing you to have a pretty small amount of disk space for the base install of the VM.

So I went along and blew away my VMs (most of them needed rebuilding anyway) and I started with a base image (which I called "Base Image") which was a Windows Server 2008 R2 Data Center edition install.  On this I installed Windows and patched it up to the current patch level.  I then took five snapshots one for each version of SQL Server from SQL Server 2008 to SQL Server "Denali" CTP called "SQL {Version} Base Image".  Once those machines were booted up and installed (along with their Adventure Works databases) I ran sysprep on the machines and powered down the machines.  I could now snapshot these snapshots and build my actual lab machines.

I started with a domain controller which was actually a snapshot of the "base image" VM.  This gave me a Windows AD domain to work with which is needed for things like Clustering, and AlwaysOn.  Next I made my AlwaysOn demo machines which is 5 separate VMs all snapped from the "SQL Denali Base Image".

Next I setup my SQL 2008 R2 Clustering demo machines which are just a 2 node cluster.  At this point I've got 7 VMs each with Windows 2008 R2 Data Center and some version of SQL Server installed and I'm averaging about 1 Gig of space used for each VM in my lab when using this technique.

Setting everything up to work is actually pretty easy.  Let's walk through setting up the SQL Server 2005 base image and building a working client VM running SQL Server 2005.  The base image has already been built, but hasn't been syspreped so when we snapshot the machine it'll be like it was just rebooted.

The first thing we do if fire up VMware Workstation.  (These screenshots were taking before the article was written so not all the VMs that I've mentioned show up in the screenshots.)

We start by bringing up the list of Virtual Machines on the laptop and selecting the Base Image as shown in Figure 1.

Figure 1: VMware Workstation Virtual Machine List

When we right click on the machine after opening it we select the Snapshot Manager which brings up the screen as shown in Figure 2.

Figure 2: The Snapshot Manager.

Within the snapshot manager we click the clone button which starts the "Clone Virtual Machine Wizard".  We click next on the first screen of the wizard which is simply an informational screen.  On the second screen of the wizard we select the top radio button which tells the wizard that we want to create a cloned virtual machine from the current state of the base virtual machine as shown in Figure 3.  If there is already a snapshot that you want to use you can select it from the drop down on the bottom of the screen.

Figure 3: Step 2 of the Clone Virtual Machine Wizard selecting the current state of the virtual machine.

On the next screen of the Clone Virtual Machine Wizard we can either select to create a full clone of a linked clone.  As this isn't a production server and the goal here is to safe lots of space we select the "Create a linked clone" option as shown in Figure 4 and click next.

Figure 4: Step 3 of the Clone Virtual Machine Wizard selecting to create a linked clone.

On the next screen of the Clone Virtual Machine Wizard we name the image and tell VMware where we want to store the new virtual machine as shown in Figure 5.

Figure 5: Step 4 of the Clone Virtual Machine Wizard naming the new virtual machine.

To keep things organized I drop the new VM named "SQL 2005 Base Image"  into the Templates folder.  Then we power up the VM and install SQL Server 2005 on the VM.  Nothing special is done here so I'm going to skip the SQL Server installation part of the process.  Once the installation of SQL Server (and anything else that needs to be available on every VM) is complete it is time to sysprep the VM.  To do this open a command shell window and navigate to c:\windows\system32\sysprep\ and run sysprep.exe (thankfully sysprep is now included with Windows now instead of needing to be downloaded separately).  When the sysprep window opens select "Enter System Out-of-Box Experience (OOBE)" from the "System Cleanup Action" drop down menu and select "Shutdown" from the "Shutdown Options" menu as shown in Figure 6.

Figure 6: The sysprep user interface setup to build the machine and shutdown.

After you click OK the virtual machine will shut itself own.  If you plan on powering up the machine without having it be syspreped you'll want to take a snapshot before shutting down the VM.  Once the machine has shut it self-down you can snapshot the machine just like above which will create the virtual machine which you then rename and add to the Windows domain (if needed) and do whatever you need to with it.  As we may want multiple virtual machines running SQL 2005 we might want to snapshot the base machine two or three times only taking up a very small amount of space each time.

You don't need to be a speaker or author to make use of this technique when creating your VMs.  Anyone who is doing testing or research at work can use this to safe space.  The reason that this works so well in the lab is that typically we only need to run one or two VMs at a time so with the machines sharing the same physical space is fine as performance will be the same as it would be normally.

Hopefully you will find that this technique works as well for you as it does for me in my laptop LAB environment.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.